I want to convert X509 data to string format in C++. I tried following method but I can only print one line rather than whole data. Can someone please help me out? Any help will be much appreciated. Please find sample code:
BIO *bio; string issuer;
bio = BIO_new(BIO_s_mem());
if(bio == NULL) {
throw f5util::Exception("BIO_new failed..");
}
// my_Issuer is actually X509 *.
if(PEM_write_bio_X509(bio, my_Issuer) == 0) {
BIO_free(bio);
throw f5util::Exception("PEM_write_bio_x509() failed..");
}
issuer.resize(bio->num_write);
int bio_len = BIO_read(bio, &issuer[0], bio->num_write);
issuer.resize(bio_len);
// here I tried to print the string output and I got only first line
// i.e. "---------BEGIN CERTIFICATE-----------"
BIO_free(bio);
I will also welcome any alternate approach/suggestions.