From 2b3205b5fa427376dd364f0ce0d6e0dff257b6f6 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 19 Jan 2017 17:04:02 +0100 Subject: [PATCH] BUILD: ssl: fix build on OpenSSL 1.0.0 After the code was ported to support 1.1.0, this one broke on 1.0.0 : src/shctx.c:406: undefined reference to `SSL_SESSION_set1_id_context' The function was indeed introduced only in 1.0.1. The build was validated with 0.9.8, 1.0.0, 1.0.1, 1.0.2 and 1.1.0. This fix must be backported to 1.7. --- include/proto/openssl-compat.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/include/proto/openssl-compat.h b/include/proto/openssl-compat.h index 645c9b715..e2154f7ef 100644 --- a/include/proto/openssl-compat.h +++ b/include/proto/openssl-compat.h @@ -56,16 +56,7 @@ static inline void X509_ALGOR_get0(ASN1_OBJECT **paobj, int *pptype, const void #if (OPENSSL_VERSION_NUMBER < 0x1000000fL) -/* - * Functions introduced in OpenSSL 1.0.1 - */ -static inline int SSL_SESSION_set1_id_context(SSL_SESSION *s, const unsigned char *sid_ctx, unsigned int sid_ctx_len) -{ - s->sid_ctx_length = sid_ctx_len; - memcpy(s->sid_ctx, sid_ctx, sid_ctx_len); - return 1; -} - +/* Functions introduced in OpenSSL 1.0.0 */ static inline int EVP_PKEY_base_id(const EVP_PKEY *pkey) { return EVP_PKEY_type(pkey->type); @@ -86,6 +77,18 @@ static inline int X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg, const unsigned ch #endif +#if (OPENSSL_VERSION_NUMBER < 0x1000100fL) +/* + * Functions introduced in OpenSSL 1.0.1 + */ +static inline int SSL_SESSION_set1_id_context(SSL_SESSION *s, const unsigned char *sid_ctx, unsigned int sid_ctx_len) +{ + s->sid_ctx_length = sid_ctx_len; + memcpy(s->sid_ctx, sid_ctx, sid_ctx_len); + return 1; +} +#endif + #if (OPENSSL_VERSION_NUMBER < 0x1010000fL) || defined(LIBRESSL_VERSION_NUMBER) /* * Functions introduced in OpenSSL 1.1.0 and not yet present in LibreSSL