问题
I have seen this question answered but it doesn't seem to be working for .net core 3.1 This 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.");
}
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
}
}
}
}
Gives the follow error:
System.InvalidOperationException: 'The requested certificate *.timedesk.com could not be found in LocalMachine/Root with AllowInvalid setting: False.'
回答1:
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
来源:https://stackoverflow.com/questions/59921131/certificate-issue-in-kestrel-ssl-json-configuration-using-net-core-3-1