Make XMPPTCPConnection fail without a HostnameVerifier

This commit is contained in:
Georg Lukas 2014-07-26 21:55:52 +02:00 committed by Florian Schmaus
parent 7b3331dda0
commit 5f67345275
1 changed files with 3 additions and 1 deletions

View File

@ -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());
}