From 414341ebc6dbe50814b5c08fb709f1f31f15862c Mon Sep 17 00:00:00 2001 From: "Simon V. Lejel" Date: Mon, 12 Feb 2024 17:39:04 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Initailiza=20OpenSSL=20in?= =?UTF-8?q?=20a=20more=20modern=20way=20if=20possible?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/main.cc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/server/main.cc b/src/server/main.cc index 0d5ef6a..95a43e6 100644 --- a/src/server/main.cc +++ b/src/server/main.cc @@ -1,7 +1,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -33,8 +35,19 @@ string getCtxError() { int main() { - SSL_library_init(); - SSL_load_error_strings(); + // Inistialize the SSL library + if (OpenSSL_version_num() < 0x10100000L) { + // Old version, deprecated as of version 1.1.0 + SSL_library_init(); + + // Loads human readable error strings + // Automatically inistialized in newer versions + SSL_load_error_strings(); + } else { + // New version + // Initalizes both SSl and crypto and is generally better + OPENSSL_init_ssl(0, nullptr); + } SSL_CTX *ctx = SSL_CTX_new(TLS_server_method()); if (!ctx) {