golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.88k stars 17.52k forks source link

crypto: Many APIs return errors caused by other errors, without allowing unwrapping #58365

Open dcormier opened 1 year ago

dcormier commented 1 year ago

What version of Go are you using (go version)?

$ go version
go version go1.20 darwin/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="/Users/me/Library/Caches/go-build"
GOENV="/Users/me/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/me/go/pkg/mod"
GONOPROXY="redacted"
GONOSUMDB="redacted"
GOOS="darwin"
GOPATH="/Users/me/go"
GOPRIVATE="redacted"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.20"
GCCGO="gccgo"
GOAMD64="v1"
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"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/vd/0rnst0yj2md0t7ss9__mr1540000gs/T/go-build2389605252=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Attempted to check errors for specific certificate issues in errors returned from tls.Conn.Read().

What did you expect to see?

errors that could be unwrapped to expose child errors.

What did you see instead?

errors flattened to strings, so the only solution was to parse the error value.


I have an existing PR to wrap child errors rather than flatten them to strings: #58299.

Here are some notes about each of those changes (as requested):


All of these would happen during the TLS client connection handshake:


All of these would happen during the TLS server connection handshake:



gopherbot commented 1 year ago

Change https://go.dev/cl/465136 mentions this issue: crypto: support errors.Unwrap() for more crypto errors

seankhliao commented 1 year ago

cc @golang/security