【发布时间】:2019-09-26 07:33:03
【问题描述】:
我刚刚将此插件安装到我的 azure webapp 中 https://github.com/shibayan/azure-appservice-letsencrypt
它可以完美地用作我的自定义域上托管的 SSL 证书。
但是现在,我需要使用这个证书在我的后端进行签名操作(它是一个身份服务器)
所以这是我使用位于startup.cs 中的证书的代码:
using (var store = new X509Store(StoreName.My, StoreLocation.CurrentUser))
{
store.Open(OpenFlags.ReadOnly);
var col = store.Certificates.Find(X509FindType.FindByThumbprint, "mythumbprint", false);
if (col.Count > 0)
{
builder.AddSigningCredential(col[0]); // the builder of identityserver
}
else
{
throw new Exception("Startup Error: Unable to find signing certificate");
}
_logger.LogInformation(col[0].PublicKey.Key.KeyExchangeAlgorithm);
}
除了我尝试访问公钥的那一行之外,启动工作正常:
col[0].PublicKey.Key.KeyExchangeAlgorithm
我收到此异常:
System.NotSupportedException:证书密钥算法不是 支持的。在 System.Security.Cryptography.X509Certificates.PublicKey.get_Key()
根据 dotnet 核心文档 (https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.x509certificates.publickey.key?view=netframework-4.8) 和 github (https://github.com/dotnet/corefx/blob/master/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/PublicKey.cs),仅支持 RSA 和 DSA。
所以我的问题是:我能做什么?我尝试将证书转换为 pfx 文件,但我没有找到此证书的私钥(我只有指纹)
【问题讨论】:
标签: c# asp.net-core identityserver4 lets-encrypt x509certificate2