Change use of AllowRenegotiation in HttpConnectionPool (dotnet/corefx#38127)
authorStephen Toub <stoub@microsoft.com>
Sat, 1 Jun 2019 19:27:50 +0000 (15:27 -0400)
committerGitHub <noreply@github.com>
Sat, 1 Jun 2019 19:27:50 +0000 (15:27 -0400)
* Change use of AllowRenegotation in HttpConnectionPool

* Address PR feedback

Fix typos in comments

Co-Authored-By: David Shulman <david.shulman@microsoft.com>
Commit migrated from https://github.com/dotnet/corefx/commit/cada442a1385e4ecaf9139eb9f98e522776043e2

src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs

index 624de5c..3c19f2d 100644 (file)
@@ -155,7 +155,20 @@ namespace System.Net.Http
                 {
                     _sslOptionsHttp2 = ConstructSslOptions(poolManager, sslHostName);
                     _sslOptionsHttp2.ApplicationProtocols = Http2ApplicationProtocols;
-                    _sslOptionsHttp2.AllowRenegotiation = false;
+                    
+                    // Note:
+                    // The HTTP/2 specification states:
+                    //   "A deployment of HTTP/2 over TLS 1.2 MUST disable renegotiation.
+                    //    An endpoint MUST treat a TLS renegotiation as a connection error (Section 5.4.1)
+                    //    of type PROTOCOL_ERROR."
+                    // which suggests we should do:
+                    //   _sslOptionsHttp2.AllowRenegotiation = false;
+                    // However, if AllowRenegotiation is set to false, that will also prevent
+                    // renegotation if the server denies the HTTP/2 request and causes a
+                    // downgrade to HTTP/1.1, and the current APIs don't provide a mechanism
+                    // by which AllowRenegotiation could be set back to true in that case.
+                    // For now, if an HTTP/2 server erroneously issues a renegotiation, we'll
+                    // allow it.
 
                     Debug.Assert(hostHeader != null);
                     _encodedAuthorityHostHeader = HPackEncoder.EncodeLiteralHeaderFieldWithoutIndexingToAllocatedArray(StaticTable.Authority, hostHeader);