I am attempting to upload an object to S3 using the customer provided encryption key. http://docs.aws.amazon.com/AmazonS3/latest/dev/ServerSideEncryptionCustomerKeys.html
My code looks like:
$this->s3->putObject(array(
'Bucket' => $this->bucket,
'Key' => "$filename",
'Body' => $resource,
'ACL' => 'private',
'SSECustomerAlgorithm' => 'AES256',
'SSECustomerKey' => base64_encode('48wk86271sDb23pY23zT5rZJ7q55R7eE'),
'SSECustomerKeyMD5'=> base64_encode(md5('48wk86271sDb23pY23zT5rZJ7q55R7eE'))
));
The error I am getting says:
AWS Error Message: The calculated MD5 hash of the key did not match the hash that was provided
What am I doing wrong? My key 48wk86271sDb23pY23zT5rZJ7q55R7eE is 256 bits. I've also tried using base64_encode(md5(key, true)).
SSECustomerKey => 'raw key string with 32 chars', SSECustomerKeyMD5 => md5(key,true). The "true" as I understand it returns the binary md5, not hex, which is probably what you need here, since docs mention 128 bits for the md5. - Michael - sqlbot