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.
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 !
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.