Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ macro(set_search_path result)
endmacro()

if (CMAKE_SYSTEM_NAME STREQUAL Windows)
add_definitions(-D_WIN32_WINNT=0x0601)
# CMake uses semicolon as list separator. Change ';'->'\;'
function(to_native_path path result)
file (TO_NATIVE_PATH "${path}" path)
Expand Down
2 changes: 1 addition & 1 deletion c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ endif()
# Link in openssl if present
if (SSL_IMPL STREQUAL openssl)
set (pn_ssl_impl src/ssl/openssl.c)
set (SSL_LIB OpenSSL::SSL Threads::Threads)
set (SSL_LIB OpenSSL::SSL OpenSSL::Crypto Threads::Threads)
elseif (SSL_IMPL STREQUAL schannel)
set (pn_ssl_impl src/ssl/schannel.cpp)
set (SSL_LIB Crypt32.lib Secur32.lib)
Expand Down
25 changes: 22 additions & 3 deletions c/src/ssl/openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,11 @@ static int verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
return preverify_ok;
}

#ifdef __GNUC__
// Temporary: PROTON-2544 for build. Next release: replace or remove DH_xxx() functions.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif // __GNUC__

// This was introduced in v1.1
#if OPENSSL_VERSION_NUMBER < 0x10100000
Expand Down Expand Up @@ -591,7 +593,9 @@ static bool pni_init_ssl_domain( pn_ssl_domain_t * domain, pn_ssl_mode_t mode )
}

// PROTON-2544: see earlier related push. Temporary only.
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif // __GNUC__

pn_ssl_domain_t *pn_ssl_domain( pn_ssl_mode_t mode )
{
Expand Down Expand Up @@ -1719,6 +1723,7 @@ static size_t buffered_output(pn_transport_t *transport)


/* Thread-safe locking and initialization for POSIX and Windows */
static void initialize(void);

static bool init_ok = false;

Expand All @@ -1730,18 +1735,32 @@ static inline void pni_mutex_lock(pni_mutex_t *m) { EnterCriticalSection(m); }
static inline void pni_mutex_unlock(pni_mutex_t *m) { LeaveCriticalSection(m); }
static inline unsigned long id_callback(void) { return (unsigned long)GetCurrentThreadId(); }
INIT_ONCE initialize_once = INIT_ONCE_STATIC_INIT;

static inline BOOL pni_init_once_fn(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *Context) {
(void) InitOnce;
(void) Parameter;
(void) Context;

initialize();

if (ERR_peek_error()) {
ssl_log_flush(NULL, PN_LEVEL_ERROR);
return false;
}

return true;
}

static inline bool ensure_initialized(void) {
void* dummy;
InitOnceExecuteOnce(&initialize_once, &initialize, NULL, &dummy);
InitOnceExecuteOnce(&initialize_once, &pni_init_once_fn, NULL, &dummy);
return init_ok;
}

#else /* POSIX */

#include <pthread.h>

static void initialize(void);

typedef pthread_mutex_t pni_mutex_t;
static inline int pni_mutex_init(pni_mutex_t *m) { return pthread_mutex_init(m, NULL); }
static inline int pni_mutex_lock(pni_mutex_t *m) { return pthread_mutex_lock(m); }
Expand Down