awslabs / aws-crt-nodejs

NodeJS bindings for the AWS Common Runtime.
Apache License 2.0
37 stars 24 forks source link

'AWS Signer SigV4A Headers' unit test failing #491

Closed langhorstg316 closed 8 months ago

langhorstg316 commented 9 months ago

Describe the bug

I was testing the SigV4A signing examples from https://github.com/aws-samples/sigv4a-signing-examples and kept receiving the following credential error.

image

I then cloned this repo and ran the unit tests with "npm run test" and saw the same credentials error was occurring with the unit test.

image

I am running the latest macOS: 14.0 (23A344). I tried to debug it with vs code but the issue is in the c code. Any obvious areas to look or purge like keychain, some local aws cache, etc? I just have the standard default profile configured in ~/.aws/credentials and config.

Expected Behavior

I expect to see the signed headers returned.

Current Behavior

Failing on 'AWS Signer SigV4A Headers' unit test

Reproduction Steps

Possible Solution

No response

Additional Information/Context

No response

aws-crt-nodejs version used

1.18

nodejs version used

20.*

Operating System and version

macOS 14.0 (23A344)

bretambrose commented 9 months ago

You could enable trace logging (https://github.com/awslabs/aws-crt-nodejs/blob/main/lib/native/io.ts#L87) and attach the log for that particular test.

That being said, we do not have any access to Sonoma at present for testing purposes and I don't have an ETA when we would.

langhorstg316 commented 9 months ago

I enabled logging with level TRACE. Nothing was captured for that specific test. Saw plenty of trace outputs for the other tests in auth.spec.ts.

image
langhorstg316 commented 9 months ago

In addition, I see the following output from macOS unified logger.

image
bretambrose commented 9 months ago

Try modifying the test so that it swallows the error and doesn't fail. For me, I get:

[INFO] [2023-10-10T18:06:55Z] [00007ff846e5d700] [AuthCredentialsProvider] - (id=0x6000027db3f0) Static credentials provider successfully sourced credentials
[INFO] [2023-10-10T18:06:55Z] [00007ff846e5d700] [AuthSigning] - (id=0x600000addef0) Signing successfully built canonical request for algorithm SigV4Asymmetric, with contents 
GET
/

host:example.amazonaws.com
x-amz-date:20150830T123600Z
x-amz-region-set:us-east-1

host;x-amz-date;x-amz-region-set
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
[INFO] [2023-10-10T18:06:55Z] [00007ff846e5d700] [AuthSigning] - (id=0x600000addef0) Signing successfully built string-to-sign via algorithm SigV4Asymmetric, with contents 
AWS4-ECDSA-P256-SHA256
20150830T123600Z
20150830/service/aws4_request
cf59db423e841c8b7e3444158185aa261b724a5c27cbe762676f3eed19f4dc02
[INFO] [2023-10-10T18:06:55Z] [00007ff846e5d700] [AuthSigning] - (id=0x600000addef0) Http request successfully built final authorization value via algorithm SigV4Asymmetric, with contents 
AWS4-ECDSA-P256-SHA256 Credential=AKIDEXAMPLE/20150830/service/aws4_request, SignedHeaders=host;x-amz-date;x-amz-region-set, Signature=3044022011ba5a1e8d5d0459b4a29db48e6948158dc29ba0476319578d6d50f74c1aec92022001b3fbece96f58b6e423f8fd19376a2e3f8032eb12bd8166d43bc37e91747dc4
bretambrose commented 9 months ago

Seems likely that something is failing in here that does not fail for any versions < 14:

https://github.com/awslabs/aws-c-cal/blob/main/source/darwin/securityframework_ecc.c

TingDaoK commented 8 months ago

Thanks for reporting the issue. The latest version https://github.com/awslabs/aws-crt-nodejs/tree/v1.18.1, with the fix just released. It should be available from npm soon.

The fix is here for visibility

TingDaoK commented 8 months ago

Okay, the latest version is available now, can you try it out and let us know if you still have any issue?

langhorstg316 commented 8 months ago

Just updated and tested. Worked as expected. Amazing work and response time!

jmklix commented 8 months ago

I'm glad this fix worked for you, let us know if you run into any other problems with this repo.