本文介绍了使用 .net Core 3.1 的 Kestrel ssl JSON 配置中的证书问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经看到这个问题的回答,但它似乎不适用于 .net core 3.1此代码查找证书:
I have seen this question answered but it doesn't seem to be working for .net core 3.1This code finds the Certificate:
using (var store = new X509Store("Root", StoreLocation.LocalMachine))
{
store.Open(OpenFlags.ReadOnly);
var certCollection = store.Certificates;
var currentCerts = certCollection.Find(X509FindType.FindBySubjectName, "*.timedesk.com", false);
if (currentCerts.Count == 0)
throw new Exception("Https certificate is not found.");
}
这个 appsettings.json 没有找到证书:
This appsettings.json does not find the certificate:
"Kestrel": {
"Endpoints": {
"Https": {
"URL": "https://toast.timedesk.com:443",
"Scheme": "https",
"Certificate": {
"Store": "Root",
"Location": "LocalMachine",
"Subject": "*.timedesk.com",
"AllowInvalid": false
}
}
}
}
给出以下错误:
System.InvalidOperationException: 'The requested certificate *.timedesk.com could not be found in LocalMachine/Root with AllowInvalid setting: False.'
推荐答案
我发现了问题,服务器上的 Cert 没有私钥.一旦我得到一个私钥,它就开始工作了.证书显示它现在有私钥
I figured out the issue, the Cert on the server did not have a private key. Once i got a private key this started working.Cert showing it now has private key
这篇关于使用 .net Core 3.1 的 Kestrel ssl JSON 配置中的证书问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!