Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto/x509 does not read RSA-PSS private key files #50532

Closed
yaronf opened this issue Jan 10, 2022 · 1 comment
Closed

crypto/x509 does not read RSA-PSS private key files #50532

yaronf opened this issue Jan 10, 2022 · 1 comment

Comments

@yaronf
Copy link

yaronf commented Jan 10, 2022

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

$ go version
go version go1.17.6 darwin/amd64

Does this issue reproduce with the latest release?

This is the latest.

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/ysheffer/Library/Caches/go-build"
GOENV="/Users/ysheffer/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/ysheffer/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/ysheffer/go"
GOPRIVATE=""
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.17.6"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
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 -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/v9/906yb8jd2yn9y2zp4trp6vt5d540vs/T/go-build1621945842=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Trying to read a PKCS#8 private key with the RSA-PSS algorithm , as generated by openssl.

openssl genpkey -algorithm RSA-PSS -outform PEM -out priv-op.key

Sample key:

-----BEGIN PRIVATE KEY-----
MIIEuwIBADALBgkqhkiG9w0BAQoEggSnMIIEowIBAAKCAQEA5fGYBv14nELM/akt
bhdD8973g3mg0sWNDiO+zBLLWSeZ8GL2WueEprhZnDaCTpauEJQO94l0NzVNAREj
Iw4zEPgAMS+a/TzJsUL7GzdJeiP/sG/VW8wD+XOtSW/a2p680v0S4lJ+ZalnJRwQ
kWcxSdb5++BS8rgTyWXiSugMZbEvSFS1tBVYHKBVAZfLagWA++C6mh/+n3r5sENk
omB5gWvKKYmLYm/Dmuw++UfO9+Z2mLfwlAJLawCea5P0Z+NMRdCDJ+Jrf8NgC0JB
vIelXbpWb2ZJQVAMYjOZ8p6Bxa6gpj0hC4RmU0Jx9epV08sOhvllm0H9I0M7UjkJ
Q9gKbQIDAQABAoIBAAPQy/yFtTwmkZ898O6MPUjtML9CQ+xrcclDx5U8VJqAoTnP
cpYUlGtt0LLaZrQmJPJKeqsZ4U9PN51mauZYhHlqHBq01wYPvasO2PrdIn9/3GzR
lkFFM+WuSThYPlH1Y12+7FLMGqPWOUtw2UeIZlV610AaO1YivtVPNv+WNSp0y62X
7jOZAeBXRYxUgQoVbwc+ZK3xz/2e80yfIVkadkQGI9/3M8WNefgxD9im3M2bzfwZ
rxiTghIv/QJD4Q0kaxrm10uDm0t2EvhQPVd1GkE1ssUNYeot8GVNqVE3a18M37Z4
1o0HUHVWrIbg0b1N9CdeGpzATC3CxARH1RmVKTMCgYEA+K6syCYOGjEM8F0jeR2w
8fvmVbdIDb6njKBkVOAm424HnPqeKgEze2MdZHjbGrUDNv8Q0ncU5lSmirvwoqF6
9Y1GMQxRt7MJSsF5IuQLL0qpj4OH57hUDH48+epajVg+xYPQ4lqiyezyJpxX+UXH
GUOaAMZzZokkUkFrD693soMCgYEA7LXCz+Mx2xZENNTvWZMxVu6xymH2cNXGnYm1
Zwm22d/6YxDFElekrYTlFxFD/Xpq0XRNQ/OW97Jo3GyxQFmoqb4VwBMdKjDr4w5q
N4Q5rLtjpLqiPlPvgWwhUn74XrgAcuM0kRz2cnZKNJ8NNr5YXA7vWNwgK/N4EAOK
NQnl/E8CgYByMFr8SKUfF7jWQh5AxgZzBvT8FP3L+eibpSaM5qRUuDhct6OarBSE
qr1bXjdVqxp/zV1fFvkMzn/uol/bfYSlbip16S84x8gTgIVsJQSRwZncYUwtdbF6
TxkWtKrBzmx8a4ul9HJdgCSs4AtxVb4XdrgndPiWc5CvCITtnee7mwKBgQCgtoee
PdMLvQJyHGCloJpPO6Dal8iKs5o2O9k+LApJwxhtSmWDHp5gcWpZTw+qegMsUppj
GG/XnPo1LlbqKfWpybVaw595ld2SO6dCKjQ+Yrw0i8K8LqDeblvxduOK68LiPgDi
xZdN/6JCN/rwwCud1UYMPuhY7uUFemHLwPy1YQKBgD30VAYj7+Ak9hRVmgufjl/m
VoLV9dsaoyv/zsRRh3VrEGeYCsrr2Oip99mdJArqNFs4OnE3XxHygiVTSBZringQ
Xws3RbLWEZqoxcjI0EpbE05SltsfcuovHIifA89mZ4YavSuRDz9Gj9it3f0s/wi6
hS+ykvc8WRpCcI3OSYOi
-----END PRIVATE KEY-----

What did you expect to see?

After PEM decoding, x509.ParsePKCS8PrivateKey should succeed.

What did you see instead?

cannot parse private key: x509: PKCS#8 wrapping contained private key with unknown algorithm: 1.2.840.113549.1.1.10

Related unresolved issue: #23847.

@yaronf yaronf changed the title affected/package: crypto.x509 crypto.x509 does not read RSA-PSS private key files Jan 10, 2022
@yaronf yaronf changed the title crypto.x509 does not read RSA-PSS private key files crypto/x509 does not read RSA-PSS private key files Jan 10, 2022
@seankhliao
Copy link
Member

Duplicate of #48314

@seankhliao seankhliao marked this as a duplicate of #48314 Jan 10, 2022
@golang golang locked and limited conversation to collaborators Jan 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants