When running > aws s3 ls s3://bucket_name/prefix/ --no-sign-request from the command line I have no problem listing out the contents of a public bucket. Note that my company's web traffic is routed via a proxy.
When I try connecting with the following java code I get 403 forbidden errors:
Region region = Region.EU_CENTRAL_1;
ProxyConfiguration config = ProxyConfiguration.builder().endpoint(
URI.create(proxyUrl)).username(serviceAccount).password(serviceAccountPw).build();
S3Client.builder()
.httpClient(ApacheHttpClient.builder().proxyConfiguration(config).build())
.region(region)
.build();
Do I need to do anything special to simulate the '--no-sign-request' flag? I have tried using an anonymous credentials provider, ie adding the following line to the above:
.credentialsProvider(AnonymousCredentialsProvider.create())
If I do this I see the following errors returned:
software.amazon.awssdk.services.s3.model.S3Exception: null (Service: S3, Status Code: 407, Request ID: null)
Exception in S3BucketServiceImpl null (Service: S3, Status Code: 407, Request ID: null)
o.a.h.i.a.HttpAuthenticator[0;39m: NEGOTIATE authentication error: Invalid name provided (Mechanism level: KrbException: Cannot locate default realm)
Why can I be getting 403 errors when trying to access a public bucket and how do I simulate the --no-sign-request flag in Java?
Thanks!