Amazon S3 SDK for java - configure TLSv1.2

I have a basic Amazon S3 SDK code snippet that is used to retrieve a list of buckets. The server is configured to only accept TLSv1.2. I cannot configure my client to send a TLS v1.2 request, debugging shows that the client always sends TLSv1. I tried to set the system property, but this also does not work.

-Dhttps.protocols = TLSv1.2

        BasicAWSCredentials credentials = new BasicAWSCredentials(username,password);

        AmazonS3 s3 = new AmazonS3Client(credentials);
        final String serviceurl = "https://ip:port";
        s3.setEndpoint(serviceurl);
        S3ClientOptions s3ClientOptions = new S3ClientOptions();
        s3ClientOptions.setPathStyleAccess(false);
        s3.setS3ClientOptions(s3ClientOptions);

        for (Bucket bucket: s3.listBuckets()) {
            System.out.println("Bucket name::" + bucket.getName());
        }

What am I missing here? How to configure code to send a TLSv1.2 request? I am using the AWS SDK 1.7.25. Thank you for your help.

+4
source share
2 answers

Version 1.9.4 of the Java SDK made TLSv1.2 the default .

1.9.14 (). .

, , . , , :

import org.apache.http.conn.ssl.SSLSocketFactory;
import com.amazonaws.ApacheHttpClientConfig;
import com.amazonaws.ClientConfiguration;

SSLContext ctx = SSLContext.getInstance("TLSv1.2");
SSLSocketFactory socketFactory = ctx.engineGetSocketFactory();

ClientConfiguration client = new ClientConfiguration();
ApacheHttpClientConfig apacheClient = client.getApacheHttpClientConfig();
SSLSocketFactory socketContext = apacheClient.getSslSocketFactory();
apacheClient.setSslSocketFactory(socketFactory);

:

+3

Amazon SDK System false

(SDKGlobalConfiguration.DISABLE_CERT_CHECKING_SYSTEM_PROPERTY, "false");

, com.amazonaws.sdk.disableCertChecking false.

, . , 3566773, , , .

, !!!

0

All Articles