golang / go

The Go programming language

Home Page:https://go.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

encoding/asn1: cannot marshal into a GeneralString

jcmturner opened this issue · comments

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

go version go1.7.5 linux/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GORACE=""
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build372878858=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1

The issue

Using "encoding/asn1" it is not possible to marshal into a an asn1 general string. It is possible to unmarshal from one but it is only possible to marshal into one of ia5, printable or utf8.
https://play.golang.org/p/cwv9ZGV5K5

Suggestion

There should be an struct tag such as "generalstring" that works in the same way as the "ia5" tag but sets the asn1 tag value of 27.

Change https://golang.org/cl/134223 mentions this issue: encoding/asn1: add ability to marshal to general string