java.lang.Object
net.i2p.apache.http.conn.ssl.DefaultHostnameVerifier
- All Implemented Interfaces:
HostnameVerifier
Default
HostnameVerifier implementation.Field Summary
FieldsModifier and TypeFieldDescription(package private) static final intDNS name type constant.(package private) static final intIP address type constant.private final LogLogger instance.private final PublicSuffixMatcherPublic suffix matcher.Constructor Summary
ConstructorsConstructorDescriptionCreate hostname verifier with default settings.DefaultHostnameVerifier(PublicSuffixMatcher publicSuffixMatcher) Create hostname verifier with public suffix matcher.Method Summary
Modifier and TypeMethodDescription(package private) static StringExtract the Common Name from the subject principal.extractSubjectAlts(X509Certificate cert, int subjectType) Extract subject alternative names from the certificate.(package private) static voidmatchCN(String host, String cn, PublicSuffixMatcher publicSuffixMatcher) Match the common name against the hostname.(package private) static voidmatchDNSName(String host, List<String> subjectAlts, PublicSuffixMatcher publicSuffixMatcher) Match the DNS name against subject alternative names.(package private) static booleanmatchDomainRoot(String host, String domainRoot) Match the host against a domain root.(package private) static booleanmatchIdentity(String host, String identity) Match the host against the identity.(package private) static booleanmatchIdentity(String host, String identity, PublicSuffixMatcher publicSuffixMatcher) Match the host against the identity with public suffix matching.private static booleanmatchIdentity(String host, String identity, PublicSuffixMatcher publicSuffixMatcher, boolean strict) True when the certificate identity may be used for the host.(package private) static booleanmatchIdentityStrict(String host, String identity) Strictly match the host against the identity.(package private) static booleanmatchIdentityStrict(String host, String identity, PublicSuffixMatcher publicSuffixMatcher) Strictly match the host against the identity with public suffix matching.(package private) static voidmatchIPAddress(String host, List<String> subjectAlts) Match the IP address against subject alternative names.(package private) static voidmatchIPv6Address(String host, List<String> subjectAlts) Match the IPv6 address against subject alternative names.(package private) static StringnormaliseAddress(String hostname) Normalize an IPv6 or DNS name.final voidverify(String host, X509Certificate cert) Verify the hostname against the certificate.final booleanverify(String host, SSLSession session)
Field Details
DNS_NAME_TYPE
IP_ADDRESS_TYPE
log
Logger instance.publicSuffixMatcher
Public suffix matcher.
Constructor Details
DefaultHostnameVerifier
Create hostname verifier with public suffix matcher.- Parameters:
publicSuffixMatcher- public suffix matcher
DefaultHostnameVerifier
public DefaultHostnameVerifier()Create hostname verifier with default settings.
Method Details
verify
- Specified by:
verifyin interfaceHostnameVerifier
verify
Verify the hostname against the certificate.- Parameters:
host- the DNS name or IP literal to match against the certificatecert- the server certificate that must be valid for host- Throws:
SSLException- if verification fails
matchIPAddress
Match the IP address against subject alternative names.- Parameters:
host- the IP address to look forsubjectAlts- the certificate's subject alternative names, each a bare IP string- Throws:
SSLException- if no alternative name equals host
matchIPv6Address
Match the IPv6 address against subject alternative names.- Parameters:
host- the IPv6 address to look forsubjectAlts- the certificate's subject alternative names, in any IPv6 form- Throws:
SSLException- if no alternative name normalises to host
matchDNSName
static void matchDNSName(String host, List<String> subjectAlts, PublicSuffixMatcher publicSuffixMatcher) throws SSLException Match the DNS name against subject alternative names.- Parameters:
host- the DNS name to look for, compared case-insensitivelysubjectAlts- the certificate's subject alternative namespublicSuffixMatcher- rejects names in a public suffix, null to skip that check- Throws:
SSLException- if no alternative name matches host
matchCN
static void matchCN(String host, String cn, PublicSuffixMatcher publicSuffixMatcher) throws SSLException Match the common name against the hostname.- Parameters:
host- the DNS name the certificate was presented forcn- the common name taken from the certificate subjectpublicSuffixMatcher- rejects names in a public suffix, null to skip that check- Throws:
SSLException- if cn does not match host
matchDomainRoot
matchIdentity
private static boolean matchIdentity(String host, String identity, PublicSuffixMatcher publicSuffixMatcher, boolean strict) True when the certificate identity may be used for the host.- Parameters:
host- the host name being connected toidentity- the name from the certificatepublicSuffixMatcher- the public suffix matcher, or nullstrict- whether a wildcard must match a single label- Returns:
- true if the identity matches the host
matchIdentity
Match the host against the identity with public suffix matching.- Parameters:
host- the name being testedidentity- the certificate identity, which may hold one wildcard per labelpublicSuffixMatcher- rejects identities in a public suffix, null to skip it- Returns:
- true if host matches identity under RFC 2818 rules
matchIdentity
matchIdentityStrict
static boolean matchIdentityStrict(String host, String identity, PublicSuffixMatcher publicSuffixMatcher) Strictly match the host against the identity with public suffix matching.- Parameters:
host- the name being testedidentity- the certificate identity, which may hold one wildcard per labelpublicSuffixMatcher- rejects identities in a public suffix, null to skip it- Returns:
- true if host matches identity and any wildcard spans exactly one label
matchIdentityStrict
extractCN
Extract the Common Name from the subject principal.- Parameters:
subjectPrincipal- the X500 principal name- Returns:
- the CN, or null if not found
- Throws:
SSLException- if the name is invalid
extractSubjectAlts
Extract subject alternative names from the certificate.- Parameters:
cert- the certificate to read the subject alternative names fromsubjectType- the subject type (DNS or IP)- Returns:
- the list of subject alternative names, or null
normaliseAddress