Top Description Fields Constructors Methods
org.conscrypt

public final Class OkHostnameVerifier

extends Object
implements ConscryptHostnameVerifier
Class Inheritance
All Implemented Interfaces
org.conscrypt.ConscryptHostnameVerifier
Imports
java.security.cert.Certificate, .CertificateParsingException, .X509Certificate, java.util.ArrayList, .Collection, .Collections, .List, .Locale, java.util.regex.Pattern, javax.net.ssl.SSLException, .SSLSession

A HostnameVerifier consistent with RFC 2818.

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
public static final OkHostnameVerifier
private final boolean
private static final Pattern
VERIFY_AS_IP_ADDRESS

Quick and dirty pattern to differentiate IP addresses from hostnames.

Constructor Summary

AccessConstructor and Description
private
OkHostnameVerifier(boolean strictWildcardMode)

Method Summary

Modifier and TypeMethod and Description
public static List<String>
private static List<String>
getSubjectAltNames(X509Certificate certificate, int type)

public static OkHostnameVerifier
public boolean
verify(X509Certificate[] certs, String host, SSLSession session)

Implements org.conscrypt.ConscryptHostnameVerifier.verify.

Returns whether the given hostname is allowable given the peer's authentication information from the given session.
public boolean
verify(String host, X509Certificate certificate)

pack-priv static boolean
private boolean
verifyHostName(String hostName, X509Certificate certificate)

Returns true if certificate matches hostName.

private boolean
verifyHostName(String
lower-case host name.
hostName
,
String
domain name pattern from certificate. May be a wildcard pattern such as *.android.com.
pattern
)

Returns true iff hostName matches the domain name pattern.

private boolean
verifyIpAddress(String ipAddress, X509Certificate certificate)

Returns true if certificate matches ipAddress.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ALT_DNS_NAMEback to summary
private static final int ALT_DNS_NAME
ALT_IPA_NAMEback to summary
private static final int ALT_IPA_NAME
INSTANCEback to summary
public static final OkHostnameVerifier INSTANCE
strictWildcardModeback to summary
private final boolean strictWildcardMode
VERIFY_AS_IP_ADDRESSback to summary
private static final Pattern VERIFY_AS_IP_ADDRESS

Quick and dirty pattern to differentiate IP addresses from hostnames. This is an approximation of Android's private InetAddress#isNumeric API.

This matches IPv6 addresses as a hex string containing at least one colon, and possibly including dots after the first colon. It matches IPv4 addresses as strings containing only decimal digits and dots. This pattern matches strings like "a:.23" and "54" that are neither IP addresses nor hostnames; they will be verified as IP addresses (which is a more strict verification).

Constructor Detail

OkHostnameVerifierback to summary
private OkHostnameVerifier(boolean strictWildcardMode)

Method Detail

allSubjectAltNamesback to summary
public static List<String> allSubjectAltNames(X509Certificate certificate)
getSubjectAltNamesback to summary
private static List<String> getSubjectAltNames(X509Certificate certificate, int type)
Annotations
@SuppressWarnings:MixedMutabilityReturnType
strictInstanceback to summary
public static OkHostnameVerifier strictInstance()
verifyback to summary
public boolean verify(X509Certificate[] certs, String host, SSLSession session)

Implements org.conscrypt.ConscryptHostnameVerifier.verify.

Doc from org.conscrypt.ConscryptHostnameVerifier.verify.

Returns whether the given hostname is allowable given the peer's authentication information from the given session.

Annotations
@Override
verifyback to summary
public boolean verify(String host, X509Certificate certificate)
verifyAsIpAddressback to summary
pack-priv static boolean verifyAsIpAddress(String host)
verifyHostNameback to summary
private boolean verifyHostName(String hostName, X509Certificate certificate)

Returns true if certificate matches hostName.

Annotations
@SuppressWarnings:UnusedVariable
verifyHostNameback to summary
private boolean verifyHostName(String hostName, String pattern)

Returns true iff hostName matches the domain name pattern.

Parameters
hostName:String

lower-case host name.

pattern:String

domain name pattern from certificate. May be a wildcard pattern such as *.android.com.

verifyIpAddressback to summary
private boolean verifyIpAddress(String ipAddress, X509Certificate certificate)

Returns true if certificate matches ipAddress.