Reputation: 3274
I am able to retrieve the public key contents from a cert file using openssl by following the link http://fm4dd.com/openssl/certpubkey.htm
However, it prints the public key to stdout. I want to be able to store it in a string . Is there a way to get it into a char buffer or a string ?
The line PEM_write_bio_PUBKEY(outbio, pkey)
prints to stdout.
Searched quite a bit, wasnt able to get what I wanted.
Any help will be appreciated, better if the code sample is provided as I'm running out of time.
Thanks in advance.
Upvotes: 0
Views: 1778
Reputation: 3274
I found a solution finally ! X509 structure to human readable string
Just replaced with EVP_PKEY *key
in X509_to_PEM()
signature and used PEM_write_bio_PUBKEY(bio, key)
instead of PEM_write_bio_X509(bio, cert)
.
Worked !
Upvotes: 2