I am converting ASN1_TIME to std::string in this way:
std::string timeString;
BIO *bmem = BIO_new(BIO_s_mem());
if (ASN1_TIME_print(bmem, asn1Time)) {
BUF_MEM * bptr;
BIO_get_mem_ptr(bmem, &bptr);
timeString.assign(std::string(bptr->data, bptr->length));
}
else { // Log error
}
BIO_free_all(bmem);
Whats wrong with BUF_MEM use? I am getting very large numbers in bptr->length causing exception in std::string construction.