我已经看到这个问题的答案,但它似乎不适用于 .net core 3.1
此代码查找证书:
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没有找到证书:
"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.'
我发现了这个问题,服务器上的证书没有私钥。一旦我得到了私钥,它就开始工作了。显示它现在拥有私钥的证书 https://i.stack.imgur.com/Nl6PC.png
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)