daniel-zahariev / php-aws-ses

PHP classes that interfaces Amazon Simple Email Service
307 stars 100 forks source link

Signature v4 problem, AWS: [Action Required] Migrate to Signature Version 4 to continue using Amazon SES #85

Open benjamin74 opened 3 years ago

benjamin74 commented 3 years ago

Hello,

I am a bit clueless : I keep receiving emails from AWS telling me that my php-aws-ses install is using version 3:

Your Signature Version 3 requests were identified to be originating from: - IAM Users: arn:aws:iam::XXXXXXXXXXX:user/YYYYYYYY-php - IPs: xxx.zzz.xxx.175 - User Agents: SimpleEmailService/php

I've updated my composer packages so I'm now using version 0.9.5 which, according to the documentation, is configured to use signature v4 by default.

Does anyone has any idea of what the issue could be ?

I'm using php-aws-ses in one of the most basic usage and it worked perfectly until now:

require_once 'vendor/autoload.php';
function emailing_sesmail($from, $to, $subject, $body){
        $m = new SimpleEmailServiceMessage();
        $m->addTo($to);
        $m->setFrom($from);
        $m->setSubject($subject);
        $m->setMessageFromString($body);
        // that's the key ID and secret of user php-aws-ses-script inside AWS IAM
        $ses = new SimpleEmailService('XXXXXXXXXXXXXXX', 'ZZZZZZZZZZZZZZZZZZZZZZZZ');
        return print_r($ses->sendEmail($m));
}

Thanks for any idea!

daniel-zahariev commented 3 years ago

Hi @benjamin74, here's a short-list of things to check:

aa6my commented 3 years ago

Hello,

I am a bit clueless : I keep receiving emails from AWS telling me that my php-aws-ses install is using version 3:

Your Signature Version 3 requests were identified to be originating from: - IAM Users: arn:aws:iam::XXXXXXXXXXX:user/YYYYYYYY-php - IPs: xxx.zzz.xxx.175 - User Agents: SimpleEmailService/php

I've updated my composer packages so I'm now using version 0.9.5 which, according to the documentation, is configured to use signature v4 by default.

Does anyone has any idea of what the issue could be ?

I'm using php-aws-ses in one of the most basic usage and it worked perfectly until now:

require_once 'vendor/autoload.php';
function emailing_sesmail($from, $to, $subject, $body){
        $m = new SimpleEmailServiceMessage();
        $m->addTo($to);
        $m->setFrom($from);
        $m->setSubject($subject);
        $m->setMessageFromString($body);
        // that's the key ID and secret of user php-aws-ses-script inside AWS IAM
        $ses = new SimpleEmailService('XXXXXXXXXXXXXXX', 'ZZZZZZZZZZZZZZZZZZZZZZZZ');
        return print_r($ses->sendEmail($m));
}

Thanks for any idea!

My suggestion for $ses

$region = SimpleEmailService::AWS_US_EAST_1; //its should be AWS_US_EAST_1 only, if you try to using diffrent region it will be failed
$version = SimpleEmailService::REQUEST_SIGNATURE_V4;
$debug = true;

$ses = new SimpleEmailService(
    $_ENV['AWS_ACCESS_KEY_ID'], 
    $_ENV['AWS_SECRET_ACCESS_KEY'], 
    $region,
    $debug,
    $version
);

$ses->setHost('ap-southeast-1'); //trick to switch region
return print_r($ses->sendEmail($m));
zippytiff commented 3 years ago

Hi

Newbie question

I have the error showing now:

Signature Version 3 requests are deprecated from March 1, 2021. From that date on, we are progressively rejecting such requests. To resolve the issue you must migrate to Signature Version 4. If you are self-signing your requests, refer to the documentation for Authenticating requests to the Amazon SES API [1] with Signature Version 4 [2]. If you are not self-signing your requests, simply update your SDK/CLI to the latest version. [1]

im using an inherited SES setup, using an access and secret key

Is this error saying i need to update them ? if so how ?

im running 0.9.3 of your code

Much appreciated

ZT

benjamin74 commented 3 years ago

Thanks @ daniel-zahariev for your suggestion, since I wasn't 100% sure whether or not the problem was solved I had to wait some days after restarting php-fpm to confirm that I'm not receiving such emails from amazon anymore.

So it looks like it was just an issue with my old PHP version being cached until php-fpm got restarted.

@ zippytiff I suspect updating to the latest version and making sure to restart php-fpm should solve your problem.