-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
Go version
go version go1.21.11 linux/amd64
Output of go env in your module/workspace:
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/.cache/go-build'
GOENV='/home/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/dn/sdk/go1.21.11'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/sdk/go1.21.11/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.11'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
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'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3756811533=/tmp/go-build -gno-record-gcc-switches'What did you do?
I ran a server configured with multiple client authentication modes, one of which is verify-if-given using VerifyClientCertIfGiven. To test its behavior, I used a client that presented an invalid certificate—meaning the certificate could not be verified by the server's stored CA. Given that I expected the TLS handshake to fail.
What did you see happen?
The TLS handshake did not fail. Instead it continued to the application authentication logic, and when I checked the certificate metadata, I noticed that len(tlsInfo.State.PeerCertificates) was equal to zero, treating it like certificate not provided at all.
What did you expect to see?
Per the official docs Im expecting that it should be return and failed (and not fallback) since once client provide a certificate it should be a valid one to the stored CA:
// VerifyClientCertIfGiven indicates that a client certificate should be requested
// during the handshake, but does not require that the client sends a
// certificate. If the client does send a certificate it is required to be
// valid.
VerifyClientCertIfGiven