openssl: More LibreSSL compatibility
LibreSSL does not have the new version macros & functions that OpenSSL 1.1.0 implements. This causes a compile-time failure against LibreSSL. Further, the runtime function for returning the library version returns the wrong number (the hardcoded constant number SSLEAY_VERSION_NUMBER aka OPENSSL_VERSION_NUMBER, instead of LIBRESSL_VERSION_NUMBER). Add more ifdef soup to remedy the situation.
This commit is contained in:
parent
bc2eeb0992
commit
03e6030ed2
1 changed files with 39 additions and 13 deletions
|
@ -61,6 +61,37 @@
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* More LibreSSL compatibility mess
|
||||||
|
* Used in rb_get_ssl_info() below.
|
||||||
|
*/
|
||||||
|
#if !defined(LIBRESSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x10100000L)
|
||||||
|
/* OpenSSL 1.1.0+ */
|
||||||
|
# define LRB_SSL_VTEXT_COMPILETIME OPENSSL_VERSION_TEXT
|
||||||
|
# define LRB_SSL_VTEXT_RUNTIME OpenSSL_version(OPENSSL_VERSION)
|
||||||
|
# define LRB_SSL_VNUM_COMPILETIME OPENSSL_VERSION_NUMBER
|
||||||
|
# define LRB_SSL_VNUM_RUNTIME OpenSSL_version_num()
|
||||||
|
# define LRB_SSL_FULL_VERSION_INFO 1
|
||||||
|
#else
|
||||||
|
/*
|
||||||
|
* "Full version info" above means we have access to all 4 pieces of information.
|
||||||
|
*
|
||||||
|
* For the below, this is not the case; LibreSSL version number at runtime returns
|
||||||
|
* the wrong version number, and OpenSSL version text at compile time does not exist.
|
||||||
|
* Thus, we only reliably have version text at runtime, and version number at compile
|
||||||
|
* time.
|
||||||
|
*/
|
||||||
|
# if defined(LIBRESSL_VERSION_NUMBER) && (LIBRESSL_VERSION_NUMBER >= 0x20200000L)
|
||||||
|
/* LibreSSL 2.2.0+ */
|
||||||
|
# define LRB_SSL_VTEXT_RUNTIME SSLeay_version(SSLEAY_VERSION)
|
||||||
|
# define LRB_SSL_VNUM_COMPILETIME LIBRESSL_VERSION_NUMBER
|
||||||
|
# else
|
||||||
|
/* OpenSSL < 1.1.0 or LibreSSL < 2.2.0 */
|
||||||
|
# define LRB_SSL_VTEXT_RUNTIME SSLeay_version(SSLEAY_VERSION)
|
||||||
|
# define LRB_SSL_VNUM_COMPILETIME SSLEAY_VERSION_NUMBER
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
static SSL_CTX *ssl_server_ctx = NULL;
|
static SSL_CTX *ssl_server_ctx = NULL;
|
||||||
static SSL_CTX *ssl_client_ctx = NULL;
|
static SSL_CTX *ssl_client_ctx = NULL;
|
||||||
static int libratbox_index = -1;
|
static int libratbox_index = -1;
|
||||||
|
@ -767,22 +798,17 @@ rb_supports_ssl(void)
|
||||||
void
|
void
|
||||||
rb_get_ssl_info(char *buf, size_t len)
|
rb_get_ssl_info(char *buf, size_t len)
|
||||||
{
|
{
|
||||||
#if (OPENSSL_VERSION_NUMBER >= 0x10100000L)
|
#ifdef LRB_SSL_FULL_VERSION_INFO
|
||||||
if (OpenSSL_version_num() == OPENSSL_VERSION_NUMBER)
|
if (LRB_SSL_VNUM_RUNTIME == LRB_SSL_VNUM_COMPILETIME)
|
||||||
rb_snprintf(buf, len, "OpenSSL: 0x%lx, %s",
|
rb_snprintf(buf, len, "OpenSSL: compiled 0x%lx, library %s",
|
||||||
OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_TEXT);
|
LRB_SSL_VNUM_COMPILETIME, LRB_SSL_VTEXT_COMPILETIME);
|
||||||
else
|
else
|
||||||
rb_snprintf(buf, len, "OpenSSL: compiled (0x%lx, %s), library (0x%lx, %s)",
|
rb_snprintf(buf, len, "OpenSSL: compiled (0x%lx, %s), library (0x%lx, %s)",
|
||||||
OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_TEXT,
|
LRB_SSL_VNUM_COMPILETIME, LRB_SSL_VTEXT_COMPILETIME,
|
||||||
OpenSSL_version_num(), OpenSSL_version(OPENSSL_VERSION));
|
LRB_SSL_VNUM_RUNTIME, LRB_SSL_VTEXT_RUNTIME);
|
||||||
#else
|
#else
|
||||||
if (SSLeay() == SSLEAY_VERSION_NUMBER)
|
rb_snprintf(buf, len, "OpenSSL: compiled 0x%lx, library %s",
|
||||||
rb_snprintf(buf, len, "OpenSSL: 0x%lx, %s",
|
LRB_SSL_VNUM_COMPILETIME, LRB_SSL_VTEXT_RUNTIME);
|
||||||
SSLeay(), SSLeay_version(SSLEAY_VERSION));
|
|
||||||
else
|
|
||||||
rb_snprintf(buf, len, "OpenSSL: compiled (0x%lx, %s), library (0x%lx, %s)",
|
|
||||||
SSLEAY_VERSION_NUMBER, "???",
|
|
||||||
SSLeay(), SSLeay_version(SSLEAY_VERSION));
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue