Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net core 使用.net Core 3.1在Kestrel ssl JSON配置中颁发证书_.net Core_Ssl Certificate_Kestrel Http Server_.net Core 3.1 - Fatal编程技术网

.net core 使用.net Core 3.1在Kestrel ssl JSON配置中颁发证书

.net core 使用.net Core 3.1在Kestrel ssl JSON配置中颁发证书,.net-core,ssl-certificate,kestrel-http-server,.net-core-3.1,.net Core,Ssl Certificate,Kestrel Http Server,.net Core 3.1,我已经看到这个问题的答案,但它似乎不适用于.NETCore3.1 此代码查找证书: using (var store = new X509Store("Root", StoreLocation.LocalMachine)) { store.Open(OpenFlags.ReadOnly); var certCollection = store.Certificates; var currentCerts = certCollection.Find(X509FindTy

我已经看到这个问题的答案,但它似乎不适用于.NETCore3.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.");
}
"Kestrel": {
  "Endpoints": {
    "Https": {
      "URL": "https://toast.timedesk.com:443",
      "Scheme": "https",
      "Certificate": {
        "Store": "Root",
        "Location": "LocalMachine",
        "Subject": "*.timedesk.com",
        "AllowInvalid": false
      }
    }
  }
}
此appsettings.json找不到证书:

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.");
}
"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.'

我发现了问题所在,服务器上的证书没有私钥。一旦我拿到了私钥,它就开始工作了