Top Description Fields Constructors Methods
org.apache.hc.client5.http.ssl

public Class TrustSelfSignedStrategy

extends Object
implements TrustStrategy
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.ssl.TrustStrategy
Annotations
@Deprecated
@Contract
threading:STATELESS
Imports
java.security.cert.CertificateException, .X509Certificate, org.apache.hc.core5.annotation.Contract, .ThreadingBehavior, org.apache.hc.core5.ssl.TrustStrategy

Deprecated

For self-signed certificates prefer specifying a keystore containing the certificate when calling the org.apache.hc.core5.ssl.SSLContextBuilder loadTrustMaterial methods.

A trust strategy that accepts self-signed certificates as trusted. Verification of all other certificates is done by the trust manager configured in the SSL context.

Security Warning

This acts like TrustAllStrategy, with the only restriction that the certificate chain must have length 1. This means this trust strategy does not protect against man-in-the-middle attacks. See the TrustAllStrategy for more information and more secure alternatives.
Since
4.1

Field Summary

Modifier and TypeField and Description
public static final TrustSelfSignedStrategy
INSTANCE

Deprecated as a consequence of TrustSelfSignedStrategy being deprecated.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
isTrusted(final X509Certificate[]
the peer certificate chain
chain
,
final String
the authentication type based on the client certificate
authType
)

Implements org.apache.hc.core5.ssl.TrustStrategy.isTrusted.

Determines whether the certificate chain can be trusted without consulting the trust manager configured in the actual SSL context.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INSTANCEback to summary
public static final TrustSelfSignedStrategy INSTANCE

Deprecated

as a consequence of TrustSelfSignedStrategy being deprecated. See corresponding docs for further information.

Constructor Detail

TrustSelfSignedStrategyback to summary
public TrustSelfSignedStrategy()

Method Detail

isTrustedback to summary
public boolean isTrusted(final X509Certificate[] chain, final String authType) throws CertificateException

Implements org.apache.hc.core5.ssl.TrustStrategy.isTrusted.

Doc from org.apache.hc.core5.ssl.TrustStrategy.isTrusted.

Determines whether the certificate chain can be trusted without consulting the trust manager configured in the actual SSL context. This method can be used to override the standard JSSE certificate verification process.

Please note that, if this method returns false, the trust manager configured in the actual SSL context can still clear the certificate as trusted.

Parameters
chain:X509Certificate[]

the peer certificate chain

authType:String

the authentication type based on the client certificate

Returns:boolean

true if the certificate can be trusted without verification by the trust manager, false otherwise.

Annotations
@Override
Exceptions
CertificateException:
thrown if the certificate is not trusted or invalid.