Go version
go version go1.22.8 darwin/amd64
Output of go env in your module/workspace:
GO111MODULE='on'
GOARCH='arm64'
GOBIN='/Users/jack/src/bin'
GOCACHE='/Users/jack/Library/Caches/go-build'
GOENV='/Users/jack/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOMODCACHE='/Users/jack/src/pkg/mod'
GOOS='darwin'
GOPATH='/Users/jack/src'
GOPROXY='https://goproxy.cn,direct'
GOROOT='/Users/jack/go/go1.22.8'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/jack/go/go1.22.8/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.8'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
What did you do?
I start a service with multiple domains, use GetConfigForClient function for providing TLS certificates dynamically depends on the request's servername. Start go1.6 has enable http2 by default, and it will add supported application level protocols,such as "h2","http/1.1", but the tls.Config from GetConfigForClient did not do this.
// readClientHello reads a ClientHello message and selects the protocol version.
func (c *Conn) readClientHello(ctx context.Context) (*clientHelloMsg, error) {
// clientHelloMsg is included in the transcript, but we haven't initialized
// it yet. The respective handshake functions will record it themselves.
msg, err := c.readHandshake(nil)
if err != nil {
return nil, err
}
clientHello, ok := msg.(*clientHelloMsg)
if !ok {
c.sendAlert(alertUnexpectedMessage)
return nil, unexpectedMessageError(clientHello, msg)
}
var configForClient *Config
originalConfig := c.config
if c.config.**GetConfigForClient** != nil {
chi := clientHelloInfo(ctx, c, clientHello)
if configForClient, err = c.config.**GetConfigForClient**(chi); err != nil {
c.sendAlert(alertInternalError)
return nil, err
} else if configForClient != nil {
c.config = configForClient
}
}
this leads to the client request offers h2,http/1.1, but server only accepted http/1.1 only
What did you see happen?
IPv4: xx.xx.xxx.xx
* Trying xx.xx.xxx.xx:443...
* ALPN: curl offers h2,http/1.1
} [5 bytes data]
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* CAfile: ca.pem
* CApath: none
{ [5 bytes data]
* TLSv1.3 (IN), TLS handshake, Server hello (2):
{ [122 bytes data]
* TLSv1.3 (IN), TLS change cipher, Change cipher spec (1):
{ [1 bytes data]
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
{ [25 bytes data]
* TLSv1.3 (IN), TLS handshake, Request CERT (13):
{ [229 bytes data]
* TLSv1.3 (IN), TLS handshake, Certificate (11):
{ [1035 bytes data]
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
{ [264 bytes data]
* TLSv1.3 (IN), TLS handshake, Finished (20):
{ [52 bytes data]
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
} [1 bytes data]
* TLSv1.3 (OUT), TLS handshake, Certificate (11):
} [2087 bytes data]
* TLSv1.3 (OUT), TLS handshake, CERT verify (15):
} [264 bytes data]
* TLSv1.3 (OUT), TLS handshake, Finished (20):
} [52 bytes data]
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 / x25519 / RSASSA-PSS
* ALPN: server accepted http/1.1
What did you expect to see?
if the NextProtos of tls.Config is empty, should copy from originalConfig, It should be consistent with the default
Go version
go version go1.22.8 darwin/amd64
Output of
go envin your module/workspace:What did you do?
I start a service with multiple domains, use GetConfigForClient function for providing TLS certificates dynamically depends on the request's servername. Start go1.6 has enable http2 by default, and it will add supported application level protocols,such as "h2","http/1.1", but the tls.Config from GetConfigForClient did not do this.
this leads to the client request offers h2,http/1.1, but server only accepted http/1.1 only
What did you see happen?
What did you expect to see?
if the NextProtos of tls.Config is empty, should copy from originalConfig, It should be consistent with the default