Open
Description
Go version
go1.23.4
Output of go env
in your module/workspace:
N/A
What did you do?
I was validating a Box-generated private key using ssh.ParseRawPrivateKey
and encountered an unexpected error.
Reproducer: https://go.dev/play/p/mX6cEyGa7FO
( The private key is inert and was generated with: openssl genpkey -algorithm RSA -aes256 -out encrypted_private_key.pem
)
What did you see happen?
The function fails due to "ENCRYPTED PRIVATE KEY" not being a supported key type.
panic: ssh: unsupported key type "ENCRYPTED PRIVATE KEY"
What did you expect to see?
The function should actually return PassphraseMissingError
, per the documentation:
If the private key is encrypted, it will return a PassphraseMissingError.
https://github.com/golang/crypto/blob/b4f1988a35dee11ec3e05d6bf3e90b695fbd8909/ssh/keys.go#L1230-L1233