我已经将基于ASP.NET 6 ReactJS模板的ASP.NET 6解决方案部署到Linux /Apache托管环境中。
根据下面提供的错误消息,我似乎需要修改签名提供程序的算法,但是我不知道该如何做到这一点。
System.NotSupportedException: IDX10634: Unable to create the SignatureProvider.
Algorithm: 'RS256', SecurityKey: 'Microsoft.IdentityModel.Tokens.X509SecurityKey, KeyId: 'xxxxxxxxxxxx', InternalId: 'xxxxxxx'.' is not supported. The list of supported algorithms is available here: https://aka.ms/IdentityModel/supported-algorithms
我已经找到了几个FAQ,表明可以使用ECDSA或类似的方法,但是没有真正的示例说明如何在我的解决方案类型中使用Program.cs或类似的修改来实现这一点。
我很感激你对此的任何想法!
提前感谢!
发布于 2022-09-21 23:25:49
您可以使用OpenSSL创建自己的ECDSA密钥:
#Create P256 ECDSA Private key
openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -aes256 -out p256-private.pem
# Optionally, if you want to extract the public key:
openssl ec -in p256-private.pem -pubout -out p256-public.pe
# Create certificat file
openssl req -new -x509 -key p256-private-key.pem -days 365 -subj "/CN=MyP256Cert" -out p256-cert.crt
# Crete the PFX file
openssl req -new -x509 -key p256-private-key.pem -days 365 -subj "/CN=MyP256Cert" -out p256-cert.crt
然后可以使用以下方法将其加载到C#中:
var ecdsaCert = new X509Certificate2("es256.pfx", "password");
SecurityKey ecdsaPrivateKey = new ECDsaSecurityKey(ecdsaCert.GetECDsaPrivateKey());
您可以使用以下内容将其添加到IdentityServer中:
// Add ES256 (ECDSA using P-256 and SHA-256)
builder.AddSigningCredential(GetECDsaPrivateKey(p256Cert), IdentityServerConstants.ECDsaSigningAlgorithm.ES256);
https://stackoverflow.com/questions/73806473
复制相似问题