Skip to content

Commit 3112343

Browse files
FiloSottiledmitshur
authored andcommitted
[internal-branch.go1.16-vendor] http2: also set "http/1.1" ALPN in ConfigureServer
With CL 289209, we started enforcing ALPN protocol overlap when both sides support ALPN. This means that an "http/1.1"-only ALPN-aware client will fail to connect to a server with only "h2" in NextProtos. Unfortunately, that's how ConfigureServer was setting up the tls.Config. The new behavior mirrors ConfigureTransport on the client side (but not Transport.newTLSConfig because the latter is used to make HTTP/2-only connections). Updates golang/go#49076 Change-Id: Idbab7a6f873f3be78104df6f2908895f4d399bd3 Reviewed-on: https://go-review.googlesource.com/c/net/+/325611 Trust: Filippo Valsorda <[email protected]> Run-TryBot: Filippo Valsorda <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Roland Shoemaker <[email protected]> Reviewed-on: https://go-review.googlesource.com/c/net/+/356974 Trust: Damien Neil <[email protected]> Run-TryBot: Damien Neil <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 63939f4 commit 3112343

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

http2/server.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -265,16 +265,12 @@ func ConfigureServer(s *http.Server, conf *Server) error {
265265

266266
s.TLSConfig.PreferServerCipherSuites = true
267267

268-
haveNPN := false
269-
for _, p := range s.TLSConfig.NextProtos {
270-
if p == NextProtoTLS {
271-
haveNPN = true
272-
break
273-
}
274-
}
275-
if !haveNPN {
268+
if !strSliceContains(s.TLSConfig.NextProtos, NextProtoTLS) {
276269
s.TLSConfig.NextProtos = append(s.TLSConfig.NextProtos, NextProtoTLS)
277270
}
271+
if !strSliceContains(s.TLSConfig.NextProtos, "http/1.1") {
272+
s.TLSConfig.NextProtos = append(s.TLSConfig.NextProtos, "http/1.1")
273+
}
278274

279275
if s.TLSNextProto == nil {
280276
s.TLSNextProto = map[string]func(*http.Server, *tls.Conn, http.Handler){}

0 commit comments

Comments
 (0)