Skip to content

Commit c9f4fb0

Browse files
FiloSottiledmitshur
authored andcommitted
[internal-branch.go1.17-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#49077 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/+/357669 Trust: Damien Neil <[email protected]> Run-TryBot: Damien Neil <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 6d2eada commit c9f4fb0

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
@@ -259,16 +259,12 @@ func ConfigureServer(s *http.Server, conf *Server) error {
259259

260260
s.TLSConfig.PreferServerCipherSuites = true
261261

262-
haveNPN := false
263-
for _, p := range s.TLSConfig.NextProtos {
264-
if p == NextProtoTLS {
265-
haveNPN = true
266-
break
267-
}
268-
}
269-
if !haveNPN {
262+
if !strSliceContains(s.TLSConfig.NextProtos, NextProtoTLS) {
270263
s.TLSConfig.NextProtos = append(s.TLSConfig.NextProtos, NextProtoTLS)
271264
}
265+
if !strSliceContains(s.TLSConfig.NextProtos, "http/1.1") {
266+
s.TLSConfig.NextProtos = append(s.TLSConfig.NextProtos, "http/1.1")
267+
}
272268

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

0 commit comments

Comments
 (0)