-
Notifications
You must be signed in to change notification settings - Fork 183
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
JWT.Encode works fine on local machine in .NET7.0 Windows 11 , on windows server 2012 throw exception: Unable to sign content., inner exception: The requested operation is not supported.| #227
Comments
Hi @RafalSzczerba , can you post full stack trace? And if you have code that showing how do you load your |
Hello @dvsekhvalnov Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException: The requested operation is not supported. at System.Security.Cryptography.ECCng.ImportKeyBlob(String blobType, ReadOnlySpan PrivateKey creation:
|
Additionally I've found place where exception is made. It is in JWK.cs during attempt to import parameters: ecdsaKey.ImportParameters(param); |
Hm.. interesting, let's try simple thing first: Jwk eccKey = new Jwk(
crv: "P-256",
x: "BHId3zoDv6pDgOUh8rKdloUZ0YumRTcaVDCppUPoYgk",
y: "g3QIDhaWEksYtZ9OWjNHn9a6-i_P9o5_NrdISP0VWDU",
d: "KpTnMOHEpskXvuXHFCfiRtGUHUZ9Dq5CCcZQ-19rYs4"
); will your code work with key above ^^ ? Also, on .NET 5+ you can use built-in functions to read PEM files, see here: https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.ecalgorithm.importfrompem?view=net-7.0#system-security-cryptography-ecalgorithm-importfrompem(system-readonlyspan((system-char))) you can probably do something like (no explicit need to convert to var eccPem = File.ReadAllText("my-key.pem");
var key = ECDsa.Create();
key.ImportFromPem(eccPem);
Jose.JWT.Encode(payload, key, ....); |
I'm using this packange in my project in .NET7.0 and is wokring fine on my local machine, but after deployment this on the server problem occures while calling method Jose.JWT.Encode(payload, privateKey, JwsAlgorithm.ES256, headers, options: new JwtOptions {DetachPayload = true, EncodePayload = false });
where:
payload: jsonBody,
priavteKey: is made from .pem and creation object with fullfilled following properites:
new Jwk (crv, , x, y, d: );
I've compared content of payload, header, private key , algorithm, options and there are exactly the same in local machine and on the server.
The exception pop up:
CreateJWSSignature: ex: Unable to sign content., inner exception: The requested operation is not supported.
Could you tell me if this method need to have some extra access to the some resources which I have on local machine but not available on the server? Or maybe you know how to fix this in the code? I'm using windows 11 on local machine, server is windows server 2012
The text was updated successfully, but these errors were encountered: