From: Reinhard Tartler Date: Sun, 12 Oct 2025 06:31:58 -0400 Subject: Fix compilation with golang 1.25.2 Bug-Upstream: https://github.com/etcd-io/etcd/pull/20775 Forwarded: not-needed --- client/pkg/transport/listener.go | 30 +++++++++++++++++++++++- server/etcdmain/grpc_proxy.go | 2 +- server/etcdserver/api/v2http/client_auth_test.go | 1 + 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/client/pkg/transport/listener.go b/client/pkg/transport/listener.go index a7d3768..66dcc20 100644 --- a/client/pkg/transport/listener.go +++ b/client/pkg/transport/listener.go @@ -285,7 +285,7 @@ func SelfCert(lg *zap.Logger, dirpath string, hosts []string, selfSignedCertVali } for _, host := range hosts { - h, _, _ := net.SplitHostPort(host) + h, _, _ := splitHostPort(host) if ip := net.ParseIP(h); ip != nil { tmpl.IPAddresses = append(tmpl.IPAddresses, ip) } else { @@ -353,6 +353,34 @@ func SelfCert(lg *zap.Logger, dirpath string, hosts []string, selfSignedCertVali return SelfCert(lg, dirpath, hosts, selfSignedCertValidity) } +func splitHostPort(host string) (string, string, error) { + if !containsPort(host) { + host = host + ":" + } + return net.SplitHostPort(host) +} + +func containsPort(hostport string) bool { + if hostport == "" { + return false + } + + if hostport[0] == '[' { + end := strings.IndexByte(hostport, ']') + return len(hostport) > end+1 && hostport[end+1] == ':' + } + + colon := strings.LastIndexByte(hostport, ':') + if colon < 0 { + return false + } + + if strings.Contains(hostport[:colon], ":") { + return false + } + return true +} + // baseConfig is called on initial TLS handshake start. // // Previously, diff --git a/server/etcdmain/grpc_proxy.go b/server/etcdmain/grpc_proxy.go index 4ff5060..9227c03 100644 --- a/server/etcdmain/grpc_proxy.go +++ b/server/etcdmain/grpc_proxy.go @@ -203,7 +203,7 @@ func startGRPCProxy(cmd *cobra.Command, args []string) { // Please see https://github.com/etcd-io/etcd/issues/11970#issuecomment-687875315 for more context. tlsInfo := newTLS(grpcProxyListenCA, grpcProxyListenCert, grpcProxyListenKey, false) if tlsInfo == nil && grpcProxyListenAutoTLS { - host := []string{"https://" + grpcProxyListenAddr} + host := []string{grpcProxyListenAddr} dir := filepath.Join(grpcProxyDataDir, "fixtures", "proxy") autoTLS, err := transport.SelfCert(lg, dir, host, selfSignedCertValidity) if err != nil { diff --git a/server/etcdserver/api/v2http/client_auth_test.go b/server/etcdserver/api/v2http/client_auth_test.go index 157003f..db8983b 100644 --- a/server/etcdserver/api/v2http/client_auth_test.go +++ b/server/etcdserver/api/v2http/client_auth_test.go @@ -766,6 +766,7 @@ func TestPrefixAccess(t *testing.T) { } func TestUserFromClientCertificate(t *testing.T) { + t.Skip("This test uses pre-generated certs from testdata/*.pem that no longer parse correctly with golang 1.25.2, cf. https://github.com/golang/go/commit/3fc4c79fdbb17b9b29ea9f8c29dd780df075d4c4") witherror := &mockAuthStore{ users: map[string]*v2auth.User{ "user": {