public final class SslUtils extends Object
Modifier and Type | Method and Description |
---|---|
static KeyManagerFactory |
getDefaultKeyManagerFactory()
Returns the default key manager factory.
|
static TrustManagerFactory |
getDefaultTrustManagerFactory()
Returns the default trust manager factory.
|
static KeyManagerFactory |
getPkixKeyManagerFactory()
Returns the PKIX key manager factory.
|
static TrustManagerFactory |
getPkixTrustManagerFactory()
Returns the PKIX trust manager factory.
|
static SSLContext |
getSslContext()
Returns the SSL context for "SSL" algorithm.
|
static SSLContext |
getTlsSslContext()
Returns the SSL context for "TLS" algorithm.
|
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.
|
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. |
static HostnameVerifier |
trustAllHostnameVerifier()
Beta Returns a verifier that trusts all host names. |
static SSLContext |
trustAllSSLContext()
Beta Returns an SSL context in which all X.509 certificates are trusted. |
public static SSLContext getSslContext() throws NoSuchAlgorithmException
NoSuchAlgorithmException
public static SSLContext getTlsSslContext() throws NoSuchAlgorithmException
NoSuchAlgorithmException
public static TrustManagerFactory getDefaultTrustManagerFactory() throws NoSuchAlgorithmException
NoSuchAlgorithmException
public static TrustManagerFactory getPkixTrustManagerFactory() throws NoSuchAlgorithmException
NoSuchAlgorithmException
public static KeyManagerFactory getDefaultKeyManagerFactory() throws NoSuchAlgorithmException
NoSuchAlgorithmException
public static KeyManagerFactory getPkixKeyManagerFactory() throws NoSuchAlgorithmException
NoSuchAlgorithmException
@CanIgnoreReturnValue public static SSLContext initSslContext(SSLContext sslContext, KeyStore trustStore, TrustManagerFactory trustManagerFactory) throws GeneralSecurityException
sslContext
- SSL context (for example SSLContext.getInstance(java.lang.String)
)trustStore
- key store for certificates to trust (for example SecurityUtils.getJavaKeyStore()
)trustManagerFactory
- trust manager factory (for example getPkixTrustManagerFactory()
)GeneralSecurityException
@Beta public static SSLContext initSslContext(SSLContext sslContext, KeyStore trustStore, TrustManagerFactory trustManagerFactory, KeyStore mtlsKeyStore, String mtlsKeyStorePassword, KeyManagerFactory keyManagerFactory) throws GeneralSecurityException
Beta
sslContext
- SSL context (for example SSLContext.getInstance(java.lang.String)
)trustStore
- key store for certificates to trust (for example SecurityUtils.getJavaKeyStore()
)trustManagerFactory
- trust manager factory (for example getPkixTrustManagerFactory()
)mtlsKeyStore
- key store for client certificate and key to establish mutual TLSmtlsKeyStorePassword
- password for mtlsKeyStore parameterkeyManagerFactory
- key manager factory (for example getDefaultKeyManagerFactory()
)GeneralSecurityException
@Beta public static SSLContext trustAllSSLContext() throws GeneralSecurityException
Beta
Be careful! Disabling SSL certificate validation is dangerous and should only be done in testing environments.
GeneralSecurityException
@Beta public static HostnameVerifier trustAllHostnameVerifier()
Beta
Be careful! Disabling host name verification is dangerous and should only be done in testing environments.
Copyright © 2011–2022 Google. All rights reserved.