Error when running test-invoke-authorizer: tokenSignature

0

I am attempting to create a custom authorizer for IoT and am following this guide:
https://aws.amazon.com/blogs/security/how-to-use-your-own-identity-and-access-management-systems-to-control-access-to-aws-iot-resources/

When I attempt to test my authorizer with this command:
aws iot test-invoke-authorizer --authorizer-name <authorizer_name> --token allow --token-signature <token_signature>

I get the response:
An error occurred (InvalidRequestException) when calling the TestInvokeAuthorizer operation: 1 validation error detected: Value '<signature here>' at 'tokenSignature' failed to satisfy constraint: Member must satisfy regular expression pattern: [A-Za-z0-9_/]_={0,2}

I am testing it in Centos, and have created a bash script like this:
#!/bin/bash
sig=cat token.sign.b64
aws iot test-invoke-authorizer --authorizer-name MyAuthorizer --token allow --token-signature "$sig"

The token.sign.b64 is created as per the instructions in the guide.

How do I get it to authorize correctly?

tobyjo
질문됨 5년 전489회 조회
1개 답변
0

I found the answer myself.

Running
od -c token.sign.b64
to view the actual byte contents of the file showed that it had \n chars in it which would have been generating the error.

So instead of just running base64 on the file I ran this to ensure that no \n got into the output file:
base64 token.sign | tr -d \n > token.sign.b64

tobyjo
답변함 5년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