Skip to content

Instantly share code, notes, and snippets.

@tw-Frey
Last active November 8, 2021 01:32
Show Gist options
  • Select an option

  • Save tw-Frey/a0df4c81d448100826b6fcae6feeba8b to your computer and use it in GitHub Desktop.

Select an option

Save tw-Frey/a0df4c81d448100826b6fcae6feeba8b to your computer and use it in GitHub Desktop.
Synopsis of TrustManagerFactory

TrustManagerFactory

  • Name
    TrustManagerFactory

  • Synopsis
    A TrustManagerFactory is responsible for creating TrustManager objects for a specific trust management algorithm. Obtain a TrustManagerFactory object by calling one of the getInstance( ) methods and specifying the desired algorithm and, optionally, the desired provider. In Java 1.4, the “SunX509” algorithm is the only one supported by the default “SunJSSE” provider. After calling getInstance( ), you initialize the factory object with init( ). For the “SunX509” algorithm, you pass a KeyStore object to init( ). This KeyStore should contain the public keys of trusted CAs (certification authorities). Once a TrustManagerFactory has been created and initialized, use it to create a TrustManager by calling getTrustManagers( ). This method returns an array of TrustManager objects because some trust management algorithms may handle more than one type of key or certificate. The “SunX509” algorithm manages only X.509 keys, and always returns an array with an X509TrustManager object as its single element. This returned array is typically passed to the init( ) method of an SSLContext object.

    If no KeyStore is passed to the init( ) method of the TrustManagerFactory for the “SunX509” algorithm, then the factory uses a KeyStore created from the file named by the system property javax.net.ssl.trustStore if that property is defined. (It also uses the key store type and password specified by the properties javax.net.ssl.trustStoreType and javax.net.ssl.trustStorePassword ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment