Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aws.Crt.Auth.AwsSigner is unable to sign a request using SigV4A when using Unity for Android and iOS #2126

Closed
ivgnt opened this issue Oct 10, 2022 · 10 comments
Labels
bug This issue is a bug. credentials p2 This is a standard priority issue queued

Comments

@ivgnt
Copy link

ivgnt commented Oct 10, 2022

Describe the bug

In my Unity project I am trying to access AWS multi-region access point using the following code:

Config = new AmazonS3Config();

Config.UseArnRegion = false;
Config.RegionEndpoint = RegionEndpoint.EUWest2;
                
Client = new AmazonS3Client(Config);
        
GetObjectRequest req = new GetObjectRequest
{                   
    BucketName = arn:aws:s3::123456789012:accesspoint/<MRAP_alias>,
    Key = filename                    
};

Client.GetObjectAsync(req).Wait();

The same code works in non-Unity projects apps with .NET Core 3.5 and .NET Core 5.0, but when I'm trying to run it in Unity (both .NET Standard 2.1 and .NET Framework), the following error is raised:

MarshalDirectiveException: Marshalling of non-string and non-blittable arrays to managed code is not implemented. (wrapper native-to-managed) Aws.Crt.Auth.AwsSigner.OnHttpRequestSigningComplete(ulong,int,intptr,ulong,intptr,intptr,unit)

There is also no error when I use a bucket name instead of an access point.

Expected Behavior

The requested file is returned

Current Behavior

MarshalDirectiveException is raised

Reproduction Steps

In Unity project:

Config = new AmazonS3Config();

Config.UseArnRegion = false;
Config.RegionEndpoint = RegionEndpoint.EUWest2;
                
Client = new AmazonS3Client(Config);
        
GetObjectRequest req = new GetObjectRequest
{                   
    BucketName = arn:aws:s3::123456789012:accesspoint/<MRAP_alias>,
    Key = filename                    
};

Client.GetObjectAsync(req).Wait();

Possible Solution

No response

Additional Information/Context

Unity 2021.3.8

AWS .NET SDK and/or Package version used

AWSSDK.Core.3.7.13.12
AWSSDK.S3.3.7.9.61
AWSSDK.Extensions.CrtIntegration.3.7.1.4

Targeted .NET Platform

.NET Standard 2.1

Operating System and version

Windows 11

@ivgnt ivgnt added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 10, 2022
@ivgnt ivgnt changed the title Aws.Crt.Auth.AwsSigner is unable to sign a request using SigV4A when use .NET Standard 2.1 (Unity) Aws.Crt.Auth.AwsSigner is unable to sign a request using SigV4A when using .NET Standard 2.1 (Unity) Oct 10, 2022
@ashishdhingra
Copy link
Contributor

Needs review with the team since Unity is the special case.

@ashishdhingra ashishdhingra added needs-review and removed needs-triage This issue or PR still needs to be triaged. labels Oct 11, 2022
@ik130 ik130 added the A label Oct 14, 2022
@ashishdhingra ashishdhingra added p1 This is a high priority issue and removed A labels Nov 1, 2022
@ivgnt
Copy link
Author

ivgnt commented Dec 9, 2022

Any updates?

@peterrsongg
Copy link
Contributor

@ivgnt Hello, there is an open pull request here: awslabs/aws-crt-dotnet#87 that should address the error you were seeing

@peterrsongg
Copy link
Contributor

@ivgnt The update to target the new version of crt was included in version 3.7.230.0 . If this fixes your problem feel free to close this issue

@ivgnt
Copy link
Author

ivgnt commented Jan 26, 2023

@peterrsongg Thank you! Just tested it, and everything works now. Thank you!

@ivgnt ivgnt closed this as completed Jan 26, 2023
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@ivgnt ivgnt reopened this Jan 30, 2023
@ivgnt
Copy link
Author

ivgnt commented Jan 30, 2023

So, everything worked fine on windows, but we see this error when building and installing the app on both Android and iOS devices

CrtException: Could not detect a supported platform
at Aws.Crt.Platform.GetRuntimePlatformOS () [0x00000] in <00000000000000000000000000000000>:0
at Aws.Crt.CRT+PlatformBinding..ctor () [0x00000] in <00000000000000000000000000000000>:0
at Aws.Crt.CRT..cctor () [0x00000] in <00000000000000000000000000000000>:0
at Aws.Crt.NativeAPI..cctor () [0x00000] in <00000000000000000000000000000000>:0
at Aws.Crt.Auth.AwsSigner+API..cctor () [0x00000] in <00000000000000000000000000000000>:0
at Aws.Crt.Auth.AwsSigner.SignHttpRequest (Aws.Crt.Http.HttpRequest request, Aws.Crt.Auth.AwsSigningConfig signingConfig) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Extensions.CrtIntegration.CrtAWS4aSigner.SignRequest (Amazon.Runtime.Internal.IRequest request, Amazon.Runtime.IClientConfig clientConfig, Amazon.Runtime.Internal.Util.RequestMetrics metrics, Amazon.Runtime.ImmutableCredentials credentials) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.Auth.S3Signer.Sign

@peterrsongg
Copy link
Contributor

peterrsongg commented Jan 30, 2023

@ivgnt thanks for bringing this to our attention. Since the issue is with the CRT library, can you open up an issue there and reference this issue? This is the repo: https://github.com/awslabs/aws-crt-dotnet

@ashishdhingra ashishdhingra added p2 This is a standard priority issue and removed p1 This is a high priority issue labels May 19, 2023
@normj normj changed the title Aws.Crt.Auth.AwsSigner is unable to sign a request using SigV4A when using .NET Standard 2.1 (Unity) Aws.Crt.Auth.AwsSigner is unable to sign a request using SigV4A when using Unity for Android and iOS May 19, 2023
@dscpinheiro
Copy link
Contributor

Closing this as the CRT is not planning to add Android support in .NET.

@dscpinheiro dscpinheiro closed this as not planned Won't fix, can't repro, duplicate, stale Jul 5, 2024
Copy link

github-actions bot commented Jul 5, 2024

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. credentials p2 This is a standard priority issue queued
Projects
None yet
Development

No branches or pull requests

6 participants