-
Notifications
You must be signed in to change notification settings - Fork 865
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
Instructions for generating signed URLs are incorrect. #3567
Comments
What package are you using? As mentioned on the other issue For example, this works for me: $ openssl version
OpenSSL 3.0.8 7 Feb 2023 (Library: OpenSSL 3.0.8 7 Feb 2023) <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AWSSDK.Extensions.CloudFront.Signers" Version="4.0.0-preview.4" />
</ItemGroup>
</Project>
using Amazon.CloudFront;
// Key generated using the OpenSSL version above
var privateKeyReader = new StreamReader(@"private_key_openssl3.pem");
var url = AmazonCloudFrontUrlSigner.GetCannedSignedURL(
"https://example.com/my-content",
privateKeyReader,
"my-key-id",
DateTime.UtcNow.AddHours(1)
);
Console.WriteLine(url); |
I use |
It would be wonderful if the documentation for this is updated. Took half a day debugging to land on this github issue that fixed it in 5 minutes. |
Hi
Following the guide of this url:
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-trusted-signers.html
The generated private key did not work for me using
AmazonCloudFrontUrlSigner.GetCannedSignedURL(url, privateKeyReader, keyPair, expiresOn);
throw a exception Invalid Key
The solution is to add the -traditional parameter to the creation, it would look like this:
openssl genrsa -out private_key.pem -traditional 2048
So it works correctly in c#
If you already have the generated private key you can transform it to the correct format using:
openssl rsa -in private_key.pem -out private_key_traditional.pem -traditional
The step of generating the public key has worked correctly for me and the generated urls work correctly.
I use, on ubuntu in wsl
OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)
Originally posted by @ferminolr in #3221 (comment)
The text was updated successfully, but these errors were encountered: