public class EntrustHostnameVerifier
extends java.lang.Object
implements javax.net.ssl.HostnameVerifier
3.6. Server Identity Check
The client MUST check its understanding of the server's hostname against the server's identity as presented in the server's Certificate message, in order to prevent man-in-the-middle attacks.
Matching is performed according to these rules:
HostnameVerifier| Constructor and Description |
|---|
EntrustHostnameVerifier() |
| Modifier and Type | Method and Description |
|---|---|
static EntrustSSLSocketFactory.InetHandling |
getInetHandlingForName(java.lang.String host)
This method checks the given hostname and returns the appropriate type
of InetHandling mode, which will be one of the following:
InetHandling.HOSTNAME
InetHandling.IPADDRESS
This method should be used when creating a socket using the
EntrustSSLSocketFactory when the EntrustSSLSocketFactory.create() method uses
a java.net.InetAddress or the unconnected Socket's connect() method uses
java.net.SocketAddress. |
protected boolean |
getTLSServerNameAndMatch(java.lang.String hostname,
X509Certificate cert)
Extract the TLS servername(s) from the certificate and compare it against the
hostname for a match.
|
boolean |
verify(java.lang.String hostname,
javax.net.ssl.SSLSession sslSession)
Given a hostname and the SSLSession, determine if the Server Identity
check passes according to RFC 2830.
|
protected boolean |
verifyServer(java.lang.String hostname,
java.lang.String[] names)
Do the comparison using a String array of candidate DNS.
|
boolean |
verifyServer(java.lang.String hostname,
X509Certificate[] certs)
Do the actual Hostname verification.
|
protected boolean |
verifyServerIP(java.lang.String IPString,
java.lang.String[] names)
Do the comparison using the IP address strings converted to network
byte order.
|
public boolean verify(java.lang.String hostname,
javax.net.ssl.SSLSession sslSession)
Matching is performed according to these rules:
verify in interface javax.net.ssl.HostnameVerifierhostname - the hostname being verifeidsslSession - the SSLSession which will be verified against the hostnameHostnameVerifierprotected boolean getTLSServerNameAndMatch(java.lang.String hostname,
X509Certificate cert)
hostname - The hostname being verified in String formatcert - the Certificate whose server names are being checkedpublic boolean verifyServer(java.lang.String hostname,
X509Certificate[] certs)
hostname - the hostname which will be verifiedcerts - the array of certificates which will be verifiedprotected boolean verifyServer(java.lang.String hostname,
java.lang.String[] names)
hostname - the hostname which will be verifiednames - The array of hostnames that will be used to try and find a matchprotected boolean verifyServerIP(java.lang.String IPString,
java.lang.String[] names)
IPString - the IP String that will be converted to a byte[] in
network byte ordernames - The array of IPStrings that will be used to try and find a matchpublic static EntrustSSLSocketFactory.InetHandling getInetHandlingForName(java.lang.String host)
InetHandling.HOSTNAMEInetHandling.IPADDRESSEntrustSSLSocketFactory factory = new EntrustSSLSocketFactory(tm,km,sr); InetSocketAddress address = new InetSocketAddress(host, port); InetHandling inet = EntrustHostnameVerifier.getInetHandlingFor(host); factory.setInetAddressHandling(inet); SSLSocket s = (SSLSocket)factory.createSocket(); s.setEnabledCipherSuites(CIPHER_SUITES); s.connect(address, m_timeout);
host - The hostname String which can either be in a hostname format
(for example 'test.example.com') or IP address format (192.0.2.4).