Package com.google.api.client.util
Class SslUtils
- java.lang.Object
-
- com.google.api.client.util.SslUtils
-
public final class SslUtils extends Object
SSL utilities.- Since:
- 1.13
- Author:
- Yaniv Inbar
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method 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()
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.
-
-
-
Method Detail
-
getSslContext
public static SSLContext getSslContext() throws NoSuchAlgorithmException
Returns the SSL context for "SSL" algorithm.- Throws:
NoSuchAlgorithmException
- Since:
- 1.14
-
getTlsSslContext
public static SSLContext getTlsSslContext() throws NoSuchAlgorithmException
Returns the SSL context for "TLS" algorithm.- Throws:
NoSuchAlgorithmException
- Since:
- 1.14
-
getDefaultTrustManagerFactory
public static TrustManagerFactory getDefaultTrustManagerFactory() throws NoSuchAlgorithmException
Returns the default trust manager factory.- Throws:
NoSuchAlgorithmException
- Since:
- 1.14
-
getPkixTrustManagerFactory
public static TrustManagerFactory getPkixTrustManagerFactory() throws NoSuchAlgorithmException
Returns the PKIX trust manager factory.- Throws:
NoSuchAlgorithmException
- Since:
- 1.14
-
getDefaultKeyManagerFactory
public static KeyManagerFactory getDefaultKeyManagerFactory() throws NoSuchAlgorithmException
Returns the default key manager factory.- Throws:
NoSuchAlgorithmException
- Since:
- 1.14
-
getPkixKeyManagerFactory
public static KeyManagerFactory getPkixKeyManagerFactory() throws NoSuchAlgorithmException
Returns the PKIX key manager factory.- Throws:
NoSuchAlgorithmException
- Since:
- 1.14
-
initSslContext
public static SSLContext initSslContext(SSLContext sslContext, KeyStore trustStore, TrustManagerFactory trustManagerFactory) throws GeneralSecurityException
Initializes the SSL context to the trust managers supplied by the trust manager factory for the given trust store.- Parameters:
sslContext
- SSL context (for exampleSSLContext.getInstance(java.lang.String)
)trustStore
- key store for certificates to trust (for exampleSecurityUtils.getJavaKeyStore()
)trustManagerFactory
- trust manager factory (for examplegetPkixTrustManagerFactory()
)- Throws:
GeneralSecurityException
- Since:
- 1.14
-
trustAllSSLContext
@Beta public static SSLContext trustAllSSLContext() throws GeneralSecurityException
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.
- Throws:
GeneralSecurityException
-
trustAllHostnameVerifier
@Beta 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.
-
-