Skip to content

[Mailer / Amazon Mailer] Valid AWS secret key characters removed / throwing invalid DSN exception #36669

Closed
@nspyke

Description

@nspyke

Symfony version(s) affected: 4.4.8

Description
I am setting up the Symfony Amazon mailer component and passed my AWS key and AWS secret to the mailer DSN. My AWS secret contains a + character in it, eg A57+VZcaA (obviously not a real key). I noticed I was getting signature errors.
Adding a dump and echo to line 41 of Symfony\Component\Mailer\Bridge\Amazon\Transport\SesHttpTransport using the example secret above outputs the following;

https://pasteboard.co/J6ErpBL.png

As a workaround, I generated a new access key and secret, and this time it contains two / characters in it eg ...se/J1/0p, and am getting the exception;

 The "ses://xxxxx:xxxxse/J1/0p@default?region=us-west-2" mailer DSN is invalid

How to reproduce
Setup symfony/mailer with the Amazon SES mailer.
Generate a access key and secret that has a + or / character in it.
Add;

        echo($this->secretKey);
        dd($this->secretKey);

to line 41 of Symfony\Component\Mailer\Bridge\Amazon\Transport\SesHttpTransport

Additional context
I also tried to reference a service parameter instead of a .env variable and the plus character was also removed from that as well.
When I edited the SesHttpTransport class and changed the $secretKey variable to my actual key in the constructor, the email was sent successfully.

In an attempt to figure out where the cause is a dd($dsn) on line 96 of Symfony\Component\Mailer\Transport shows the full correct key being presented to the Transport classes.

A further dump on line 125 of the same class shows the secret with the + symbol removed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions