-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Description
Hi there,
After upgrading to .net 8.0, I am getting above error, I am using ES256 algorithm to sign the JWT using jose-jwt library
here is a full stack:
[17:12:14 ERR] HTTP POST /api/v1/auth/login responded 500 in 291.7296 ms
Jose.JoseException: Unable to sign content.
---> Interop+AppleCrypto+AppleCFErrorCryptographicException: The operation couldn’t be completed. (OSStatus error 100000 - CSSM Exception: 100000 UNIX[Undefined error: 0])
at Interop.AppleCrypto.NativeCreateSignature(SafeSecKeyRefHandle privateKey, ReadOnlySpan1 dataHash, PAL_HashAlgorithm hashAlgorithm, PAL_SignatureAlgorithm signatureAlgorithm) at Interop.AppleCrypto.CreateSignature(SafeSecKeyRefHandle privateKey, ReadOnlySpan1 dataHash, PAL_HashAlgorithm hashAlgorithm, PAL_SignatureAlgorithm signatureAlgorithm)
at System.Security.Cryptography.ECDsaImplementation.ECDsaSecurityTransforms.SignHash(Byte[] hash)
at System.Security.Cryptography.ECDsa.SignData(Byte[] data, Int32 offset, Int32 count, HashAlgorithmName hashAlgorithm)
at Jose.netstandard1_4.EcdsaUsingSha.Sign(ECDsa privateKey, Byte[] securedInput)
at Jose.netstandard1_4.EcdsaUsingSha.Sign(Byte[] securedInput, Object key)
--- End of inner exception stack trace ---
at Jose.netstandard1_4.EcdsaUsingSha.Sign(Byte[] securedInput, Object key)
at Jose.JWT.EncodeBytes(Byte[] payload, Object key, JwsAlgorithm algorithm, IDictionary2 extraHeaders, JwtSettings settings, JwtOptions options) at Jose.JWT.Encode(String payload, Object key, JwsAlgorithm algorithm, IDictionary2 extraHeaders, JwtSettings settings, JwtOptions options)
at Jose.JWT.Encode(Object payload, Object key, JwsAlgorithm algorithm, IDictionary`2 extraHeaders, JwtSettings settings, JwtOptions options)
I already checked #59703 but it didn't help. Kindly review and any help would be appreciated.
Thanks,
Binoy
Reproduction Steps
var payload = new Dictionary<string, object>
{
{ "iss", _jwtSettings.Issuer! },
{ "aud", _jwtSettings.Audience! },
{ "sub", userId },
{ ApplicationClaims.FullName, displayName! },
{ ApplicationClaims.ProductKind, productKind },
{ ApplicationClaims.Timezone, timezone },
{ "email", email },
{ ApplicationClaims.TenantId, tenantId },
{ "iat", DateTimeOffset.UtcNow.ToUnixTimeSeconds() },
{ "exp", DateTimeOffset.UtcNow.AddMinutes(_jwtSettings.Validity).ToUnixTimeSeconds() }
};
return Jose.JWT.Encode(payload, _privateKey, Jose.JwsAlgorithm.ES256);
Crashing when running JWT.Encode() methode
Expected behavior
It should sign the JWT and should not throw exception
Actual behavior
Throwing exception when calling JWT.Encode method:
Jose.JoseException: Unable to sign content.
---> Interop+AppleCrypto+AppleCFErrorCryptographicException: The operation couldn’t be completed. (OSStatus error 100000 - CSSM Exception: 100000 UNIX[Undefined error: 0])
Regression?
No response
Known Workarounds
No response
Configuration
Runtime Environment:
OS Name: Mac OS X
OS Version: 14.1
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/8.0.100/
.NET workloads installed:
Workload version: 8.0.100-manifests.6c33ef20
There are no installed workloads to display.
Host:
Version: 8.0.0
Architecture: arm64
Commit: 5535e31
.NET SDKs installed:
8.0.100 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
x64 [/usr/local/share/dotnet/x64]
registered at [/etc/dotnet/install_location_x64]
Other information
No response