我一直使用AWS SDK V3 for PHP將對象放到使用客戶提供的密鑰的服務器端加密的S3上。文檔很粗略(或者至少我沒有找到它)。CreateSignedURL失敗使用PHP的AWS SSE-C
對於使用S3client上傳的對象,我用putobject與
$params['SSECustomerAlgorithm'] = 'AES256';
$params['SSECustomerKey'] = $this->encryptioncustkey;
$params['SSECustomerKeyMD5'] = $this->encryptioncustkeymd5;
的$這個 - > encryptioncustkey是一個普通的用戶密碼(不Base64編碼的,因爲SDK似乎是這樣做的)和這個 - > encryptioncustkeymd5 = md5($ this-> encryptioncustkey,true);
put對象正常工作。但是,問題在於生成createSignedURL。
$cmd = $client->getCommand('GetObject', array(
'Bucket' => $bucket,
'Key' => $storedPath,
'ResponseContentDisposition' => 'attachment;charset=utf-8;filename="'.utf8_encode($fileName).'"',
'ResponseContentType' => $ctype,
'SSECustomerAlgorithm' => 'AES256',
'SSECustomerKey' => $this->encryptioncustkey,
'SSECustomerKeyMD5' => $this->encryptioncustkey64md5
));
但我得到其中根據文檔不需要SSE-C怪異響應表明它缺少「X-AMZ-服務器端加密」(ServerSideEncryption)。即使我將它設置爲ServerSideEncryption ='AES256',它也不起作用。
<Error>
<Code>InvalidArgument</Code>
<Message>
Requests specifying Server Side Encryption with Customer provided keys must provide an appropriate secret key.
</Message>
<ArgumentName>x-amz-server-side-encryption</ArgumentName>
<ArgumentValue>null</ArgumentValue>
<RequestId>A3368F6CE5DD310D</RequestId>
<HostId>
nHavXXz/gFOoJT0tnh+wgFTbTgGdpggRkyb0sDh07H7SomcX7HrcKU1dDzgZimrQwyaVQEqAjdk=
</HostId>
</Error>