Skip to content

Commit 1b9dfe1

Browse files
committed
fix: expose ALPN in TLS handshake
New versions of gRPC-go are enforcing the `h2` ALPN to be presented during the TLS handshake. See https://pkg.go.dev/google.golang.org/grpc/internal/envconfig#pkg-variables `GRPC_ENFORCE_ALPN_ENABLED`. The TLS server here isn't automatically getting this set due to usage of GetConfigForClient. This properly sets it. Without this, istio-csr will be incompatible with Istio 1.24, which upgrades the gRPC version. Note this can be worked around by setting `GRPC_ENFORCE_ALPN_ENABLED=false` on the proxy container, which Istio is able to do -- so there is an escape hatch for users. The Istio logs look like `"transport: authentication handshake failed: credentials: cannot check peer: missing selected ALPN property"`
1 parent 48b06ca commit 1b9dfe1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pkg/tls/tls.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,9 @@ func (p *Provider) fetchCertificate(ctx context.Context) (time.Time, error) {
427427
p.tlsConfig = &tls.Config{
428428
MinVersion: tls.VersionTLS12,
429429
Certificates: []tls.Certificate{tlsCert},
430+
// Advertise ALPN, required in modern gRPC versions
431+
// Typically gRPC sets this for us, but since this tls.Config ultimately gets returned in GetConfigForClient it doesn't.
432+
NextProtos: []string{"h2"},
430433
ClientAuth: tls.VerifyClientCertIfGiven,
431434
ClientCAs: peerCertVerifier.GetGeneralCertPool(),
432435
VerifyPeerCertificate: func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error {

0 commit comments

Comments
 (0)