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

failed to load public key: PEM_read_bio_PUBKEY failed #17

Closed
dantti opened this issue Apr 17, 2019 · 4 comments
Closed

failed to load public key: PEM_read_bio_PUBKEY failed #17

dantti opened this issue Apr 17, 2019 · 4 comments

Comments

@dantti
Copy link

dantti commented Apr 17, 2019

Hi,

I tried to change the sources to use PEM_read_bio_RSA_PUBKEY or PEM_read_bio_RSAPublicKey, to no effect, I'm trying to verify the signature of this token.
Tried to change CERTIFICATE to PUBLIC KEY, but no luck, any tips?

Thanks

@Thalhammer
Copy link
Owner

A certificate is a superset of a public key. Amongst the public key, it also contains information like the issuer, expected uses and so on. You can use openssl to extract the public key like so:

openssl x509 -pubkey -noout -in google_cert.pem > pubkey.pem

The extracted public key works fine, I just tried it.

@dantti
Copy link
Author

dantti commented Apr 17, 2019

It indeed works, thanks, do you happen to have a code snippet to do the above without resorting to command line?

@Thalhammer
Copy link
Owner

I have not tried it, but this:
http://fm4dd.com/openssl/certpubkey.htm
and this:
https://www.openssl.org/docs/manmaster/man3/BIO_s_mem.html
Looks like a good solution.

@dantti
Copy link
Author

dantti commented Apr 17, 2019

Thanks, perhaps consider having this build-in? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants