Created
February 4, 2020 06:00
-
-
Save aovestdipaperino/25c28be3df3c4c89cdd6b79bd4b2a76a to your computer and use it in GitHub Desktop.
Read X509 Certificate expiration date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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