org.apache.hc.client5.http.ssl

## Class TrustAllStrategy

- java.lang.Object
- - org.apache.hc.client5.http.ssl.TrustAllStrategy

- All Implemented Interfaces:
    org.apache.hc.core5.ssl.TrustStrategy

      @Contract(threading=STATELESS)
      public class TrustAllStrategy
      extends Object
      implements org.apache.hc.core5.ssl.TrustStrategy

  A trust strategy that accepts all certificates as trusted.

  ## Security Warning

  This trust strategy effectively disables trust verification of SSL / TLS, and allows man-in-the-middle attacks. If possible avoid this trust strategy and use more secure alternatives. For example, for self-signed certificates prefer specifying a keystore containing the certificate chain when calling the `SSLContextBuilder` `loadTrustMaterial` methods.
  Since:
    4.5.4, 5.0

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static TrustAllStrategy` | `INSTANCE` Default instance of `TrustAllStrategy`.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TrustAllStrategy()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `isTrusted(X509Certificate[] chain, String authType)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### INSTANCE

          public static final TrustAllStrategy INSTANCE

      Default instance of `TrustAllStrategy`.

  - ### Constructor Detail

    - #### TrustAllStrategy

          public TrustAllStrategy()

  - ### Method Detail

    - #### isTrusted

          public boolean isTrusted(X509Certificate[] chain,
                                   String authType)
                            throws CertificateException

      Specified by:
        `isTrusted` in interface `org.apache.hc.core5.ssl.TrustStrategy`
      Throws:
        `CertificateException`

Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.