Reputation: 3282
I'm trying to consume messages from SQS with the symfony 5 SQS consumer and i'm having an issue when the aws secret key contains special chars like +
or \
.
Here's my .env
file :
MESSENGER_TRANSPORT_DSN="https://sqs.eu-west-3.amazonaws.com/XXXXXXXX/bonobo-asg?access_key=XXXX&secret_key=XXXX+XXXXX\XXXXXX®ion=eu-west-3&auto_setup=false"
And my messenger.yml
config file :
framework:
messenger:
transports:
asg:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
serializer: App\Messenger\SnsSerializer
When i launch the consumer i get the following error :
[AsyncAws\Core\Exception\Http\ClientException (403)]
HTTP 403 returned for "https://sqs.eu-west-3.amazonaws.com/".
Code: SignatureDoesNotMatch
Message: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for de
tails.
I think it comes from the special chars in the secret key because when i try with another key containing only letters and numbers, it works fine.
I tried to escape the special chars with \
but it gives me the same error.
How can i use my key containing special chars with the symfony sqs consumer?
Upvotes: 0
Views: 967
Reputation: 203
I had the same issue, but found out that Symfony's DSN are parsed as normal URLs.
So if your URL parameters (in our case access_key
or secret_key
) contains some special characters, they need to be URL encoded.
I replaced +
by %2B
and /
by %2F
and it worked perfectly.
Reference: https://github.com/symfony/symfony/issues/32021
Upvotes: 2