IIS Express使用“虚拟” SSL证书

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

我已经为此战斗了几周。我已经用尽了Google-fu,需要您的帮助。

我想删除IIS Express默认的证书(即将过期),并使用我“修复” IIS Express时创建的证书。

IIS Express使用的SSL证书在PC上的任何地方都找不到。当前,它不使用在修复过程中创建的证书。它使用的是rando证书,在计算机的任何地方都找不到。

我已经通过mmc管理单元100次,运行过dos和powershell命令,通过我的注册表进行搜索,通过文件系统进行了搜索,我什至经历了10万行的进程监视器,试图找到将证书拖到哪里的方法从。我找不到任何地方使用的证书。

Windows10。这是带有相关本地主机条目的证书转储:

Location   : CurrentUser

Name : Root

Subject      : CN=localhost
Issuer       : CN=localhost
Thumbprint   : 7019C23346CD99CDE8ED35F2A712410F3E5A03DB
FriendlyName : ASP.NET Core HTTPS development certificate
NotBefore    : 2/28/2020 8:26:43 AM
NotAfter     : 2/27/2021 8:26:43 AM
Extensions   : {System.Security.Cryptography.Oid, System.Security.Cryptography.Oid, System.Security.Cryptography.Oid, 
               System.Security.Cryptography.Oid...}

Subject      : CN=localhost
Issuer       : CN=localhost
Thumbprint   : 4671C5C7DC49E26F318C30911B4494D2511E665E
FriendlyName : IIS Express Development Certificate
NotBefore    : 2/28/2020 8:26:16 AM
NotAfter     : 2/27/2025 6:00:00 PM
Extensions   : {System.Security.Cryptography.Oid, System.Security.Cryptography.Oid, System.Security.Cryptography.Oid}

Name: My

Subject      : CN=localhost
Issuer       : CN=localhost
Thumbprint   : 7019C23346CD99CDE8ED35F2A712410F3E5A03DB
FriendlyName : ASP.NET Core HTTPS development certificate
NotBefore    : 2/28/2020 8:26:43 AM
NotAfter     : 2/27/2021 8:26:43 AM
Extensions   : {System.Security.Cryptography.Oid, System.Security.Cryptography.Oid, System.Security.Cryptography.Oid, 
               System.Security.Cryptography.Oid...}

Subject      : CN=localhost
Issuer       : CN=localhost
Thumbprint   : 4671C5C7DC49E26F318C30911B4494D2511E665E
FriendlyName : IIS Express Development Certificate
NotBefore    : 2/28/2020 8:26:16 AM
NotAfter     : 2/27/2025 6:00:00 PM
Extensions   : {System.Security.Cryptography.Oid, System.Security.Cryptography.Oid, System.Security.Cryptography.Oid}

这是Chrome所提供的证书:

Serial number: 00e7573e7ee6f8a315
Signature algorithm: sha256RSA
Issuer: localhost
Subject: localhost
1.3.6.1.4.1.311.84.1.1: ASP.NET Core HTTPS development certificate
Thumbprint: f3b46e7bd1d6a66d150948342ffe00ebb42f33ac

有人有什么想法吗?让我知道是否需要其他信息。

windows ssl-certificate iis-express
1个回答
0
投票

Kestrel尝试为该项目找到一个“默认”证书。该证书未存储在计算机的密钥存储区中。它以.pfx文件形式存储在文件系统中。路径为%appData%\ ASP.NET \ https。

我通过阅读Kestrel源代码发现了这一点KestrelConfigurationLoader.TryGetCertificatePath():

    var hostingEnvironment = Options.ApplicationServices.GetRequiredService<IHostEnvironment>();
    var appName = hostingEnvironment.ApplicationName;

    // This will go away when we implement
    // https://github.com/aspnet/Hosting/issues/1294
    var appData = Environment.GetEnvironmentVariable("APPDATA");
    var home = Environment.GetEnvironmentVariable("HOME");
    var basePath = appData != null ? Path.Combine(appData, "ASP.NET", "https") : null;
    basePath = basePath ?? (home != null ? Path.Combine(home, ".aspnet", "https") : null);
    path = basePath != null ? Path.Combine(basePath, $"{appName}.pfx") : null;
    return path != null;

我删除了文件夹中的密钥,它解决了我的问题。快乐的日子!

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