Skip to content

Commit 52da8fb

Browse files
committed
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#46310 Change-Id: Idbab7a6f873f3be78104df6f2908895f4d399bd3 Reviewed-on: https://go-review.googlesource.com/c/net/+/325611 Trust: Filippo Valsorda <filippo@golang.org> Run-TryBot: Filippo Valsorda <filippo@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Roland Shoemaker <roland@golang.org>
1 parent abc4532 commit 52da8fb

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

http2/server.go

+4-8
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)