Class TrustManagerUtils

java.lang.Object
org.apache.commons.net.util.TrustManagerUtils

public final class TrustManagerUtils extends Object
TrustManager utilities for generating TrustManagers.
Since:
3.0
  • Field Details

    • EMPTY_X509CERTIFICATE_ARRAY

      private static final X509Certificate[] EMPTY_X509CERTIFICATE_ARRAY
    • ACCEPT_ALL

      private static final X509TrustManager ACCEPT_ALL
    • CHECK_SERVER_VALIDITY

      private static final X509TrustManager CHECK_SERVER_VALIDITY
  • Constructor Details

    • TrustManagerUtils

      public TrustManagerUtils()
  • Method Details

    • getAcceptAllTrustManager

      public static X509TrustManager getAcceptAllTrustManager()
      Generate a TrustManager that performs no checks.
      Returns:
      the TrustManager
    • getValidateServerCertificateTrustManager

      public static X509TrustManager getValidateServerCertificateTrustManager()
      Generate a TrustManager that checks server certificates for validity, but otherwise performs no checks.
      Returns:
      the validating TrustManager
    • getDefaultTrustManager

      public static X509TrustManager getDefaultTrustManager(KeyStore keyStore) throws GeneralSecurityException
      Return the default TrustManager provided by the JVM.

      This should be the same as the default used by SSLContext#init(KeyManager[], TrustManager[], SecureRandom) when the TrustManager parameter is set to null

      Parameters:
      keyStore - the KeyStore to use, may be null
      Returns:
      the default TrustManager
      Throws:
      GeneralSecurityException - if an error occurs