aws-sdk-java
aws-sdk-java copied to clipboard
Unable to execute HTTP request: Unrecognized SSL message, plaintext connection
Upcoming End-of-Support
- [X] I acknowledge the upcoming end-of-support for AWS SDK for Java v1 was announced, and migration to AWS SDK for Java v2 is recommended.
Describe the bug
I'm trying to set a proxy for the S3Client with the following code:
ProxyConfiguration.Builder apacheProxyConfiguration = ProxyConfiguration.builder();
apacheProxyConfiguration.useSystemPropertyValues(true);
String host = HTTPS + proxyUrl;
apacheProxyConfiguration.endpoint(URI.create(host + ":" + proxyPort));
S3Client.builder()
.region(Region.of(US_EAST_1))
.credentialsProvider(() -> basicCredentials)
.httpClient(ApacheHttpClient
.builder()
.proxyConfiguration(apacheProxyConfiguration
.build())
.build())
.build();
But when I try to execute a getObject using the proxy, I get the following error:
Unable to execute HTTP request: Unrecognized SSL message, plaintext connection
It looks like it's executing a HTTP request instead of a HTTPS request to the proxy so it gets rejected.
What could be the reason behind this problem?
Expected Behavior
Use the proxy with HTTPS protocol
Current Behavior
Reaching proxy with HTTP protocol
Reproduction Steps
Code:
ProxyConfiguration.Builder apacheProxyConfiguration = ProxyConfiguration.builder();
apacheProxyConfiguration.useSystemPropertyValues(true);
String host = HTTPS + proxyUrl;
apacheProxyConfiguration.endpoint(URI.create(host + ":" + proxyPort));
S3Client.builder()
.region(Region.of(US_EAST_1))
.credentialsProvider(() -> basicCredentials)
.httpClient(ApacheHttpClient
.builder()
.proxyConfiguration(apacheProxyConfiguration
.build())
.build())
.build();
S3Client:
amazonS3.getObject(
GetObjectRequest.builder().bucket(bucket).key(key).build()
Possible Solution
No response
Additional Information/Context
No response
AWS Java SDK version used
2.25.47
JDK version used
8
Operating System and version
Mac
This issue is now closed.
Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.