What version of Go are you using (go version)?
go version go1.9.2 linux/amd64
Does this issue reproduce with the latest release?
I haven't tested with 1.9.4 or 1.10
What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/conrado/go"
GORACE=""
GOROOT="/usr/lib/go-1.9"
GOTOOLDIR="/usr/lib/go-1.9/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build745436001=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
What did you do?
Generate certificate with OpenSSL:
openssl req -newkey rsa:2048 -keyout test.key -sha256 -sigopt rsa_padding_mode:pss -sigopt rsa_pss_saltlen:32 -sigopt rsa_mgf1_md:sha256 -x509 -days 3650 -nodes -subj '/C=US/ST=CA/L=SF/O=Test/CN=Test' -out test.pem
and parse it with x509.ParseCertificate. The SignatureAlgorithm will be 0 (Unknown), which eventually makes the certification validation fail.
https://play.golang.org/p/CKf-GRBnda1
What did you expect to see?
SignatureAlgorithm should be SHA256-RSAPSS
What did you see instead?
SignatureAlgorithm is 0 (Unknown)
Analysis
The problem is that OpenSSL generates AlgorithmIdentifiers for the PSS hash and MGF with empty parameters, instead of NULL. (Related to what is described here). However, Go only accepts NULL parameters in getSignatureAlgorithmFromAI
According to RFC 4055,
All implementations MUST accept both NULL and absent parameters as legal and equivalent encodings
If it's decided this should be fixed, I can write the patch.
What version of Go are you using (
go version)?go version go1.9.2 linux/amd64Does this issue reproduce with the latest release?
I haven't tested with 1.9.4 or 1.10
What operating system and processor architecture are you using (
go env)?What did you do?
Generate certificate with OpenSSL:
openssl req -newkey rsa:2048 -keyout test.key -sha256 -sigopt rsa_padding_mode:pss -sigopt rsa_pss_saltlen:32 -sigopt rsa_mgf1_md:sha256 -x509 -days 3650 -nodes -subj '/C=US/ST=CA/L=SF/O=Test/CN=Test' -out test.pemand parse it with
x509.ParseCertificate. TheSignatureAlgorithmwill be 0 (Unknown), which eventually makes the certification validation fail.https://play.golang.org/p/CKf-GRBnda1
What did you expect to see?
SignatureAlgorithmshould beSHA256-RSAPSSWhat did you see instead?
SignatureAlgorithmis 0 (Unknown)Analysis
The problem is that OpenSSL generates AlgorithmIdentifiers for the PSS hash and MGF with empty parameters, instead of NULL. (Related to what is described here). However, Go only accepts NULL parameters in
getSignatureAlgorithmFromAIAccording to RFC 4055,
If it's decided this should be fixed, I can write the patch.