Class SslUtils (1.43.2)

public final class SslUtils

SSL utilities.

Inheritance

java.lang.Object > SslUtils

Static Methods

getDefaultKeyManagerFactory()

public static KeyManagerFactory getDefaultKeyManagerFactory()

Returns the default key manager factory.

Returns
Type Description
KeyManagerFactory
Exceptions
Type Description
NoSuchAlgorithmException

getDefaultTrustManagerFactory()

public static TrustManagerFactory getDefaultTrustManagerFactory()

Returns the default trust manager factory.

Returns
Type Description
TrustManagerFactory
Exceptions
Type Description
NoSuchAlgorithmException

getPkixKeyManagerFactory()

public static KeyManagerFactory getPkixKeyManagerFactory()

Returns the PKIX key manager factory.

Returns
Type Description
KeyManagerFactory
Exceptions
Type Description
NoSuchAlgorithmException

getPkixTrustManagerFactory()

public static TrustManagerFactory getPkixTrustManagerFactory()

Returns the PKIX trust manager factory.

Returns
Type Description
TrustManagerFactory
Exceptions
Type Description
NoSuchAlgorithmException

getSslContext()

public static SSLContext getSslContext()

Returns the SSL context for "SSL" algorithm.

Returns
Type Description
SSLContext
Exceptions
Type Description
NoSuchAlgorithmException

getTlsSslContext()

public static SSLContext getTlsSslContext()

Returns the SSL context for "TLS" algorithm.

Returns
Type Description
SSLContext
Exceptions
Type Description
NoSuchAlgorithmException

initSslContext(SSLContext sslContext, KeyStore trustStore, TrustManagerFactory trustManagerFactory)

public static SSLContext initSslContext(SSLContext sslContext, KeyStore trustStore, TrustManagerFactory trustManagerFactory)

Initializes the SSL context to the trust managers supplied by the trust manager factory for the given trust store.

Parameters
Name Description
sslContext SSLContext

SSL context (for example SSLContext#getInstance)

trustStore KeyStore

key store for certificates to trust (for example SecurityUtils#getJavaKeyStore())

trustManagerFactory TrustManagerFactory

trust manager factory (for example #getPkixTrustManagerFactory())

Returns
Type Description
SSLContext
Exceptions
Type Description
GeneralSecurityException

initSslContext(SSLContext sslContext, KeyStore trustStore, TrustManagerFactory trustManagerFactory, KeyStore mtlsKeyStore, String mtlsKeyStorePassword, KeyManagerFactory keyManagerFactory)

public static SSLContext initSslContext(SSLContext sslContext, KeyStore trustStore, TrustManagerFactory trustManagerFactory, KeyStore mtlsKeyStore, String mtlsKeyStorePassword, KeyManagerFactory keyManagerFactory)

Beta
Initializes the SSL context to the trust managers supplied by the trust manager factory for the given trust store, and to the key managers supplied by the key manager factory for the given key store.

Parameters
Name Description
sslContext SSLContext

SSL context (for example SSLContext#getInstance)

trustStore KeyStore

key store for certificates to trust (for example SecurityUtils#getJavaKeyStore())

trustManagerFactory TrustManagerFactory

trust manager factory (for example #getPkixTrustManagerFactory())

mtlsKeyStore KeyStore

key store for client certificate and key to establish mutual TLS

mtlsKeyStorePassword String

password for mtlsKeyStore parameter

keyManagerFactory KeyManagerFactory

key manager factory (for example #getDefaultKeyManagerFactory())

Returns
Type Description
SSLContext
Exceptions
Type Description
GeneralSecurityException

trustAllHostnameVerifier()

public static HostnameVerifier trustAllHostnameVerifier()

Beta
Returns a verifier that trusts all host names.

Be careful! Disabling host name verification is dangerous and should only be done in testing environments.

Returns
Type Description
HostnameVerifier

trustAllSSLContext()

public static SSLContext trustAllSSLContext()

Beta
Returns an SSL context in which all X.509 certificates are trusted.

Be careful! Disabling SSL certificate validation is dangerous and should only be done in testing environments.

Returns
Type Description
SSLContext
Exceptions
Type Description
GeneralSecurityException