【问题标题】:Certificate issue in Kestrel ssl JSON configuration using .net Core 3.1使用 .net Core 3.1 的 Kestrel ssl JSON 配置中的证书问题
【发布时间】:2020-05-12 05:42:56
【问题描述】:

我已经看到这个问题得到了回答,但它似乎不适用于 .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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-16
      • 2020-11-09
      • 1970-01-01
      • 2020-08-22
      • 2019-10-21
      • 2021-03-09
      相关资源
      最近更新 更多