void
tls_ctx_check_cert_time (const struct tls_root_ctx *ctx)
{
-#if OPENSSL_VERSION_NUMBER >= 0x10002000L
int ret;
- const X509 *cert = SSL_CTX_get0_certificate(ctx->ctx);
+ const X509 *cert;
+
+#if OPENSSL_VERSION_NUMBER >= 0x10002000L
+ /* OpenSSL 1.0.2 and up */
+ cert = SSL_CTX_get0_certificate(ctx->ctx);
+#else
+ /* OpenSSL 1.0.1 and earlier need an SSL object to get at the certificate */
+ SSL *ssl = SSL_new(ctx->ctx);
+ cert = SSL_get_certificate(ssl);
+#endif
ret = X509_cmp_time (X509_get_notBefore (cert), NULL);
if (ret == 0)
{
msg (M_WARN, "WARNING: Your certificate has expired!");
}
+#if OPENSSL_VERSION_NUMBER < 0x10002000L
+ SSL_free(ssl);
#endif
}