From 5f673452753fe57a413780309db1d281f5d3e0fb Mon Sep 17 00:00:00 2001 From: Georg Lukas Date: Sat, 26 Jul 2014 21:55:52 +0200 Subject: [PATCH] Make XMPPTCPConnection fail without a HostnameVerifier --- .../java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java index c2b17f30e..d59a53c3c 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java @@ -676,7 +676,9 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { sslSocket.startHandshake(); final HostnameVerifier verifier = getConfiguration().getHostnameVerifier(); - if (verifier != null && !verifier.verify(getServiceName(), sslSocket.getSession())) { + if (verifier == null) { + throw new IllegalStateException("No HostnameVerifier set. Use connectionConfiguration.setHostnameVerifier() to configure."); + } else if (!verifier.verify(getServiceName(), sslSocket.getSession())) { throw new CertificateException("Hostname verification of certificate failed. Certificate does not authenticate " + getServiceName()); }