org.apache.http.conn.ssl.SSLInitializationException Java Examples

The following examples show how to use org.apache.http.conn.ssl.SSLInitializationException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: snowflake-jdbc   Author: snowflakedb   File: SnowflakeS3Client.java    License: Apache License 2.0 6 votes vote down vote up
private static SSLConnectionSocketFactory getSSLConnectionSocketFactory()
{
  if (s3ConnectionSocketFactory == null)
  {
    synchronized (SnowflakeS3Client.class)
    {
      if (s3ConnectionSocketFactory == null)
      {
        try
        {
          // trust manager is set to null, which will use default ones
          // instead of SFTrustManager (which enables ocsp checking)
          s3ConnectionSocketFactory = new SFSSLConnectionSocketFactory(null,
                                                                       HttpUtil.isSocksProxyDisabled());
        }
        catch (KeyManagementException | NoSuchAlgorithmException e)
        {
          throw new SSLInitializationException(e.getMessage(), e);
        }
      }
    }
  }

  return s3ConnectionSocketFactory;
}
 
Example #2
Source Project: aws-sdk-java-v2   Author: aws   File: ApacheHttpClient.java    License: Apache License 2.0 5 votes vote down vote up
private SSLContext getSslContext(AttributeMap standardOptions) {
    Validate.isTrue(standardOptions.get(SdkHttpConfigurationOption.TLS_TRUST_MANAGERS_PROVIDER) == null ||
                    !standardOptions.get(SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES),
                    "A TlsTrustManagerProvider can't be provided if TrustAllCertificates is also set");

    TrustManager[] trustManagers = null;
    if (standardOptions.get(SdkHttpConfigurationOption.TLS_TRUST_MANAGERS_PROVIDER) != null) {
        trustManagers = standardOptions.get(SdkHttpConfigurationOption.TLS_TRUST_MANAGERS_PROVIDER).trustManagers();
    }

    if (standardOptions.get(SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES)) {
        log.warn(() -> "SSL Certificate verification is disabled. This is not a safe setting and should only be "
                       + "used for testing.");
        trustManagers = trustAllTrustManager();
    }

    TlsKeyManagersProvider provider = standardOptions.get(SdkHttpConfigurationOption.TLS_KEY_MANAGERS_PROVIDER);
    KeyManager[] keyManagers = provider.keyManagers();

    try {
        SSLContext sslcontext = SSLContext.getInstance("TLS");
        // http://download.java.net/jdk9/docs/technotes/guides/security/jsse/JSSERefGuide.html
        sslcontext.init(keyManagers, trustManagers, null);
        return sslcontext;
    } catch (final NoSuchAlgorithmException | KeyManagementException ex) {
        throw new SSLInitializationException(ex.getMessage(), ex);
    }
}