Skip to content

Commit ea868b4

Browse files
committed
Re-enabling ability to build with OpenSSL v1.x.
1 parent 5b6bc38 commit ea868b4

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

source/authentication/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ endif()
2626

2727
add_library( authentication-client-objects OBJECT udaClientSSL.cpp udaClientSSL.h udaServerSSL.h utils.cpp )
2828
target_link_libraries( authentication-client-objects PRIVATE OpenSSL::SSL LibXml2::LibXml2 )
29-
target_compile_definitions( authentication-client-objects PRIVATE -DOPENSSL_NO_DEPRECATED )
29+
target_compile_definitions( authentication-client-objects PRIVATE )
3030

3131
if( NOT CLIENT_ONLY )
3232
add_library( authentication-server-objects OBJECT udaServerSSL.cpp udaClientSSL.h utils.cpp )
33-
target_compile_definitions( authentication-server-objects PRIVATE -DSERVERBUILD -DOPENSSL_NO_DEPRECATED )
33+
target_compile_definitions( authentication-server-objects PRIVATE -DSERVERBUILD )
3434
target_link_libraries( authentication-server-objects PRIVATE OpenSSL::SSL LibXml2::LibXml2 )
3535
endif()

source/authentication/udaClientSSL.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include <cstdio>
66
#include <fcntl.h>
7-
#include <time.h>
7+
#include <ctime>
88
#include <openssl/ssl.h>
99

1010
#include <client/updateSelectParms.h>
@@ -53,7 +53,9 @@ static void init_ssl_library()
5353
UDA_LOG(UDA_LOG_DEBUG, "Prior SSL initialisation\n");
5454
return;
5555
}
56-
OPENSSL_init_ssl(OPENSSL_INIT_SSL_DEFAULT, nullptr);
56+
SSL_library_init();
57+
SSL_load_error_strings();
58+
OpenSSL_add_ssl_algorithms();
5759
#ifdef _WIN32
5860
if (getenv("UDA_SSL_INITIALISED") == nullptr) {
5961
_putenv_s("UDA_SSL_INITIALISED", "1");
@@ -271,8 +273,8 @@ int configureUdaClientSSLContext(const HostData* host)
271273
UDA_THROW_ERROR(999, "Unable to parse client certificate [%s] to verify certificate validity");
272274
}
273275

274-
const ASN1_TIME* before = X509_getm_notBefore(clientCert);
275-
const ASN1_TIME* after = X509_getm_notAfter(clientCert);
276+
const ASN1_TIME* before = X509_get_notBefore(clientCert);
277+
const ASN1_TIME* after = X509_get_notAfter(clientCert);
276278

277279
char work[X509_STRING_SIZE];
278280
UDA_LOG(UDA_LOG_DEBUG, "Client X509 subject: %s\n",
@@ -383,7 +385,7 @@ int startUdaClientSSL()
383385
}
384386

385387
// Get the Server certificate and verify
386-
X509* peer = SSL_get1_peer_certificate(g_ssl);
388+
X509* peer = SSL_get_peer_certificate(g_ssl);
387389

388390
if (peer != nullptr) {
389391

@@ -406,8 +408,8 @@ int startUdaClientSSL()
406408

407409
// Verify Date validity
408410

409-
const ASN1_TIME* before = X509_getm_notBefore(peer);
410-
const ASN1_TIME* after = X509_getm_notAfter(peer);
411+
const ASN1_TIME* before = X509_get_notBefore(peer);
412+
const ASN1_TIME* after = X509_get_notAfter(peer);
411413

412414
time_t current_time = time(nullptr);
413415
char* c_time_string = ctime(&current_time);

source/authentication/udaServerSSL.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ void initUdaServerSSL()
9595
UDA_LOG(UDA_LOG_DEBUG, "Prior SSL initialisation\n");
9696
return;
9797
}
98-
OPENSSL_init_ssl(OPENSSL_INIT_SSL_DEFAULT, nullptr);
98+
SSL_library_init();
99+
SSL_load_error_strings();
100+
OpenSSL_add_ssl_algorithms();
99101
#ifdef _WIN32
100102
_putenv_s("UDA_SSL_INITIALISED", "1");
101103
#else

0 commit comments

Comments
 (0)