aws-sdk-java icon indicating copy to clipboard operation
aws-sdk-java copied to clipboard

Can no longer use disableCertChecking property with AmazonS3Client

Open cgrimm01 opened this issue 13 years ago • 4 comments

In version 1.4.1, there is a problem that makes the property "com.amazonaws.sdk.disableCertChecking" used in the HttpClientFactory::createHttpClient() method to not persist through execution.

I have debugged through the code and the problem is in AmazonS3Client constructor. There was an "init()" function added. This init function calls client.disableStrictHostnameVerification() that reconstructs the https scheme and thus removing the https scheme established by the disableCertChecking property being set.

cgrimm01 avatar Mar 22 '13 16:03 cgrimm01

For context, these lines of code in HttpClientFactory::createHttpClient() is what was supposed to enable usage of self-signed certificates:

    /*
     * If SSL cert checking for endpoints has been explicitly disabled,
     * register a new scheme for HTTPS that won't cause self-signed certs to
     * error out.
     */
    if (System.getProperty("com.amazonaws.sdk.disableCertChecking") != null) {
        Scheme sch = new Scheme("https", 443, new TrustingSocketFactory());
        httpClient.getConnectionManager().getSchemeRegistry().register(sch);
    }

And the following routine in AmazonHttpClient.java removes it:

public void disableStrictHostnameVerification() {
    try {
        SchemeRegistry schemeRegistry = httpClient.getConnectionManager().getSchemeRegistry();

        SSLSocketFactory sf = new SSLSocketFactory(
                SSLContext.getDefault(),
                SSLSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
        Scheme https = new Scheme("https", 443, sf);

        schemeRegistry.register(https);
    } catch (NoSuchAlgorithmException e) {
        throw new AmazonClientException("Unable to access default SSL context to disable strict hostname verification");
    }
}

cgrimm01 avatar Mar 27 '13 13:03 cgrimm01

Thanks for the heads up on this issue. This is definitely on our radar and we're working on a fix for a future release.

zachmu avatar Mar 27 '13 14:03 zachmu

This is the commit that caused this issue in version 1.4.0:

https://github.com/aws/aws-sdk-java/commit/70840d0854e672c828c91b37a94d46448e1f8979#src/main/java/com/amazonaws/services/s3/AmazonS3Client.java

cgrimm01 avatar Mar 27 '13 17:03 cgrimm01

Hi @xyyxyyx, We have fixed this issue in version 1.4.5. Let us know if you are having any more problems!

wmatveyenko avatar Jun 18 '13 19:06 wmatveyenko