From fcb0b3c9a80e1ed54556b8cfb4ef34c0d330ff73 Mon Sep 17 00:00:00 2001 From: Alberto Leiva Popper Date: Mon, 6 May 2024 15:54:16 -0600 Subject: [PATCH] Fix compilation in OpenSSL < 3 and LibreSSL --- src/libcrypto_util.c | 9 ++++++++- src/libcrypto_util.h | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/libcrypto_util.c b/src/libcrypto_util.c index 462e79f3..82a68102 100644 --- a/src/libcrypto_util.c +++ b/src/libcrypto_util.c @@ -2,6 +2,7 @@ #include #include +#include #include "alloc.h" #include "extension.h" @@ -90,6 +91,7 @@ json_t * asn1time2json(ASN1_TIME const *time) { BIO *bio; + int success; if (time == NULL) return json_null(); @@ -98,7 +100,12 @@ asn1time2json(ASN1_TIME const *time) if (bio == NULL) return NULL; - if (!ASN1_TIME_print_ex(bio, time, ASN1_DTFLGS_ISO8601)) { +#if OPENSSL_VERSION_NUMBER >= 0x30000000L + success = ASN1_TIME_print_ex(bio, time, ASN1_DTFLGS_ISO8601); +#else + success = ASN1_TIME_print(bio, time); /* Kill me */ +#endif + if (!success) { BIO_free_all(bio); return NULL; } diff --git a/src/libcrypto_util.h b/src/libcrypto_util.h index 53c9ba52..3e464f99 100644 --- a/src/libcrypto_util.h +++ b/src/libcrypto_util.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include char *bio2str(BIO *); json_t *bio2json(BIO *); -- 2.47.3