151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski/* 251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * This code is free software; you can redistribute it and/or modify it 651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * under the terms of the GNU General Public License version 2 only, as 751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * published by the Free Software Foundation. Oracle designates this 851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * particular file as subject to the "Classpath" exception as provided 951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * by Oracle in the LICENSE file that accompanied this code. 1051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 1151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * This code is distributed in the hope that it will be useful, but WITHOUT 1251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * version 2 for more details (a copy is included in the LICENSE file that 1551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * accompanied this code). 1651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 1751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * You should have received a copy of the GNU General Public License version 1851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 2 along with this work; if not, write to the Free Software Foundation, 1951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 2151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * or visit www.oracle.com if you need additional information or have any 2351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * questions. 2451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 2551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 2651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskipackage javax.net.ssl; 2751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 2851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskiimport java.net.Socket; 2951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskiimport javax.net.ssl.X509TrustManager; 3051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 3151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskiimport java.security.cert.X509Certificate; 3251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskiimport java.security.cert.CertificateException; 3351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 3451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski/** 3551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Extensions to the <code>X509TrustManager</code> interface to support 3651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * SSL/TLS connection sensitive trust management. 3751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 3851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * To prevent man-in-the-middle attacks, hostname checks can be done 3951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * to verify that the hostname in an end-entity certificate matches the 4051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * targeted hostname. TLS does not require such checks, but some protocols 4151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * over TLS (such as HTTPS) do. In earlier versions of the JDK, the 4251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * certificate chain checks were done at the SSL/TLS layer, and the hostname 4351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * verification checks were done at the layer over TLS. This class allows 4451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * for the checking to be done during a single call to this class. 4551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 4651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * RFC 2830 defines the server identification specification for the "LDAPS" 4751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * algorithm. RFC 2818 defines both the server identification and the 4851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * client identification specification for the "HTTPS" algorithm. 4951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 5051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see X509TrustManager 5151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see HostnameVerifier 5251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 5351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.7 5451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 5551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskipublic abstract class X509ExtendedTrustManager implements X509TrustManager { 5651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 5751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Given the partial or complete certificate chain provided by the 5851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * peer, build and validate the certificate path based on the 5951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * authentication type and ssl parameters. 6051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 6151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * The authentication type is determined by the actual certificate 6251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * used. For instance, if RSAPublicKey is used, the authType 6351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * should be "RSA". Checking is case-sensitive. 6451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 6551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * If the <code>socket</code> parameter is an instance of 6651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * {@link javax.net.ssl.SSLSocket}, and the endpoint identification 6751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * algorithm of the <code>SSLParameters</code> is non-empty, to prevent 6851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * man-in-the-middle attacks, the address that the <code>socket</code> 6951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * connected to should be checked against the peer's identity presented 7051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * in the end-entity X509 certificate, as specified in the endpoint 7151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * identification algorithm. 7251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 7351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * If the <code>socket</code> parameter is an instance of 7451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * {@link javax.net.ssl.SSLSocket}, and the algorithm constraints of the 7551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>SSLParameters</code> is non-null, for every certificate in the 7651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * certification path, fields such as subject public key, the signature 7751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * algorithm, key usage, extended key usage, etc. need to conform to the 7851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * algorithm constraints in place on this socket. 7951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 8051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param chain the peer certificate chain 8151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param authType the key exchange algorithm used 8251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param socket the socket used for this connection. This parameter 8351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * can be null, which indicates that implementations need not check 8451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the ssl parameters 8551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws IllegalArgumentException if null or zero-length array is passed 8651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * in for the <code>chain</code> parameter or if null or zero-length 8751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * string is passed in for the <code>authType</code> parameter 8851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws CertificateException if the certificate chain is not trusted 8951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * by this TrustManager 9051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 9151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see SSLParameters#getEndpointIdentificationAlgorithm 9251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see SSLParameters#setEndpointIdentificationAlgorithm(String) 9351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see SSLParameters#getAlgorithmConstraints 9451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see SSLParameters#setAlgorithmConstraints(AlgorithmConstraints) 9551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 9651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski public abstract void checkClientTrusted(X509Certificate[] chain, 9751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski String authType, Socket socket) throws CertificateException; 9851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 9951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 10051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Given the partial or complete certificate chain provided by the 10151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * peer, build and validate the certificate path based on the 10251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * authentication type and ssl parameters. 10351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 10451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * The authentication type is the key exchange algorithm portion 10551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * of the cipher suites represented as a String, such as "RSA", 10651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * "DHE_DSS". Note: for some exportable cipher suites, the key 10751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * exchange algorithm is determined at run time during the 10851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * handshake. For instance, for TLS_RSA_EXPORT_WITH_RC4_40_MD5, 10951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the authType should be RSA_EXPORT when an ephemeral RSA key is 11051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * used for the key exchange, and RSA when the key from the server 11151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * certificate is used. Checking is case-sensitive. 11251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 11351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * If the <code>socket</code> parameter is an instance of 11451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * {@link javax.net.ssl.SSLSocket}, and the endpoint identification 11551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * algorithm of the <code>SSLParameters</code> is non-empty, to prevent 11651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * man-in-the-middle attacks, the address that the <code>socket</code> 11751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * connected to should be checked against the peer's identity presented 11851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * in the end-entity X509 certificate, as specified in the endpoint 11951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * identification algorithm. 12051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 12151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * If the <code>socket</code> parameter is an instance of 12251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * {@link javax.net.ssl.SSLSocket}, and the algorithm constraints of the 12351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>SSLParameters</code> is non-null, for every certificate in the 12451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * certification path, fields such as subject public key, the signature 12551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * algorithm, key usage, extended key usage, etc. need to conform to the 12651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * algorithm constraints in place on this socket. 12751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 12851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param chain the peer certificate chain 12951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param authType the key exchange algorithm used 13051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param socket the socket used for this connection. This parameter 13151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * can be null, which indicates that implementations need not check 13251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the ssl parameters 13351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws IllegalArgumentException if null or zero-length array is passed 13451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * in for the <code>chain</code> parameter or if null or zero-length 13551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * string is passed in for the <code>authType</code> parameter 13651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws CertificateException if the certificate chain is not trusted 13751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * by this TrustManager 13851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 13951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see SSLParameters#getEndpointIdentificationAlgorithm 14051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see SSLParameters#setEndpointIdentificationAlgorithm(String) 14151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see SSLParameters#getAlgorithmConstraints 14251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see SSLParameters#setAlgorithmConstraints(AlgorithmConstraints) 14351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 14451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski public abstract void checkServerTrusted(X509Certificate[] chain, 14551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski String authType, Socket socket) throws CertificateException; 14651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 14751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 14851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Given the partial or complete certificate chain provided by the 14951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * peer, build and validate the certificate path based on the 15051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * authentication type and ssl parameters. 15151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 15251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * The authentication type is determined by the actual certificate 15351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * used. For instance, if RSAPublicKey is used, the authType 15451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * should be "RSA". Checking is case-sensitive. 15551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 15651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * If the <code>engine</code> parameter is available, and the endpoint 15751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * identification algorithm of the <code>SSLParameters</code> is 15851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * non-empty, to prevent man-in-the-middle attacks, the address that 15951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the <code>engine</code> connected to should be checked against 16051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the peer's identity presented in the end-entity X509 certificate, 16151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * as specified in the endpoint identification algorithm. 16251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 16351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * If the <code>engine</code> parameter is available, and the algorithm 16451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * constraints of the <code>SSLParameters</code> is non-null, for every 16551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * certificate in the certification path, fields such as subject public 16651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * key, the signature algorithm, key usage, extended key usage, etc. 16751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * need to conform to the algorithm constraints in place on this engine. 16851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 16951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param chain the peer certificate chain 17051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param authType the key exchange algorithm used 17151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param engine the engine used for this connection. This parameter 17251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * can be null, which indicates that implementations need not check 17351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the ssl parameters 17451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws IllegalArgumentException if null or zero-length array is passed 17551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * in for the <code>chain</code> parameter or if null or zero-length 17651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * string is passed in for the <code>authType</code> parameter 17751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws CertificateException if the certificate chain is not trusted 17851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * by this TrustManager 17951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 18051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see SSLParameters#getEndpointIdentificationAlgorithm 18151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see SSLParameters#setEndpointIdentificationAlgorithm(String) 18251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see SSLParameters#getAlgorithmConstraints 18351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see SSLParameters#setAlgorithmConstraints(AlgorithmConstraints) 18451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 18551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski public abstract void checkClientTrusted(X509Certificate[] chain, 18651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski String authType, SSLEngine engine) throws CertificateException; 18751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 18851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 18951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Given the partial or complete certificate chain provided by the 19051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * peer, build and validate the certificate path based on the 19151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * authentication type and ssl parameters. 19251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 19351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * The authentication type is the key exchange algorithm portion 19451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * of the cipher suites represented as a String, such as "RSA", 19551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * "DHE_DSS". Note: for some exportable cipher suites, the key 19651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * exchange algorithm is determined at run time during the 19751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * handshake. For instance, for TLS_RSA_EXPORT_WITH_RC4_40_MD5, 19851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the authType should be RSA_EXPORT when an ephemeral RSA key is 19951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * used for the key exchange, and RSA when the key from the server 20051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * certificate is used. Checking is case-sensitive. 20151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 20251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * If the <code>engine</code> parameter is available, and the endpoint 20351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * identification algorithm of the <code>SSLParameters</code> is 20451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * non-empty, to prevent man-in-the-middle attacks, the address that 20551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the <code>engine</code> connected to should be checked against 20651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the peer's identity presented in the end-entity X509 certificate, 20751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * as specified in the endpoint identification algorithm. 20851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 20951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * If the <code>engine</code> parameter is available, and the algorithm 21051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * constraints of the <code>SSLParameters</code> is non-null, for every 21151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * certificate in the certification path, fields such as subject public 21251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * key, the signature algorithm, key usage, extended key usage, etc. 21351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * need to conform to the algorithm constraints in place on this engine. 21451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 21551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param chain the peer certificate chain 21651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param authType the key exchange algorithm used 21751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param engine the engine used for this connection. This parameter 21851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * can be null, which indicates that implementations need not check 21951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the ssl parameters 22051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws IllegalArgumentException if null or zero-length array is passed 22151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * in for the <code>chain</code> parameter or if null or zero-length 22251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * string is passed in for the <code>authType</code> parameter 22351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws CertificateException if the certificate chain is not trusted 22451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * by this TrustManager 22551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 22651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see SSLParameters#getEndpointIdentificationAlgorithm 22751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see SSLParameters#setEndpointIdentificationAlgorithm(String) 22851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see SSLParameters#getAlgorithmConstraints 22951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see SSLParameters#setAlgorithmConstraints(AlgorithmConstraints) 23051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 23151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski public abstract void checkServerTrusted(X509Certificate[] chain, 23251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski String authType, SSLEngine engine) throws CertificateException; 23351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 23451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski} 235