/* * convert an ASN1 time structure to a ctime type date string */ static char *asn1_time_to_ctime(ASN1_TIME *tm) { char *ctimeresult, *a; time_t t; t = asn1_time_to_time(tm); a = ctime(&t); ctimeresult = (char *)malloc(strlen(a) + 1); memcpy(ctimeresult, a, strlen(a) + 1); return ctimeresult; }
static void CheckValidPeriod( X509 *cert) { char buf[256]; long valid; valid = (long)difftime(asn1_time_to_time(X509_get_notAfter(cert)), time(NULL)); if(valid < WARNING_BEFORE_EXPIRATION_PERIOD){ X509_NAME_oneline(X509_get_subject_name(cert),buf,sizeof buf); SSL_Warning(_d("The certificate(%s) will be expired in %d days.\nPlease update the certificate.\n"), buf, valid / (24 * 3600)); } }