Class SslUtils (1.41.8)

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
TypeDescription
KeyManagerFactory
Exceptions
TypeDescription
NoSuchAlgorithmException

getDefaultTrustManagerFactory()

public static TrustManagerFactory getDefaultTrustManagerFactory()

Returns the default trust manager factory.

Returns
TypeDescription
TrustManagerFactory
Exceptions
TypeDescription
NoSuchAlgorithmException

getPkixKeyManagerFactory()

public static KeyManagerFactory getPkixKeyManagerFactory()

Returns the PKIX key manager factory.

Returns
TypeDescription
KeyManagerFactory
Exceptions
TypeDescription
NoSuchAlgorithmException

getPkixTrustManagerFactory()

public static TrustManagerFactory getPkixTrustManagerFactory()

Returns the PKIX trust manager factory.

Returns
TypeDescription
TrustManagerFactory
Exceptions
TypeDescription
NoSuchAlgorithmException

getSslContext()

public static SSLContext getSslContext()

Returns the SSL context for "SSL" algorithm.

Returns
TypeDescription
SSLContext
Exceptions
TypeDescription
NoSuchAlgorithmException

getTlsSslContext()

public static SSLContext getTlsSslContext()

Returns the SSL context for "TLS" algorithm.

Returns
TypeDescription
SSLContext
Exceptions
TypeDescription
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
NameDescription
sslContextSSLContext

SSL context (for example SSLContext#getInstance)

trustStoreKeyStore

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

trustManagerFactoryTrustManagerFactory

trust manager factory (for example #getPkixTrustManagerFactory())

Returns
TypeDescription
SSLContext
Exceptions
TypeDescription
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
NameDescription
sslContextSSLContext

SSL context (for example SSLContext#getInstance)

trustStoreKeyStore

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

trustManagerFactoryTrustManagerFactory

trust manager factory (for example #getPkixTrustManagerFactory())

mtlsKeyStoreKeyStore

key store for client certificate and key to establish mutual TLS

mtlsKeyStorePasswordString

password for mtlsKeyStore parameter

keyManagerFactoryKeyManagerFactory

key manager factory (for example #getDefaultKeyManagerFactory())

Returns
TypeDescription
SSLContext
Exceptions
TypeDescription
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
TypeDescription
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
TypeDescription
SSLContext
Exceptions
TypeDescription
GeneralSecurityException