From 1baacd434046adcdf7cace66750f34ba3fc78b52 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Sun, 24 Nov 2024 16:56:17 +0100 Subject: Add support to query version in TLS backends --- src/IO/tls_openssl.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/IO/tls_openssl.c') diff --git a/src/IO/tls_openssl.c b/src/IO/tls_openssl.c index 5ad12b8c..9098287a 100644 --- a/src/IO/tls_openssl.c +++ b/src/IO/tls_openssl.c @@ -246,6 +246,27 @@ static void Tls_load_certificates(void) ; } +const char *a_Tls_openssl_version(char *buf, int n) +{ + /* Ugly hack to replace "OpenSSL 3.4.0 22 Oct 2024" with + * "OpenSSL/3.4.0". It also works for LibreSSL. */ + const char *ver = OpenSSL_version(OPENSSL_VERSION); + if (snprintf(buf, n, "%s", ver) >= n) + return "OpenSSL/?"; + + char *ossl = buf; + char *sp1 = strchr(ossl, ' '); + if (sp1) { + *sp1 = '/'; + char *sp2 = strchr(ossl, ' '); + if (sp2) { + *sp2 = '\0'; + } + } + + return buf; +} + /* * Initialize the OpenSSL library. */ -- cgit v1.2.3