From 90f2b2d2497a5af10f7208858afc664a0dc0e319 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 5 Jan 2019 20:12:14 -0800 Subject: [PATCH] Fix compilation without deprecated OpenSSL APIs --- daemon/I2PControl.cpp | 4 ++-- libi2pd/Crypto.cpp | 2 ++ libi2pd/Crypto.h | 2 ++ libi2pd/Gost.cpp | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/daemon/I2PControl.cpp b/daemon/I2PControl.cpp index 6ac87cbb..572292ee 100644 --- a/daemon/I2PControl.cpp +++ b/daemon/I2PControl.cpp @@ -569,8 +569,8 @@ namespace client EVP_PKEY_assign_RSA (pkey, rsa); X509 * x509 = X509_new (); ASN1_INTEGER_set (X509_get_serialNumber (x509), 1); - X509_gmtime_adj (X509_get_notBefore (x509), 0); - X509_gmtime_adj (X509_get_notAfter (x509), I2P_CONTROL_CERTIFICATE_VALIDITY*24*60*60); // expiration + X509_gmtime_adj (X509_getm_notBefore (x509), 0); + X509_gmtime_adj (X509_getm_notAfter (x509), I2P_CONTROL_CERTIFICATE_VALIDITY*24*60*60); // expiration X509_set_pubkey (x509, pkey); // public key X509_NAME * name = X509_get_subject_name (x509); X509_NAME_add_entry_by_txt (name, "C", MBSTRING_ASC, (unsigned char *)"A1", -1, -1, 0); // country (Anonymous proxy) diff --git a/libi2pd/Crypto.cpp b/libi2pd/Crypto.cpp index 82def00c..0630091a 100644 --- a/libi2pd/Crypto.cpp +++ b/libi2pd/Crypto.cpp @@ -1246,7 +1246,9 @@ namespace crypto void InitCrypto (bool precomputation) { i2p::cpu::Detect (); +#if LEGACY_OPENSSL SSL_library_init (); +#endif /* auto numLocks = CRYPTO_num_locks(); for (int i = 0; i < numLocks; i++) m_OpenSSLMutexes.emplace_back (new std::mutex); diff --git a/libi2pd/Crypto.h b/libi2pd/Crypto.h index 625edf5b..46baf095 100644 --- a/libi2pd/Crypto.h +++ b/libi2pd/Crypto.h @@ -23,6 +23,8 @@ // recognize openssl version and features #if ((OPENSSL_VERSION_NUMBER < 0x010100000) || defined(LIBRESSL_VERSION_NUMBER)) // 1.0.2 and below or LibreSSL # define LEGACY_OPENSSL 1 +# define X509_getm_notBefore X509_get_notBefore +# define X509_getm_notAfter X509_get_notAfter #else # define LEGACY_OPENSSL 0 # if (OPENSSL_VERSION_NUMBER >= 0x010101000) // 1.1.1 diff --git a/libi2pd/Gost.cpp b/libi2pd/Gost.cpp index 5773fe15..c401f8be 100644 --- a/libi2pd/Gost.cpp +++ b/libi2pd/Gost.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include "I2PEndian.h"