(openssl tls) when OpenSSL is older than 1.1, register the crypto locking callback to be thread safe. Should fix lots of CI failures
This commit is contained in:
parent
a65b334961
commit
6c205b983e
@ -1,6 +1,10 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
All changes to this project will be documented in this file.
|
All changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [9.5.5] - 2020-05-06
|
||||||
|
|
||||||
|
(openssl tls) when OpenSSL is older than 1.1, register the crypto locking callback to be thread safe. Should fix lots of CI failures
|
||||||
|
|
||||||
## [9.5.4] - 2020-05-04
|
## [9.5.4] - 2020-05-04
|
||||||
|
|
||||||
(cobra bots) do not use a queue to store messages pending processing, let the bot handle queuing
|
(cobra bots) do not use a queue to store messages pending processing, let the bot handle queuing
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
#include "IXCancellationRequest.h"
|
#include "IXCancellationRequest.h"
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
namespace ix
|
namespace ix
|
||||||
{
|
{
|
||||||
|
@ -19,6 +19,7 @@ typedef unsigned long int nfds_t;
|
|||||||
#else
|
#else
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <netinet/ip.h>
|
#include <netinet/ip.h>
|
||||||
@ -29,7 +30,6 @@ typedef unsigned long int nfds_t;
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace ix
|
namespace ix
|
||||||
|
@ -85,6 +85,8 @@ namespace ix
|
|||||||
|
|
||||||
std::atomic<bool> SocketOpenSSL::_openSSLInitializationSuccessful(false);
|
std::atomic<bool> SocketOpenSSL::_openSSLInitializationSuccessful(false);
|
||||||
std::once_flag SocketOpenSSL::_openSSLInitFlag;
|
std::once_flag SocketOpenSSL::_openSSLInitFlag;
|
||||||
|
std::unique_ptr<std::mutex[]> SocketOpenSSL::_openSSLMutexes =
|
||||||
|
std::make_unique<std::mutex[]>(CRYPTO_num_locks());
|
||||||
|
|
||||||
SocketOpenSSL::SocketOpenSSL(const SocketTLSOptions& tlsOptions, int fd)
|
SocketOpenSSL::SocketOpenSSL(const SocketTLSOptions& tlsOptions, int fd)
|
||||||
: Socket(fd)
|
: Socket(fd)
|
||||||
@ -106,6 +108,7 @@ namespace ix
|
|||||||
if (!OPENSSL_init_ssl(OPENSSL_INIT_LOAD_CONFIG, nullptr)) return;
|
if (!OPENSSL_init_ssl(OPENSSL_INIT_LOAD_CONFIG, nullptr)) return;
|
||||||
#else
|
#else
|
||||||
(void) OPENSSL_config(nullptr);
|
(void) OPENSSL_config(nullptr);
|
||||||
|
CRYPTO_set_locking_callback(SocketOpenSSL::openSSLLockingCallback);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
(void) OpenSSL_add_ssl_algorithms();
|
(void) OpenSSL_add_ssl_algorithms();
|
||||||
@ -114,6 +117,21 @@ namespace ix
|
|||||||
_openSSLInitializationSuccessful = true;
|
_openSSLInitializationSuccessful = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SocketOpenSSL::openSSLLockingCallback(int mode,
|
||||||
|
int type,
|
||||||
|
const char* /*file*/,
|
||||||
|
int /*line*/)
|
||||||
|
{
|
||||||
|
if (mode & CRYPTO_LOCK)
|
||||||
|
{
|
||||||
|
_openSSLMutexes[type].lock();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_openSSLMutexes[type].unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::string SocketOpenSSL::getSSLError(int ret)
|
std::string SocketOpenSSL::getSSLError(int ret)
|
||||||
{
|
{
|
||||||
unsigned long e;
|
unsigned long e;
|
||||||
|
@ -49,6 +49,12 @@ namespace ix
|
|||||||
bool handleTLSOptions(std::string& errMsg);
|
bool handleTLSOptions(std::string& errMsg);
|
||||||
bool openSSLServerHandshake(std::string& errMsg);
|
bool openSSLServerHandshake(std::string& errMsg);
|
||||||
|
|
||||||
|
// Required for OpenSSL < 1.1
|
||||||
|
void openSSLLockingCallback(int mode,
|
||||||
|
int type,
|
||||||
|
const char* /*file*/,
|
||||||
|
int /*line*/);
|
||||||
|
|
||||||
SSL* _ssl_connection;
|
SSL* _ssl_connection;
|
||||||
SSL_CTX* _ssl_context;
|
SSL_CTX* _ssl_context;
|
||||||
const SSL_METHOD* _ssl_method;
|
const SSL_METHOD* _ssl_method;
|
||||||
@ -58,6 +64,7 @@ namespace ix
|
|||||||
|
|
||||||
static std::once_flag _openSSLInitFlag;
|
static std::once_flag _openSSLInitFlag;
|
||||||
static std::atomic<bool> _openSSLInitializationSuccessful;
|
static std::atomic<bool> _openSSLInitializationSuccessful;
|
||||||
|
static std::unique_ptr<std::mutex[]> _openSSLMutexes;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ix
|
} // namespace ix
|
||||||
|
@ -18,7 +18,7 @@ typedef SSIZE_T ssize_t;
|
|||||||
#include "IXNetSystem.h"
|
#include "IXNetSystem.h"
|
||||||
|
|
||||||
namespace ix
|
namespace ix
|
||||||
{
|
{
|
||||||
class UdpSocket
|
class UdpSocket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -6,4 +6,4 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define IX_WEBSOCKET_VERSION "9.5.4"
|
#define IX_WEBSOCKET_VERSION "9.5.5"
|
||||||
|
2
makefile
2
makefile
@ -148,7 +148,7 @@ test_tsan_mbedtls:
|
|||||||
(cd test ; python2.7 run.py -r)
|
(cd test ; python2.7 run.py -r)
|
||||||
|
|
||||||
build_test_openssl:
|
build_test_openssl:
|
||||||
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_OPEN_SSL=1 -DUSE_TEST=1 .. ; make -j 4)
|
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_OPEN_SSL=1 -DUSE_TEST=1 .. ; ninja install)
|
||||||
|
|
||||||
test_openssl: build_test_openssl
|
test_openssl: build_test_openssl
|
||||||
(cd test ; python2.7 run.py -r)
|
(cd test ; python2.7 run.py -r)
|
||||||
|
Loading…
Reference in New Issue
Block a user