-
Notifications
You must be signed in to change notification settings - Fork 18.1k
crypto/x509: ParsePKIXPublicKey can not parse 1024bit RSA #23032
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
The difference between both keys are not (only) the length of the prime of the rsa keys but the format. Only the first one is a PKIX key (asn1 sequence of AlgorithmIdentifier+BitString and the real key is in the BitString), the second key is a RSA public key (without the AlgorithmIdentifier). |
@bpressure Removing "RSA" from the identifiers does not make a difference. |
Of cause not, the RSA is an indicator that both keys are serialized in a different way.
the second one with
|
This is working as intended, This StackOverflow post also explains it in more detail. |
Is there another way to parse such a key then? |
@parazyd This issue tracker is not the place for questions, however I will say that you can use the |
|
In Go 1.10, there will be a ParsePKCS1PublicKey that can do this. (They're rare, which is why the function hasn't existed prior to this. Normally they live inside a certificate.) |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.9.2 linux/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?What did you do?
https://play.golang.org/p/MPAwSqN2e7
Running with the former key from the official(?) example found at https://golang.org/pkg/crypto/x509/#ParsePKIXPublicKey works fine. However, when trying the same with a 1024-bit RSA public key, the program panics, being unable to parse it.
What did you expect to see?
pub is of type RSA:
What did you see instead?
The text was updated successfully, but these errors were encountered: