【问题标题】:ASP.NET Core 3.0 app not working on Windows Server 2012 R2 due to ERR_HTTP2_INADEQUATE_TRANSPORT_SECURITY由于 ERR_HTTP2_INADEQUATE_TRANSPORT_SECURITY,ASP.NET Core 3.0 应用程序无法在 Windows Server 2012 R2 上运行
【发布时间】:2020-05-08 17:00:48
【问题描述】:

我使用了一个正常工作的 ASP.NET Core 2.2 应用程序,将其升级到 3.0,突然该应用程序在 Windows Server 2012 中不再工作。它出现了以下问题:

ERR_HTTP2_INADEQUATE_TRANSPORT_SECURITY

铬:

火狐:

似乎在我不得不选择 HTTP/2 之前,现在它与 HTTP1.1 一起成为默认设置。这里有一个帖子 https://github.com/aspnet/AspNetCore/issues/14350 但这完全令人困惑,没有真正的解决方案。

我尝试了各种启用/禁用不安全协议,但无济于事。如https://www.admin-enclave.com/de/articles-by-year/11-data-articles/website_articles/articles/exchange_articles/405-resolved-error-err_spdy_inadequate_transport_security-when-using-google-chome-and-owa.html

在 Windows 10 上运行良好,因为我认为协议套件更好。但在 Fiddler 中,我检查了与 Kestrel 谈判时的唯一区别是:

Windows Server 2012 R2:

[0A0A]  Unrecognized cipher - See http://www.iana.org/assignments/tls-parameters/
[1301]  Unrecognized cipher - See http://www.iana.org/assignments/tls-parameters/
[1302]  Unrecognized cipher - See http://www.iana.org/assignments/tls-parameters/
[1303]  Unrecognized cipher - See http://www.iana.org/assignments/tls-parameters/
[C02B]  TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
[C02F]  Unrecognized cipher - See http://www.iana.org/assignments/tls-parameters/
[C02C]  TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
[C030]  Unrecognized cipher - See http://www.iana.org/assignments/tls-parameters/
[CCA9]  Unrecognized cipher - See http://www.iana.org/assignments/tls-parameters/
[CCA8]  Unrecognized cipher - See http://www.iana.org/assignments/tls-parameters/
[C013]  TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA
[C014]  TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA
[009C]  Unrecognized cipher - See http://www.iana.org/assignments/tls-parameters/
[009D]  Unrecognized cipher - See http://www.iana.org/assignments/tls-parameters/
[002F]  TLS_RSA_AES_128_SHA
[0035]  TLS_RSA_AES_256_SHA
[000A]  SSL_RSA_WITH_3DES_EDE_SHA

Windows 10:

[3A3A]  Unrecognized cipher - See http://www.iana.org/assignments/tls-parameters/
[1301]  Unrecognized cipher - See http://www.iana.org/assignments/tls-parameters/
[1302]  Unrecognized cipher - See http://www.iana.org/assignments/tls-parameters/
[1303]  Unrecognized cipher - See http://www.iana.org/assignments/tls-parameters/
[C02B]  TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
[C02F]  Unrecognized cipher - See http://www.iana.org/assignments/tls-parameters/
[C02C]  TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
[C030]  Unrecognized cipher - See http://www.iana.org/assignments/tls-parameters/
[CCA9]  Unrecognized cipher - See http://www.iana.org/assignments/tls-parameters/
[CCA8]  Unrecognized cipher - See http://www.iana.org/assignments/tls-parameters/
[C013]  TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA
[C014]  TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA
[009C]  Unrecognized cipher - See http://www.iana.org/assignments/tls-parameters/
[009D]  Unrecognized cipher - See http://www.iana.org/assignments/tls-parameters/
[002F]  TLS_RSA_AES_128_SHA
[0035]  TLS_RSA_AES_256_SHA
[000A]  SSL_RSA_WITH_3DES_EDE_SHA

顶行不同,但仅此而已。不知道它是什么,它是一些GREASE 值。

程序.cs:

    public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
      WebHost.CreateDefaultBuilder(args)
      .UseKestrel(opts => {
        opts.ListenAnyIP(5000);
        opts.ListenAnyIP(5001, listenOpts => {
          listenOpts.UseHttps(new HttpsConnectionAdapterOptions {
            ServerCertificate = new X509Certificate2("certificate-server.pfx", "...")
          });
        });
        opts.Limits.MaxRequestBodySize = null;
      })
      .UseContentRoot(Directory.GetCurrentDirectory())
      .UseStartup<Startup>();
  }

更新

感谢@chris-pratt,我似乎走在了正确的轨道上。将证书密码更改为 ECDSA_nistP256 使 Web 应用程序工作。但不幸的是,我正在使用证书来签署 JWT 令牌,现在这被打破了:

System.NotSupportedException:证书密钥算法不是 支持的。在 System.Security.Cryptography.X509Certificates.PublicKey.get_Key()

