Skip to content

Instantly share code, notes, and snippets.

@aovestdipaperino
Created February 4, 2020 06:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aovestdipaperino/25c28be3df3c4c89cdd6b79bd4b2a76a to your computer and use it in GitHub Desktop.
Save aovestdipaperino/25c28be3df3c4c89cdd6b79bd4b2a76a to your computer and use it in GitHub Desktop.
Read X509 Certificate expiration date
char buf[32];
std::string ReadExpirationDate(X509* certificate)
{
std::string timeString;
BIO* bmem = BIO_new(BIO_s_mem());
if (ASN1_TIME_print(bmem, X509_get_notAfter(certificate))) {
BUF_MEM* bptr;
BIO_get_mem_ptr(bmem, &bptr);
timeString.assign(std::string(bptr->data, bptr->length));
}
else { // Log error
}
BIO_free_all(bmem);
return timeString;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment