web-dev-qa-db-fra.com

L'application ASP.NET Core 3.0 ne fonctionne pas sur Windows Server 2012 R2 en raison de ERR_HTTP2_INADEQUATE_TRANSPORT_SECURITY

J'ai pris une application ASP.NET Core 2.2 fonctionnelle, je l'ai mise à niveau vers 3.0 et soudain, l'application ne fonctionne plus dans Windows Server 2012. Elle propose les éléments suivants:

ERR_HTTP2_INADEQUATE_TRANSPORT_SECURITY

Chrome: enter image description here

Firefox: enter image description here

Il semble qu'avant je devais opter pour HTTP/2 et maintenant c'est la valeur par défaut avec HTTP1.1. Il y a un post ici https://github.com/aspnet/AspNetCore/issues/14350 mais c'est totalement déroutant sans réelle solution.

J'ai essayé toutes sortes de protocoles d'activation/désactivation non sécurisés, mais en vain. Tels que https://www.admin-enclave.com/de/articles-by-year/11-data-articles/website_articles/articles/exchange_articles/405-resolved-error-err_spdy_inorrectate_transport_security-when-using- google-chome-and-owa.html

Fonctionne bien sur Windows 10 en raison de ce que je suppose être une meilleure suite de protocoles. Mais dans Fiddler, j'ai vérifié et la seule différence lors de la négociation avec Kestrel est:

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

La ligne du haut est différente, mais c'est tout. Je ne sais pas ce que c'est, c'est une valeur GREASE.

Program.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>();
  }

Mettre à jour

Il me semble que je suis sur la bonne voie grâce à @ chris-pratt. Modification du chiffrement du certificat en ECDSA_nistP256 faire fonctionner l'application web. Mais malheureusement, j'utilise le certificat pour signer également les jetons JWT, et maintenant cela est rompu avec:

System.NotSupportedException: l'algorithme de clé de certificat n'est pas pris en charge. à System.Security.Cryptography.X509Certificates.PublicKey.get_Key ()

Le code de signature est:

  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);

J'ai essayé de changer l'énumération SecurityAlgorithms mais je n'ai pas réussi.

6
Colton Scottie

Windows 2012 R2 ne prend pas en charge les suites de chiffrement autorisées pour HTTP/2. Je suppose qu'à partir de Core 3.0, le protocole HTTP/2 est activé par défaut. J'ai résolu mon problème en désactivant HTTP/2 dans Kestrel comme suit:

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>();
   });
1
Frankenstein