What version of Go are you using (go version)?
$ go version
go version go1.17.7 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/dev/.cache/go-build"
GOENV="/home/dev/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/dev/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/dev/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/dev/Downloads/1.17.7/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/dev/Downloads/1.17.7/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.7"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build678374455=/tmp/go-build -gno-record-gcc-switches"
What did you do?
To demonstrate this I included verify.go and three certificates in the file verify_cert.tar.gz
We have a testing pipeline that checks the handling of x509 certificates. The host.pem included in verify_cert.tar.gz is a malformed certificate. Since it is not compliant to spec, parsing the certificate should result in error. With golang version 1.15.15 and 1.16.14, x509.ParseCertificate returns error, which is expected. However, after upgrade golang version to 1.17.7, this malformed certificate is now accepted.
What did you expect to see?
With go 1.15.15
$ go run verify.go root.pem intermediate.pem host.pem
panic: failed to parse certificate: x509: cannot parse URI "g\x81\x05\x05\x01\x01": parse "g\x81\x05\x05\x01\x01": net/url: invalid control character in URL
goroutine 1 [running]:
main.main()
/home/dev/shared/verify.go:47 +0x4f7
exit status 2
With go 1.16.14
$ go run verify.go root.pem intermediate.pem host.pem
panic: failed to parse certificate: x509: SAN uniformResourceIdentifier is malformed
goroutine 1 [running]:
main.main()
/home/dev/shared/verify.go:47 +0x4f7
exit status 2
What did you see instead?
With go 1.17.7, no error is returned.
$ go run verify.go root.pem intermediate.pem host.pem
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env)?go envOutputWhat did you do?
To demonstrate this I included verify.go and three certificates in the file verify_cert.tar.gz
We have a testing pipeline that checks the handling of x509 certificates. The host.pem included in verify_cert.tar.gz is a malformed certificate. Since it is not compliant to spec, parsing the certificate should result in error. With golang version 1.15.15 and 1.16.14,
x509.ParseCertificatereturns error, which is expected. However, after upgrade golang version to 1.17.7, this malformed certificate is now accepted.What did you expect to see?
With go 1.15.15
With go 1.16.14
What did you see instead?
With go 1.17.7, no error is returned.