2 #include <openssl/bio.h>
3 #include <openssl/pem.h>
7 char* get_cert_valid_before(const unsigned char* buf, int len, char* datebuf, int datebuf_len)
11 unsigned char *p = (unsigned char*) buf;
12 X509* x = d2i_X509(NULL, &p, len);
14 return "Error calling d2i_X509()!";
17 BIO* out_bio = BIO_new(BIO_s_mem());
18 ASN1_TIME* time = X509_get_notAfter(x);
20 if (ASN1_TIME_print(out_bio, time)) {
21 int write = BIO_read(out_bio, datebuf, datebuf_len - 1);
25 datebuf[datebuf_len - 1] = '\0';