SocketFactoryCreator.connectWithHostnameChecking(SSLSocket, HostnameMismatchCallback)
instead. This class is not perfect as the HandshakeCompletedListener
is invoked (at least in reference JDK)
in a separate thread, what can easily lead to a situation when the connection is opened and made available,
before this implementation finishes checking.@Deprecated public abstract class AbstractHostnameToCertificateChecker extends Object implements HandshakeCompletedListener
HandshakeCompletedListener
which can be registered on a SSLSocket
to verify if a peer's
host name matches a DN of its certificate. It is useful on client side
when connecting to a server.
By default the implementation checks the certificate's Subject Alternative Name and Common Name, following the server identity part of RFC 2818. Additionally the 'service/hostname' syntax is supported (the service prefix is simply ignored).
If there is a name mismatch the nameMismatch() method is called. User of this class must extend it and provide the application specific reaction in this method.
Note that this class should be used only on SSL connections which are authenticated with X.509 certificates.
Constructor and Description |
---|
AbstractHostnameToCertificateChecker()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
handshakeCompleted(HandshakeCompletedEvent hce)
Deprecated.
|
protected abstract void |
nameMismatch(HandshakeCompletedEvent hce,
X509Certificate peerCertificate,
String hostName)
Deprecated.
This method is called whenever peer's host name is not matching the peer's
certificate DN.
|
protected void |
processingError(HandshakeCompletedEvent hce,
Exception e)
Deprecated.
This method is called whenever there is an error when processing the peer's certificate
and hostname.
|
public AbstractHostnameToCertificateChecker()
public void handshakeCompleted(HandshakeCompletedEvent hce)
handshakeCompleted
in interface HandshakeCompletedListener
protected abstract void nameMismatch(HandshakeCompletedEvent hce, X509Certificate peerCertificate, String hostName) throws SSLException
hce
- the original event objectpeerCertificate
- peer's certificate (for convenience)hostName
- peer's host name (for convenience)SSLException
- SSL exceptionprotected void processingError(HandshakeCompletedEvent hce, Exception e)
IllegalStateException
.hce
- the original event objecte
- errorCopyright © 2012-2017 European Middleware Initiative. All Rights Reserved.