Reputation: 71
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.'
Upvotes: 3
Views: 7968
Reputation: 71
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.
Upvotes: 4
Reputation: 28
My issue is the custom dev certificate was installed into the Personal | Certificates instead of Web Hosting | Certificates store. Easy fix, drag -n- drop.
Upvotes: 1