I keep getting signature errors using the AWS SDK for PHP, but it only happens I'm inserting encrypted data into SimpleDb. For example, if I comment out $userkey = "test", then I get errors, but if I leave it in, there are no errors.
<?php
require_once 'vendor/autoload.php';
use Aws\Common\Aws;
$client = Aws::factory('_loginconfig.php')->get('SimpleDb');
$domainName = "MY_USERS_001";
$uniqueid = uniqid();
$userkey = mcrypt_create_iv(16, MCRYPT_DEV_URANDOM);
//$userkey = "test";
$name = "Bob Smith";
try {
$client->putAttributes(array(
'DomainName' => $domainName,
'ItemName' => $uniqueid,
'Attributes' => array(
array('Name' => 'USER_KEY', 'Value' => $userkey, 'Replace' => true),
array('Name' => 'USER_REALNAME', 'Value' => $name, 'Replace' => true),
),
));
}
catch (Aws\SimpleDb\Exception\SimpleDbException $error) {
echo $error;
exit;
}
?>
I know nothing about encryption, hashes, signatures, so forgive me in advance for my ignorance on this.
After researching the issue, the solution I decided to use was to base64_encode($userkey) before I send the request.
I don't know why I am getting signature errors but this fixes the issue.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.