java.lang.Object
nl.altindag.ssl.hostnameverifier.FenixHostnameVerifier
- All Implemented Interfaces:
HostnameVerifier
NOTE:
Please don't use this class directly as it is part of the internal API. Class name and methods can be changed any time.
Instead use the
HostnameVerifierUtils which provides the same functionality
while it has a stable API because it is part of the public API.
This verifier does not accept addresses in the subjectDN:commonName attribute
and it will not verify names or wildcards against the Public Suffix List.
Therefore use of wildcards is not limited to subdomains.
This HostnameVerifier is copied from OkHttp library, see here for the original content:
- https://github.com/square/okhttp/blob/69ae7f3e10dae0554f3181edaa52bcd77ee448ab/okhttp/src/jvmMain/kotlin/okhttp3/internal/tls/OkHostnameVerifier.kt#L1-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate static final intprivate static final HostnameVerifier -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate StringasciiToLowercase(String value) This is like [toLowerCase] except that it does nothing if this contains any non-ASCII characters.static HostnameVerifierprivate Optional<X509Certificate> getPeerCertificate(SSLSession sslSession) Returns the first certificate from the peer certificates if present.getSubjectAltNames(X509Certificate certificate, int type) private booleanReturns true if the [String] is ASCII encoded.private booleanisHostnameInValid(String hostname) (package private) StringtoAbsolute(String hostname) Normalize hostname by turning it into absolute domain names if it is not yet absolute.private booleanverify(String host, X509Certificate certificate) booleanverify(String host, SSLSession sslSession) private booleanverifyHostname(String hostname, String domainNamePattern) Returns true if [hostname] matches the domain name pattern.private booleanverifyHostname(String hostname, X509Certificate certificate) private booleanverifyIpAddress(String ipAddress, X509Certificate certificate) Returns true if [certificate] matches [hostname].private booleanverifyWildcardPattern(String hostname, String domainNamePattern) WILDCARD PATTERN RULES: 1.
-
Field Details
-
INSTANCE
-
ALT_DNS_NAME
private static final int ALT_DNS_NAME- See Also:
-
ALT_IPA_NAME
private static final int ALT_IPA_NAME- See Also:
-
-
Constructor Details
-
FenixHostnameVerifier
private FenixHostnameVerifier()
-
-
Method Details
-
getInstance
-
verify
- Specified by:
verifyin interfaceHostnameVerifier
-
isAscii
Returns true if the [String] is ASCII encoded. -
getPeerCertificate
Returns the first certificate from the peer certificates if present. -
verify
-
verifyIpAddress
Returns true if [certificate] matches [hostname]. -
getSubjectAltNames
-
verifyHostname
-
verifyHostname
Returns true if [hostname] matches the domain name pattern.- Parameters:
hostname- lower-case host name.domainNamePattern- domain name pattern from certificate. Maybe a wildcard pattern such as `*.android.com`.
-
isHostnameInValid
-
toAbsolute
Normalize hostname by turning it into absolute domain names if it is not yet absolute. This is needed because server certificates do not normally contain absolute names, but they should be treated as absolute. At the same time, any hostname presented to this method should also be treated as absolute for the purposes of matching to the server certificate. www.android.com matches www.android.com www.android.com matches www.android.com. www.android.com. matches www.android.com. www.android.com. matches www.android.com -
asciiToLowercase
This is like [toLowerCase] except that it does nothing if this contains any non-ASCII characters. We want to avoid lower casing special chars like U+212A (Kelvin symbol) because they can return ASCII characters that match real hostnames. -
verifyWildcardPattern
WILDCARD PATTERN RULES: 1. Asterisk (*) is only permitted in the left-most domain name label and must be the only character in that label (i.e., must match the whole left-most label). For example, *.example.com is permitted, while *a.example.com, a*.example.com, a*b.example.com, a.*.example.com are not permitted. 2. Asterisk (*) cannot match across domain name labels. For example, *.example.com matches test.example.com but does not match sub.test.example.com. 3. Wildcard patterns for single-label domain names are not permitted.
-