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 HostnameVerifier |
trustAllHostnameVerifier()
Returns a verifier that trusts all host names.
|
static SSLContext |
trustAllSSLContext()
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
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
public static SSLContext trustAllSSLContext() throws GeneralSecurityException
Be careful! Disabling SSL certificate validation is dangerous and should only be done in testing environments.
GeneralSecurityException
public static HostnameVerifier trustAllHostnameVerifier()
Be careful! Disabling host name verification is dangerous and should only be done in testing environments.
Copyright © 2011-2013 Google. All Rights Reserved.