Removed singing_public_key.pem, because it wasn't used. Public signin key creating manually by hardcode and it work perfect on windows.
Expected behavior
I want to get decrypted token.
Actual behavior
It's working perfect on Windows. But I'm getting next error in Docker (Linux).
I've tried to use .NET 7 and .NET 8.
Possible solution
Additional context / logs / screenshots / links to code
My task is decrypt JWE with ECDH-ES+A256KW A256GCM. I've tried to use jose-jwt and it's very simple for windows, but it's using CngKey.Import which doesn't supporting on Linux.
I'm trying to use this library, but catch this problem.
I've also created question to SO, but it's still without any answer https://stackoverflow.com/questions/78108216/decrypt-jwe-ecdh-esa256kw-a256gcm.
I hope that someone could help how to fix with this package or some other workable way on linux
Stack trace:
IDX10603: Decryption failed. Keys tried: 'Microsoft.IdentityModel.Tokens.SymmetricSecurityKey, KeyId: '', InternalId: 'YrTOhgtBdNIfFUY7kudowDhgQkhdO6agUXzrJ-ETjtE'.
'.
Exceptions caught:
'System.TypeInitializationException: The type initializer for 'Microsoft.IdentityModel.Tokens.AesGcm' threw an exception.
---> System.DllNotFoundException: Unable to load shared library 'BCrypt.dll' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable:
/usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.2/BCrypt.dll.so: cannot open shared object file: No such file or directory
/app/bin/Debug/net8.0/BCrypt.dll.so: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.2/libBCrypt.dll.so: cannot open shared object file: No such file or directory
/app/bin/Debug/net8.0/libBCrypt.dll.so: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.2/BCrypt.dll: cannot open shared object file: No such file or directory
/app/bin/Debug/net8.0/BCrypt.dll: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.2/libBCrypt.dll: cannot open shared object file: No such file or directory
/app/bin/Debug/net8.0/libBCrypt.dll: cannot open shared object file: No such file or directory
at Microsoft.IdentityModel.Tokens.Interop.BCrypt.BCryptOpenAlgorithmProvider(SafeAlgorithmHandle& phAlgorithm, String pszAlgId, String pszImplementation, Int32 dwFlags)
at Microsoft.IdentityModel.Tokens.Cng.BCryptOpenAlgorithmProvider(String pszAlgId, String pszImplementation, OpenAlgorithmProviderFlags dwFlags)
at Microsoft.IdentityModel.Tokens.AesBCryptModes.<>c__DisplayClass0_0.<OpenAesAlgorithm>b__0()
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at Microsoft.IdentityModel.Tokens.AesGcm..cctor()
--- End of inner exception stack trace ---
at Microsoft.IdentityModel.Tokens.AesGcm.ImportKey(Byte[] key)
at Microsoft.IdentityModel.Tokens.AesGcm..ctor(Byte[] key)
at Microsoft.IdentityModel.Tokens.AuthenticatedEncryptionProvider.CreateAesGcmInstance()
at Microsoft.IdentityModel.Tokens.DisposableObjectPool`1.CreateInstance()
at Microsoft.IdentityModel.Tokens.DisposableObjectPool`1.Allocate()
at Microsoft.IdentityModel.Tokens.AuthenticatedEncryptionProvider.DecryptWithAesGcm(Byte[] ciphertext, Byte[] authenticatedData, Byte[] iv, Byte[] authenticationTag)
at Microsoft.IdentityModel.Tokens.AuthenticatedEncryptionProvider.Decrypt(Byte[] ciphertext, Byte[] authenticatedData, Byte[] iv, Byte[] authenticationTag)
at Microsoft.IdentityModel.JsonWebTokens.JwtTokenUtilities.DecryptToken(CryptoProviderFactory cryptoProviderFactory, SecurityKey key, String encAlg, Byte[] ciphertext, Byte[] headerAscii, Byte[] initializationVector, Byte[] authenticationTag)
at Microsoft.IdentityModel.JsonWebTokens.JwtTokenUtilities.DecryptJwtToken(SecurityToken securityToken, TokenValidationParameters validationParameters, JwtTokenDecryptionParameters decryptionParameters)
'.
token: '*my token here*'
Which version of Microsoft.IdentityModel are you using? System.IdentityModel.Tokens.Jwt 7.4.0
Where is the issue?
Is this a new or an existing app? c. Experemental app for testing before implementing to existing app.
Repro
Edit 1: Here private encryption key encryption_private_key.pem
Removed singing_public_key.pem, because it wasn't used. Public signin key creating manually by hardcode and it work perfect on windows.
Expected behavior I want to get decrypted token.
Actual behavior It's working perfect on Windows. But I'm getting next error in Docker (Linux). I've tried to use .NET 7 and .NET 8.
Possible solution
Additional context / logs / screenshots / links to code My task is decrypt JWE with ECDH-ES+A256KW A256GCM. I've tried to use jose-jwt and it's very simple for windows, but it's using CngKey.Import which doesn't supporting on Linux. I'm trying to use this library, but catch this problem. I've also created question to SO, but it's still without any answer https://stackoverflow.com/questions/78108216/decrypt-jwe-ecdh-esa256kw-a256gcm. I hope that someone could help how to fix with this package or some other workable way on linux
Stack trace: