Skip to content

Commit 720867b

Browse files
committed
Fix warnings and errors when building with LibreSSL and OpenSSL 1.1.1w.
* buckets/ssl_buckets.c (ssl_x509_ex_data_idx): Make conditional on SERF_HAVE_OSSL_STORE_OPEN_EX. * test/test_ssl.c (client_cert_uri_conn_setup): Likewise, make conditional. (SERF__OPENSSL_VERSION_PREREQ): Define this macro to expand to false if OPENSSL_VERSION_PREREQ is not defined, otherwise make it an alias. (test_ssl_revoked_server_cert, test_ssl_ocsp_verify_response_no_signer): Use our new ...PREREQ macro instead of the previous invalid usage that broke compiling with older versions of OpenSSL. git-svn-id: https://svn.apache.org/repos/asf/serf/trunk@1931107 13f79535-47bb-0310-9956-ffa450edef68
1 parent f197558 commit 720867b

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

buckets/ssl_buckets.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ DEFINE_STACK_OF(EVP_PKEY)
126126
*
127127
*/
128128

129+
#if defined(SERF_HAVE_OSSL_STORE_OPEN_EX)
129130
static int ssl_x509_ex_data_idx = -1;
131+
#endif
130132

131133
typedef struct bucket_list {
132134
serf_bucket_t *bucket;

test/test_ssl.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@
3636
#include <openssl/ocsp.h>
3737
#endif
3838

39+
/* The OPENSSL_VERSION_PREREQ macro is only available from 3.0 onwards,
40+
so we'll "backport" it here for older versions. */
41+
#ifdef OPENSSL_VERSION_PREREQ
42+
#define SERF__OPENSSL_VERSION_PREREQ(m, n) OPENSSL_VERSION_PREREQ((m), (n))
43+
#else
44+
#define SERF__OPENSSL_VERSION_PREREQ(m, n) (0)
45+
#endif
46+
3947
/* Test setting up the openssl library. */
4048
static void test_ssl_init(CuTest *tc)
4149
{
@@ -1174,6 +1182,7 @@ static void test_ssl_client_certificate(CuTest *tc)
11741182
EndVerify
11751183
}
11761184

1185+
#if defined(SERF_HAVE_OSSL_STORE_OPEN_EX)
11771186
static apr_status_t
11781187
client_cert_uri_conn_setup(apr_socket_t *skt,
11791188
serf_bucket_t **input_bkt,
@@ -1201,6 +1210,7 @@ client_cert_uri_conn_setup(apr_socket_t *skt,
12011210

12021211
return APR_SUCCESS;
12031212
}
1213+
#endif
12041214

12051215
static void test_ssl_client_certificate_uri(CuTest *tc)
12061216
{
@@ -1394,7 +1404,7 @@ static void test_ssl_revoked_server_cert(CuTest *tc)
13941404
certificate. OpenSSL may call the application multiple times per depth,
13951405
e.g. once to tell that the cert is revoked, and a second time to tell
13961406
that the certificate itself is valid. */
1397-
#if defined(OPENSSL_VERSION_PREREQ) && OPENSSL_VERSION_PREREQ(3, 6)
1407+
#if SERF__OPENSSL_VERSION_PREREQ(3, 6)
13981408
/* In OpenSSL 3.6, error handling changed so that only the
13991409
first instance of CERT_UNABLE_TO_GET_CRL is reported. */
14001410
CuAssertStrEquals(tc,
@@ -2794,7 +2804,7 @@ static void test_ssl_ocsp_verify_response_no_signer(CuTest *tc)
27942804
{
27952805
#ifndef OPENSSL_NO_OCSP
27962806
apr_status_t status = verify_ocsp_response(tc, 1, 0, 0, 0);
2797-
#if defined(OPENSSL_VERSION_PREREQ) && OPENSSL_VERSION_PREREQ(3, 0)
2807+
#if SERF__OPENSSL_VERSION_PREREQ(3, 0)
27982808
/* OCSP responses MUST be signed, and on newer versions of OpenSSL we
27992809
can't even create one without a signature. This error doesn't come
28002810
from response validation but because OCSP_response_create() fails. */

0 commit comments

Comments
 (0)