diff --git a/zkey/plugin-utils.c b/zkey/plugin-utils.c index e0d8d0f1..537c8c96 100644 --- a/zkey/plugin-utils.c +++ b/zkey/plugin-utils.c @@ -27,6 +27,18 @@ #include "properties.h" #include "utils.h" +#ifndef OPENSSL_VERSION_PREREQ + #if defined(OPENSSL_VERSION_MAJOR) && defined(OPENSSL_VERSION_MINOR) + #define OPENSSL_VERSION_PREREQ(maj, min) \ + ((OPENSSL_VERSION_MAJOR << 16) + \ + OPENSSL_VERSION_MINOR >= ((maj) << 16) + (min)) + #else + #define OPENSSL_VERSION_PREREQ(maj, min) \ + (OPENSSL_VERSION_NUMBER >= (((maj) << 28) | \ + ((min) << 20))) + #endif +#endif + /** * Initializes the plugin and setup the plugin data structure * @@ -377,8 +389,12 @@ int plugin_check_certificate(struct plugin_data *pd, const char *cert_file, *self_signed = (X509_NAME_cmp(X509_get_subject_name(cert), X509_get_issuer_name(cert)) == 0); +#if OPENSSL_VERSION_PREREQ(4, 0) + *valid = X509_check_certificate_times(NULL, cert, NULL); +#else *valid = (X509_cmp_current_time(X509_get0_notBefore(cert)) < 0 && X509_cmp_current_time(X509_get0_notAfter(cert)) > 0); +#endif X509_free(cert);