golang / go

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

proposal: encoding/asn1: timeParsing functions impose static formats #29069

Open ChrisPortman opened 5 years ago

ChrisPortman commented 5 years ago

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

$ go version
go version go1.11.2 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
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/chris/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/chris/Optus/Git/gorims"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build723180761=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Attempt to unmarshal generalized time received from a 3rd party system that used a format other than the one hard coded in the parseGeneralizedTime([]byte) (time.Time, error) function.

What did you expect to see?

A way to nominate the time format to be used

What did you see instead?

That the time format is hardcoded as a const within the time parsing funcs.

gopherbot commented 5 years ago

Change https://golang.org/cl/152117 mentions this issue: encoding/asn1: allow the user to specify the time format used to unmarshal

robpike commented 5 years ago

Wrong CL listed above; it should be https://go-review.googlesource.com/c/go/+/152117/

Meanwhile, there are questions about this idea, including whether it should happen at all. I have added the Proposal label to trigger a discussion about the role of this package vs. the crypto on.