-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net/http: go1.24 breaks compatibility by modifying in-place the tls.Config{NextProtos}
#72100
Comments
tls.Config{NextProtos}
tls.Config{NextProtos}
The problem can also be summarised by this tiny example: https://go.dev/play/p/eg_dXkGompq |
CC @neild |
Thanks. I agree that this is a regression. |
Change https://go.dev/cl/654875 mentions this issue: |
@gopherbot please backport to go 1.24, this is a regression |
Backport issue(s) opened: #72103 (for 1.24). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases. |
Go version
go version go1.24.0 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
Setup:
Run the following program locally: https://go.dev/play/p/sqxPDLLHzwX
Simulate a client connecting on the gRPC port with TLS1.3, ALPN H2:
Observe the following error:
Repeat the same test using Go 1.23 or older, TLS handshake will happen successfully.
What did you see happen?
net/http server added
Protocols
to control the allowed protocols. The server modifies the TLS ConfigNextProtos
based on this field (func adjustNextProtos
).This is a different behaviour than before and cause issue when two servers (in my example net/http and gRPC server) utilise the same TLS Config. The TLS Config is soft-cloned in both server, but net/http use
slices.DeleteFunc
which delete in-place values from the slice, thus reflecting the same change on the gRPC server.In the example I shared, h2 is disabled on the net/http server (using the old way), and so
adjustNextProtos
removes it from the TLS ConfigNextProtos
. On the other side, gRPC server appendh2
if it's not already present. Because the TLS Config is a shallow clone, the outcome is racy.What did you expect to see?
The expectation is that the gRPC server has h2 set in the NextProtos and so that the ALPN negotiation works correctly. This was the case up until Go 1.24.
The text was updated successfully, but these errors were encountered: