# Class SslUtils (2.1.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [2.1.0 (latest)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.SslUtils)
- [2.0.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/2.0.3/com.google.api.client.util.SslUtils)
- [1.47.1](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.47.1/com.google.api.client.util.SslUtils)
- [1.46.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.46.3/com.google.api.client.util.SslUtils)
- [1.45.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.45.3/com.google.api.client.util.SslUtils)
- [1.44.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.44.2/com.google.api.client.util.SslUtils)
- [1.43.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.43.2/com.google.api.client.util.SslUtils)
- [1.42.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.42.3/com.google.api.client.util.SslUtils)
- [1.41.8](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.41.8/com.google.api.client.util.SslUtils)

    public final class SslUtils

SSL utilities.

## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> SslUtils

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Static Methods

### getDefaultKeyManagerFactory()

    public static KeyManagerFactory getDefaultKeyManagerFactory()

Returns the default key manager factory.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/KeyManagerFactory.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/security/NoSuchAlgorithmException.html` |   |

### getDefaultTrustManagerFactory()

    public static TrustManagerFactory getDefaultTrustManagerFactory()

Returns the default trust manager factory.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/TrustManagerFactory.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/security/NoSuchAlgorithmException.html` |   |

### getPkixKeyManagerFactory()

    public static KeyManagerFactory getPkixKeyManagerFactory()

Returns the PKIX key manager factory.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/KeyManagerFactory.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/security/NoSuchAlgorithmException.html` |   |

### getPkixTrustManagerFactory()

    public static TrustManagerFactory getPkixTrustManagerFactory()

Returns the PKIX trust manager factory.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/TrustManagerFactory.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/security/NoSuchAlgorithmException.html` |   |

### getSslContext()

    public static SSLContext getSslContext()

Returns the SSL context for "SSL" algorithm.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/SSLContext.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/security/NoSuchAlgorithmException.html` |   |

### getTlsSslContext()

    public static SSLContext getTlsSslContext()

Returns the SSL context for "TLS" algorithm.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/SSLContext.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/security/NoSuchAlgorithmException.html` |   |

### 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` | `https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/SSLContext.html` SSL context (for example SSLContext#getInstance) |
| `trustStore` | `https://docs.oracle.com/javase/8/docs/api/java/security/KeyStore.html` key store for certificates to trust (for example [SecurityUtils#getJavaKeyStore()](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.SecurityUtils#com_google_api_client_util_SecurityUtils_getJavaKeyStore__)) |
| `trustManagerFactory` | `https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/TrustManagerFactory.html` trust manager factory (for example [#getPkixTrustManagerFactory()](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.SslUtils#com_google_api_client_util_SslUtils_getPkixTrustManagerFactory__)) |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/SSLContext.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/security/GeneralSecurityException.html` |   |

### 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](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.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` | `https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/SSLContext.html` SSL context (for example SSLContext#getInstance) |
| `trustStore` | `https://docs.oracle.com/javase/8/docs/api/java/security/KeyStore.html` key store for certificates to trust (for example [SecurityUtils#getJavaKeyStore()](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.SecurityUtils#com_google_api_client_util_SecurityUtils_getJavaKeyStore__)) |
| `trustManagerFactory` | `https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/TrustManagerFactory.html` trust manager factory (for example [#getPkixTrustManagerFactory()](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.SslUtils#com_google_api_client_util_SslUtils_getPkixTrustManagerFactory__)) |
| `mtlsKeyStore` | `https://docs.oracle.com/javase/8/docs/api/java/security/KeyStore.html` key store for client certificate and key to establish mutual TLS |
| `mtlsKeyStorePassword` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` password for mtlsKeyStore parameter |
| `keyManagerFactory` | `https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/KeyManagerFactory.html` key manager factory (for example [#getDefaultKeyManagerFactory()](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.SslUtils#com_google_api_client_util_SslUtils_getDefaultKeyManagerFactory__)) |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/SSLContext.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/security/GeneralSecurityException.html` |   |

### trustAllHostnameVerifier()

    public static HostnameVerifier trustAllHostnameVerifier()

[Beta](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.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** |
| `https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/HostnameVerifier.html` |   |

### trustAllSSLContext()

    public static SSLContext trustAllSSLContext()

[Beta](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.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** |
| `https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/SSLContext.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/security/GeneralSecurityException.html` |   |