使用 .net Core 3.1 的 Kestrel ssl JSON 配置中的证书问题

问题描述 投票:0回答:2

我已经看到这个问题的答案,但它似乎不适用于 .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.'
.net-core ssl-certificate kestrel-http-server .net-core-3.1
2个回答
3
投票

我发现了问题,服务器上的证书没有私钥。 一旦我得到私钥,它就开始工作了。
Cert showing it now has private key


0
投票

我的问题是自定义开发证书已安装到个人 |证书代替虚拟主机|证书存储。轻松修复,拖放即可。

© www.soinside.com 2019 - 2024. All rights reserved.