【问题标题】:IIS Express using "imaginary" SSL certificateIIS Express 使用“虚构的”SSL 证书
【发布时间】:2020-03-03 15:02:20
【问题描述】:

我已经为此奋斗了几个星期了。我已经用尽了我的 Google-fu,需要你的帮助。

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

IIS Express 使用的 SSL 证书在我的 PC 上的任何地方都找不到。目前它没有使用它在修复过程中创建的证书。它使用了一些我在计算机上找不到的随机证书。

我已经通过 mmc 管理单元 100 次,运行 dos 和 powershell 命令,搜索我的注册表,搜索文件系统,我什至检查了 100k 行进程监视器试图找到它在哪里拉证书来自。我在任何地方都找不到它正在使用的证书。

Windows 10。这是一个带有相关 localhost 条目的证书转储:

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

有人有什么想法吗?如果您需要任何其他信息,请告诉我。

【问题讨论】:

  • 您应该能够轻松找到证书映射 docs.jexusmanager.com/tutorials/https-binding.html#background 并注意“Location : CurrentUser”并未涵盖您计算机上的所有证书。
  • 我列出了来自 LocalMachine 和 CurrentUser 的所有 localhost 证书。 IIS Express 是否能够使用来自不同用户的证书?也许它正在使用为我设置这台机器的管理员用户的证书?

标签: windows ssl-certificate iis-express


【解决方案1】:

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;

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

【讨论】:

    猜你喜欢
    • 2017-08-08
    • 1970-01-01
    • 2017-10-18
    • 2017-10-31
    • 1970-01-01
    • 2013-11-30
    • 1970-01-01
    • 2020-04-09
    • 2014-09-09
    相关资源
    最近更新 更多