mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-09 18:29:45 +02:00
Add support for HostnameVerifier
This commit is contained in:
parent
fe258fe110
commit
d35fd16a21
3 changed files with 55 additions and 0 deletions
|
@ -46,6 +46,7 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.KeyManager;
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
|
@ -674,6 +675,11 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
// Proceed to do the handshake
|
||||
sslSocket.startHandshake();
|
||||
|
||||
final HostnameVerifier verifier = getConfiguration().getHostnameVerifier();
|
||||
if (verifier != null && !verifier.verify(getServiceName(), sslSocket.getSession())) {
|
||||
throw new CertificateException("Hostname verification of certificate failed. Certificate does not authenticate " + getServiceName());
|
||||
}
|
||||
|
||||
//if (((SSLSocket) socket).getWantClientAuth()) {
|
||||
// System.err.println("XMPPConnection wants client auth");
|
||||
//}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue