-
Notifications
You must be signed in to change notification settings - Fork 18k
x/crypto/pkcs12: PKCS12 Decode requires privateKey and certificate #23499
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
Comments
I saw that |
Can the nil-ability of returning a privateKey or cert be changed? It would be easy enough to remove the check, but there's probably a reason to requiring both? |
cc @agl |
PKCS#12, as a format, is designed to be a super-abstract, anything-container with various bits being encrypted or not. As such it's only actually usable in contexts where there are expectations of the internal structure of the data contained. x/crypto/pkcs12 is designed for a somewhat common situation where a private key and certificate are provided together in a single PKCS#12 file. It's not intended to be a general PKCS#12 processor. |
@agl Sounds good. I'll fork x/crypto/pkcs12 for my project, thanks! |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, but it's
x/crypto/pkcs12
.What operating system and processor architecture are you using (
go env
)?What did you do?
I'm trying to list certificates from various windows stores. (e.g.
My
andRoot
) When I attempt to read an exported PKCS12 / PFX filex/crypto/pkcs12
fails.pkcs12.Decode()
currently requires two items are decoded, a private key and certificate. I get the following error:This seems to come from a runtime check in the decoding routines, but I'm not totally sure why it's required.
https://github.com/golang/crypto/blob/459e26527287adbc2adcc5d0d49abff9a5f315a7/pkcs12/pkcs12.go#L311-L313
FWIW openssl doesn't have a problem showing this certificate.
openssl x509 -inform pem -in thing -noout -text
The text was updated successfully, but these errors were encountered: