我已將基于 ASP.NET 6 ReactJS 模板的 ASP.NET 6 解決方案部署到 Linux CentOS/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
我發現了幾個常見問題解答,表明使用 ECDSA 或類似的,但沒有真實的例子來說明如何在我的解決方案型別中準確地實作這一點,以及 Program.cs 或類似的修改示例。
我將不勝感激對此的任何想法!
提前致謝!
uj5u.com熱心網友回復:
您可以使用 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://www.uj5u.com/shujuku/510599.html
標籤:linux阿帕奇asp.net 核心asp.net 身份身份服务器4
