• BlackBerry Dynamics
  • Runtime library for Android applications
  • 12.0.1.79
StrictHostnameVerifier Class Reference

The Strict HostnameVerifier works the same way as Sun Java 1.4, Sun Java 5, Sun Java 6-rc. More...

Inheritance diagram for StrictHostnameVerifier:
AbstractVerifier X509HostnameVerifier

Description

It's also pretty close to IE6. This implementation appears to be compliant with RFC 2818 for dealing with wildcards.

The hostname must match either the first CN, or any of the subject-alts. A wildcard can occur in the CN, and in any of the subject-alts. The one divergence from IE6 is how we only check the first CN. IE6 allows a match against any of the CNs present. We decided to follow in Sun Java 1.4's footsteps and only check the first CN. (If you need to check all the CN's, feel free to write your own implementation!).

A wildcard such as "*.foo.com" matches only subdomains in the same level, for example "a.foo.com". It does not match deeper subdomains such as "a.b.foo.com".

Author
Julius Davies

Notice

The following notice applies to the original API on which this API is based, and to its documentation. The documentation of this API has been revised from the original.

/*
 * Copyright (C) 2006 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

Public Member Functions

final void verify (final String host, final String[] cns, final String[] subjectAlts) throws SSLException
 Checks to see if the supplied hostname matches any of the supplied CNs or "DNS" Subject-Alts. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from AbstractVerifier
static String[] getDNSSubjectAlts (X509Certificate cert)
 Extracts the array of SubjectAlt DNS names from an X509Certificate. More...
 
static int countDots (final String s)
 Counts the number of dots "." in a string. More...
 

Member Function Documentation

◆ verify()

final void verify ( final String  host,
final String[]  cns,
final String[]  subjectAlts 
) throws SSLException

Most implementations only look at the first CN, and ignore any additional CNs. Most implementations do look at all of the "DNS" Subject-Alts. The CNs or Subject-Alts may contain wildcards according to RFC 2818.

Parameters
cnsCN fields, in order, as extracted from the X.509 certificate.
subjectAltsSubject-Alt fields of type 2 ("DNS"), as extracted from the X.509 certificate.
hostThe hostname to verify.
Exceptions
SSLExceptionIf verification failed.

Implements X509HostnameVerifier.