我正在尝试登录证书 (OpenIddict),但在尝试使用指纹时出现错误:
options.AddSigningCertificate(Configuration["Certificate"]/* db b9 12 .... 22 */);
和错误:
Application startup exception: System.Security.Cryptography.CryptographicException: OpenCSP failed with error code 2148073494.
在这一行中:
app.UseOpenIddict();
如果我尝试使用 X509Certificate2,我也会收到错误消息:
var cert = new X509Certificate2(Configuration["Certificate"]/*path to file.cer*/);
options.AddSigningCertificate(cert);
和错误:
System.InvalidOperationException: The certificate doesn't contain the required private key.
在同一行 app.UseOpenIddict();
。
我使用的证书与用于 https 协议(protocol)的证书相同。这个可以吗?
我的事件 token 随机消失了(尝试刷新 token 时我得到了 invalid_token)。我在某处发现如果使用 AddEphemeralSigningKey
会发生这种情况,因为当连接断开时(由于 IIS 空闲超时),所有 token 都会丢失。因此,我正在尝试使用 AddSigningCertificate
。
还有别的办法吗?有人可以告诉我,证书有什么问题吗?谢谢。
我正在使用 ASP.NET Core 1.1.1。
我为 IIS 用户添加了对 .cer 文件的读取权限。
最佳答案
我用 SelfCert ( https://s3.amazonaws.com/pluralsight-free/keith-brown/samples/SelfCert.zip ) 创建的新证书解决了我的问题。
然后我将证书添加到项目源并调用 AddSigningCertificate:
if (this.env.IsDevelopment())
options.AddEphemeralSigningKey();
else
options.AddSigningCertificate(new FileStream(Directory.GetCurrentDirectory() + "/Resources/cert.pfx", FileMode.Open), "pass");
我还必须为 IIS 用户添加完整 文件权限。只读和执行是不够的。
就是这样。它有效。
关于ssl - AddSigningCertificate 出现 OpenIddict 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43486879/