签名码是:

  var privateKey = new X509SecurityKey(new X509Certificate2("certificate-server.pfx", "..."));
  var token = new JwtSecurityToken(
    issuer: "Sentry",
    claims: claims,
    notBefore: DateTime.Now,
    expires: DateTime.Now.AddDays(1),
    signingCredentials: new SigningCredentials(privateKey, SecurityAlgorithms.RsaSha256Signature));

  return new JwtSecurityTokenHandler().WriteToken(token);

我尝试更改 SecurityAlgorithms 枚举但没有成功。

【问题讨论】:

  • 您有在该服务器上运行的任何 ASP.NET Core 3.0 应用程序吗?我在想您可能需要通过服务器管理器向服务器添加角色/功能。
  • @kristech 是的,在我使用 .NET Core 3.0 制作新版本之前,同样的应用程序运行良好
  • 在服务器管理器中,单击添加角色和功能。在服务器角色部分中,转到 Web 服务器 (IIS) > Web 服务器 > 安全性。在该部分中安装所有这些角色。之后重新启动服务器,然后重试。
  • @kristech 尽管我使用 Kestrel 进行自我托管,但我尝试了您的建议,但没有奏效。
  • 证书使用什么密码套件?

标签: c# asp.net-core https windows-server-2012-r2 network-protocols


【解决方案1】:

Windows 2012 R2 不支持 HTTP/2 允许的密码套件。我假设从 Core 3.0 开始默认启用 HTTP/2 协议。我通过在 kestrel 中禁用 HTTP/2 解决了我的问题,如下所示:

public static IHostBuilder CreateHostBuilder(string[] args) =>

  Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webBuilder =>
  {
      webBuilder.UseKestrel(options =>
      {
        options.Listen(System.Net.IPAddress.Parse(DomainIp), 80);
        options.Listen(System.Net.IPAddress.Parse(DomainIp), 443, l =>
        {
          l.UseHttps(
            DomainCertificateFile,
            DomainCertificatePassword);
          l.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http1;
        });
      });
      webBuilder.UseStaticWebAssets();
      webBuilder.UseStartup<Startup>();
   });

【讨论】:

  • 这对我有用,但这会产生后果。我的 api 本身发出由于 https 协商错误而失败的带外 https GET 请求
  • @baouss 在我的 Blazor 项目中,我将出站 HTTPS 调用与 HttpClient 一起使用。这适用于 Http1(在 W2012 服务器上)和 Http2(在 Windows 10 上)。
  • 感谢确认它在该设置上工作。我今天才意识到,机器的注册表中禁用了 TLS 1.2,但我调用的服务需要它。
【解决方案2】:

我将添加可能对其他人有用的更多信息。在 IIS 的情况下,HTTP/2 支持从 Windows 10 和 Windows Server 2016 开始。请参阅:HTTP/2 on IIS

但是,您也可能在 Windows 10 中遇到此问题。在这种情况下,建议您确定禁用 HTTP/2 是否真的是您正在寻找的,尤其是在安全问题方面。我们参考一下OP提到的GitHub thread

“这会禁用 HTTP/2,以及“INADEQUATE_TRANSPORT_SECURITY”问题 是一个特定于 HTTP/2 的问题,所以虽然它有效,但它并不是一个真正的问题 解决方案”。

来源:GitHub discussion

要解决在 Windows 10 下发生的此问题,首先建议确保 SSL 密码套件顺序是否正确。

要配置 SSL Cipher Suite Order 组策略设置:

  1. 在命令提示符下,输入 gpedit.msc组策略对象编辑器出现。
  2. 展开计算机配置、管理模板、网络,然后点击SSL 配置设置
  3. SSL 配置设置下,点击SSL 密码套件顺序设置。
  4. SSL Cipher Suite Order 窗格中,滚动到窗格底部。
  5. 按照标有如何修改此设置的说明进行操作。

见:Prioritizing Schannel Cipher Suites

它可能与默认值不同并导致问题。或者,如果默认设置导致问题,您可以在此处进行调整。

回到原来的问题。 @hristijankiko 给我们发了一些 很棒的细节(包括非常有用的 Wireshark 跟踪)。我们 发现服务器正在 HTTP/2 上选择密码套件 由于“安全性不足”而被列入黑名单。原来这是一个 从早期升级导致的机器级配置问题 Windows 版本。修复方法是手动配置 TLS 密码 套件以匹配新的 Windows 10 默认设置 (见https://docs.microsoft.com/en-us/windows/win32/secauthn/tls-cipher-suites-in-windows-10-v1903)。 奇怪的是,即使@hristijankiko 是必要的 使用 Windows 10 v1903,但我们将在此内部进行检查。不 需要在 ASP.NET Core 中对原始问题采取进一步行动。

来源:further GitHub disscussion

您可以在此处查看给定 Windows 版本支持哪些 TLS 密码套件和优先顺序:

Cipher Suites in TLS/SSL (Schannel SSP)

对于 Windows Server 2012 R2 和 Windows 8.1 支持的密码套件,请参阅:

TLS Cipher Suites in Windows 8.1

您可以在开发人员工具的安全选项卡下快速查看选定的密码:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-17
    • 2014-07-31
    • 2018-10-24
    • 1970-01-01
    • 2016-08-01
    相关资源
    最近更新 更多