.net core Kestrel ssl JSON配置中的证书问题

.net core Kestrel ssl JSON配置中的证书问题,.net-core,ssl-certificate,kestrel-http-server,.net Core,Ssl Certificate,Kestrel Http Server,引用是否可以使用appsettings.json文件配置https: "HttpsInlineCertStore": { "Url": "https://+:5002", "Certificate": { "Subject": "<coma separated multi-line subject name>", "Store": "Root", "Location": "LocalMachine" } “HttpsInl

引用是否可以使用appsettings.json文件配置https:

  "HttpsInlineCertStore": {
    "Url": "https://+:5002",
    "Certificate": {
      "Subject": "<coma separated multi-line subject name>",
      "Store": "Root",
      "Location": "LocalMachine"
  }
“HttpsInlineCertStore”:{
“Url”:“https://+:5002”,
“证书”:{
“主题”:“,
“存储”:“根”,
“位置”:“本地计算机”
}
此证书确实存在,下一个代码返回并找到它:

        using (var certStore = new X509Store(StoreName.Root, StoreLocation.LocalMachine))
        {
            certStore.Open(OpenFlags.ReadOnly);
            var certificates = certStore.Certificates.Find(
                X509FindType.FindBySubjectDistinguishedName, "<coma separated multi-line subject name>", true);

            return certificates .Count > 0 ? certificates [0] : null;;
        }
使用(var certStore=new X509Store(StoreName.Root,StoreLocation.LocalMachine))
{
打开(OpenFlags.ReadOnly);
var certificates=certStore.certificates.Find(
X509FindType.FindBysubjectDifferentizedName,”,true);
返回证书。计数>0?证书[0]:null;;
}

同时,如果通过X509FindType.FindBySubjectName搜索证书,则不会发现任何结果,我相信这就是问题所在,尽管FindBySubjectDiscrimitedName是更具体的搜索。

最后,我能够解决此问题:
类似于“CN=name,C=UK,…”,但如果您想查找BySubjectName,则必须从搜索字符串中删除“CN=”,只保留名称,使其看起来不像“CN=name”,而是像“name”。

是的!谢谢!我刚要声明这一点,就找到了您的答案。