hello
i am trying to replicate one of the issue while downloading object from linode s3 storage using com.amazonaws.services.s3.AmazonS3
client
I am trying two scenarios
1: getting metadata of the blob
code to download metadata with an invalid encryption key
private static void downloadMetaDataFileWithInvalidEncryptionKey(AmazonS3 s3Client, String bucketName, String objectKey) throws Exception {
System.out.println("called downloadFile metadata----");
String base64EncodedKeyWrong = "ZjExMmJmMGZjZmQyMjAxZDNmMjU1MjRhNTNlY2E0OGM=";
SSECustomerKey sseKeyWrong = new SSECustomerKey(Base64.getDecoder().decode(base64EncodedKeyWrong));
GetObjectMetadataRequest getObjectMetadataRequest = new GetObjectMetadataRequest(bucketName, objectKey)
.withSSECustomerKey(sseKeyWrong);
ObjectMetadata in = s3Client.getObjectMetadata(getObjectMetadataRequest);
}
exception
com.amazonaws.services.s3.model.AmazonS3Exception: Bad Request (Service: Amazon S3; Status Code: 400; Error Code: 400 Bad Request; Request ID: tx000000874ead5c5f76c89-0067287617-845c4b44-default; S3 Extended Request ID: null; Proxy: null), S3 Extended Request ID: null
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1879)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleServiceErrorResponse(AmazonHttpClient.java:1418)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1387)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1157)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:814)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:781)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:755)
2: getting actual data of the blob
code to download file with an invalid encryption key
private static void downloadFileWithInvalidEncryptionKey(AmazonS3 s3Client, String bucketName, String objectKey) throws Exception {
System.out.println("called downloadFile file----");
String base64EncodedKeyWrong = "ZjExMmJmMGZjZmQyMjAxZDNmMjU1MjRhNTNlY2E0OGM=";
SSECustomerKey sseKeyWrong = new SSECustomerKey(Base64.getDecoder().decode(base64EncodedKeyWrong));
GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, objectKey)
.withSSECustomerKey(sseKeyWrong);
InputStream inputStream = s3Client.getObject(getObjectRequest).getObjectContent();
}
exception
com.amazonaws.services.s3.model.AmazonS3Exception: Requests specifying Server Side Encryption with Customer provided keys must provide an appropriate secret key. (Service: Amazon S3; Status Code: 400; Error Code: InvalidArgument; Request ID: tx00000b3594a0388b1f4aa-0067287617-83ea7113-default; S3 Extended Request ID: 83ea7113-default-default; Proxy: null), S3 Extended Request ID: 83ea7113-default-default
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1879)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleServiceErrorResponse(AmazonHttpClient.java:1418)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1387)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1157)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:814)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:781)
driver code
public static void main(String[] args) throws Exception {
String accessKey = "accesskeyoflinodebucket";
String secretKey = "secretKeyoflinodebucket";
String endpoint = "https://us-ord-1.linodeobjects.com";
String region = "us-ord-1";
String bucketName = "linode-bucket-name";
String objectKey = "ekart_table_08_test3-encrypt.csv";
BasicAWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey);
AmazonS3 s3Client = AmazonS3ClientBuilder.standard()
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, region))
.withCredentials(new AWSStaticCredentialsProvider(awsCredentials))
.build();
try {
downloadFileWithEncryptionKey(s3Client,bucketName,objectKey);
} catch (Exception e) {
System.out.println("failed downloadFileWithEncryptionKey");
e.printStackTrace();
}
try {
downloadMetaDataFileWithEncryptionKey(s3Client,bucketName,objectKey);
} catch (Exception e) {
System.out.println("failed downloadMetaDataFileWithEncryptionKey");
e.printStackTrace();
}
}
While both requests appear similar, the first exception's message is less specific. I'm curious if this first exception is accurate and informative or if there's a more detailed explanation for the 'Bad Request' error.
because you can see the second exception has more details about the reason of the failure.
i am asking here because i asked same question to linode team as well they said it might be s3 client issue .