Merge pull request #1281 from neheb/b

Fix compilation without deprecated OpenSSL APIs
This commit is contained in:
orignal 2019-01-06 20:12:51 -05:00 committed by GitHub
commit 8f909b051f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 2 deletions

View File

@ -569,8 +569,8 @@ namespace client
EVP_PKEY_assign_RSA (pkey, rsa); EVP_PKEY_assign_RSA (pkey, rsa);
X509 * x509 = X509_new (); X509 * x509 = X509_new ();
ASN1_INTEGER_set (X509_get_serialNumber (x509), 1); ASN1_INTEGER_set (X509_get_serialNumber (x509), 1);
X509_gmtime_adj (X509_get_notBefore (x509), 0); X509_gmtime_adj (X509_getm_notBefore (x509), 0);
X509_gmtime_adj (X509_get_notAfter (x509), I2P_CONTROL_CERTIFICATE_VALIDITY*24*60*60); // expiration X509_gmtime_adj (X509_getm_notAfter (x509), I2P_CONTROL_CERTIFICATE_VALIDITY*24*60*60); // expiration
X509_set_pubkey (x509, pkey); // public key X509_set_pubkey (x509, pkey); // public key
X509_NAME * name = X509_get_subject_name (x509); 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) X509_NAME_add_entry_by_txt (name, "C", MBSTRING_ASC, (unsigned char *)"A1", -1, -1, 0); // country (Anonymous proxy)

View File

@ -1246,7 +1246,9 @@ namespace crypto
void InitCrypto (bool precomputation) void InitCrypto (bool precomputation)
{ {
i2p::cpu::Detect (); i2p::cpu::Detect ();
#if LEGACY_OPENSSL
SSL_library_init (); SSL_library_init ();
#endif
/* auto numLocks = CRYPTO_num_locks(); /* auto numLocks = CRYPTO_num_locks();
for (int i = 0; i < numLocks; i++) for (int i = 0; i < numLocks; i++)
m_OpenSSLMutexes.emplace_back (new std::mutex); m_OpenSSLMutexes.emplace_back (new std::mutex);

View File

@ -23,6 +23,8 @@
// recognize openssl version and features // recognize openssl version and features
#if ((OPENSSL_VERSION_NUMBER < 0x010100000) || defined(LIBRESSL_VERSION_NUMBER)) // 1.0.2 and below or LibreSSL #if ((OPENSSL_VERSION_NUMBER < 0x010100000) || defined(LIBRESSL_VERSION_NUMBER)) // 1.0.2 and below or LibreSSL
# define LEGACY_OPENSSL 1 # define LEGACY_OPENSSL 1
# define X509_getm_notBefore X509_get_notBefore
# define X509_getm_notAfter X509_get_notAfter
#else #else
# define LEGACY_OPENSSL 0 # define LEGACY_OPENSSL 0
# if (OPENSSL_VERSION_NUMBER >= 0x010101000) // 1.1.1 # if (OPENSSL_VERSION_NUMBER >= 0x010101000) // 1.1.1

View File

@ -1,5 +1,6 @@
#include <string.h> #include <string.h>
#include <array> #include <array>
#include <openssl/bn.h>
#include <openssl/sha.h> #include <openssl/sha.h>
#include <openssl/evp.h> #include <openssl/evp.h>
#include "I2PEndian.h" #include "I2PEndian.h"