001/* 002 * ==================================================================== 003 * Licensed to the Apache Software Foundation (ASF) under one 004 * or more contributor license agreements. See the NOTICE file 005 * distributed with this work for additional information 006 * regarding copyright ownership. The ASF licenses this file 007 * to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance 009 * with the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, 014 * software distributed under the License is distributed on an 015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 016 * KIND, either express or implied. See the License for the 017 * specific language governing permissions and limitations 018 * under the License. 019 * ==================================================================== 020 * 021 * This software consists of voluntary contributions made by many 022 * individuals on behalf of the Apache Software Foundation. For more 023 * information on the Apache Software Foundation, please see 024 * <http://www.apache.org/>. 025 * 026 */ 027package org.apache.http.ssl; 028 029import java.security.cert.CertificateException; 030import java.security.cert.X509Certificate; 031 032/** 033 * A strategy to establish trustworthiness of certificates without consulting the trust manager 034 * configured in the actual SSL context. This interface can be used to override the standard 035 * JSSE certificate verification process. 036 * 037 * @since 4.4 038 */ 039public interface TrustStrategy { 040 041 /** 042 * Determines whether the certificate chain can be trusted without consulting the trust manager 043 * configured in the actual SSL context. This method can be used to override the standard JSSE 044 * certificate verification process. 045 * <p> 046 * Please note that, if this method returns {@code false}, the trust manager configured 047 * in the actual SSL context can still clear the certificate as trusted. 048 * 049 * @param chain the peer certificate chain 050 * @param authType the authentication type based on the client certificate 051 * @return {@code true} if the certificate can be trusted without verification by 052 * the trust manager, {@code false} otherwise. 053 * @throws CertificateException thrown if the certificate is not trusted or invalid. 054 */ 055 boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException; 056 057}