View Javadoc
1   /*
2    * ====================================================================
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   * ====================================================================
20   *
21   * This software consists of voluntary contributions made by many
22   * individuals on behalf of the Apache Software Foundation.  For more
23   * information on the Apache Software Foundation, please see
24   * <http://www.apache.org/>.
25   *
26   */
27  
28  package org.apache.http.conn.ssl;
29  
30  import java.io.IOException;
31  import java.security.cert.X509Certificate;
32  
33  import javax.net.ssl.HostnameVerifier;
34  import javax.net.ssl.SSLException;
35  import javax.net.ssl.SSLSocket;
36  
37  /**
38   * Interface for checking if a hostname matches the names stored inside the
39   * server's X.509 certificate.  This interface extends
40   * {@link javax.net.ssl.HostnameVerifier}, but it is recommended to use
41   * methods added by X509HostnameVerifier.
42   *
43   * @since 4.0
44   *
45   * @deprecated (4.4) Use {@link javax.net.ssl.HostnameVerifier}.
46   */
47  @Deprecated
48  public interface X509HostnameVerifier extends HostnameVerifier {
49  
50      /**
51       * Verifies that the host name is an acceptable match with the server's
52       * authentication scheme based on the given {@link SSLSocket}.
53       *
54       * @param host the host.
55       * @param ssl the SSL socket.
56       * @throws IOException if an I/O error occurs or the verification process
57       *   fails.
58       */
59      void verify(String host, SSLSocket ssl) throws IOException;
60  
61      /**
62       * Verifies that the host name is an acceptable match with the server's
63       * authentication scheme based on the given {@link X509Certificate}.
64       *
65       * @param host the host.
66       * @param cert the certificate.
67       * @throws SSLException if the verification process fails.
68       */
69      void verify(String host, X509Certificate cert) throws SSLException;
70  
71      /**
72       * Checks to see if the supplied hostname matches any of the supplied CNs
73       * or "DNS" Subject-Alts.  Most implementations only look at the first CN,
74       * and ignore any additional CNs.  Most implementations do look at all of
75       * the "DNS" Subject-Alts. The CNs or Subject-Alts may contain wildcards
76       * according to RFC 2818.
77       *
78       * @param cns         CN fields, in order, as extracted from the X.509
79       *                    certificate.
80       * @param subjectAlts Subject-Alt fields of type 2 ("DNS"), as extracted
81       *                    from the X.509 certificate.
82       * @param host        The hostname to verify.
83       * @throws SSLException if the verification process fails.
84       */
85      void verify(String host, String[] cns, String[] subjectAlts)
86            throws SSLException;
87  
88  }