Skip to content

Commit 26ea284

Browse files
authored
Merge pull request #158 from neheb/n
Remove deprecated OpenSSL APIs
2 parents 8b7101b + 4f552d6 commit 26ea284

3 files changed

Lines changed: 20 additions & 12 deletions

File tree

src/session.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,11 +1445,11 @@ tls_thread_id_func(CRYPTO_THREADID *tid)
14451445
static void
14461446
nc_tls_init(void)
14471447
{
1448+
#if OPENSSL_VERSION_NUMBER < 0x10100000L // < 1.1.0
14481449
SSL_load_error_strings();
14491450
ERR_load_BIO_strings();
14501451
SSL_library_init();
14511452

1452-
#if OPENSSL_VERSION_NUMBER < 0x10100000L // < 1.1.0
14531453
int i;
14541454

14551455
tls_locks = malloc(CRYPTO_num_locks() * sizeof *tls_locks);
@@ -1473,6 +1473,7 @@ nc_tls_init(void)
14731473
static void
14741474
nc_tls_destroy(void)
14751475
{
1476+
#if OPENSSL_VERSION_NUMBER < 0x10100000L // < 1.1.0
14761477
FIPS_mode_set(0);
14771478
CRYPTO_cleanup_all_ex_data();
14781479
nc_thread_destroy();
@@ -1484,7 +1485,6 @@ nc_tls_destroy(void)
14841485
SSL_COMP_free_compression_methods();
14851486
#endif
14861487

1487-
#if OPENSSL_VERSION_NUMBER < 0x10100000L // < 1.1.0
14881488
int i;
14891489

14901490
CRYPTO_THREADID_set_callback(NULL);
@@ -1507,13 +1507,13 @@ nc_tls_destroy(void)
15071507
static void
15081508
nc_ssh_tls_init(void)
15091509
{
1510+
#if OPENSSL_VERSION_NUMBER < 0x10100000L // < 1.1.0
15101511
SSL_load_error_strings();
15111512
ERR_load_BIO_strings();
15121513
SSL_library_init();
15131514

15141515
nc_ssh_init();
15151516

1516-
#if OPENSSL_VERSION_NUMBER < 0x10100000L // < 1.1.0
15171517
CRYPTO_set_dynlock_create_callback(tls_dyn_create_func);
15181518
CRYPTO_set_dynlock_lock_callback(tls_dyn_lock_func);
15191519
CRYPTO_set_dynlock_destroy_callback(tls_dyn_destroy_func);
@@ -1523,6 +1523,7 @@ nc_ssh_tls_init(void)
15231523
static void
15241524
nc_ssh_tls_destroy(void)
15251525
{
1526+
#if OPENSSL_VERSION_NUMBER < 0x10100000L // < 1.1.0
15261527
ERR_free_strings();
15271528
#if OPENSSL_VERSION_NUMBER < 0x10002000L // < 1.0.2
15281529
sk_SSL_COMP_free(SSL_COMP_get_compression_methods());
@@ -1532,7 +1533,6 @@ nc_ssh_tls_destroy(void)
15321533

15331534
nc_ssh_destroy();
15341535

1535-
#if OPENSSL_VERSION_NUMBER < 0x10100000L // < 1.1.0
15361536
CRYPTO_set_dynlock_create_callback(NULL);
15371537
CRYPTO_set_dynlock_lock_callback(NULL);
15381538
CRYPTO_set_dynlock_destroy_callback(NULL);

src/session_client_tls.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
#include "session_client_ch.h"
3030
#include "libnetconf.h"
3131

32+
#if OPENSSL_VERSION_NUMBER < 0x10100000L
33+
#define X509_STORE_CTX_get_by_subject X509_STORE_get_by_subject
34+
#endif
35+
3236
struct nc_client_context *nc_client_context_location(void);
3337
int nc_session_new_ctx( struct nc_session *session, struct ly_ctx *ctx);
3438

@@ -74,7 +78,7 @@ tlsauth_verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)
7478
store_ctx = X509_STORE_CTX_new();
7579
obj = X509_OBJECT_new();
7680
X509_STORE_CTX_init(store_ctx, opts->crl_store, NULL, NULL);
77-
rc = X509_STORE_get_by_subject(store_ctx, X509_LU_CRL, subject, obj);
81+
rc = X509_STORE_CTX_get_by_subject(store_ctx, X509_LU_CRL, subject, obj);
7882
X509_STORE_CTX_free(store_ctx);
7983
crl = X509_OBJECT_get0_X509_CRL(obj);
8084
if (rc > 0 && crl) {
@@ -113,7 +117,7 @@ tlsauth_verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)
113117
store_ctx = X509_STORE_CTX_new();
114118
obj = X509_OBJECT_new();
115119
X509_STORE_CTX_init(store_ctx, opts->crl_store, NULL, NULL);
116-
rc = X509_STORE_get_by_subject(store_ctx, X509_LU_CRL, issuer, obj);
120+
rc = X509_STORE_CTX_get_by_subject(store_ctx, X509_LU_CRL, issuer, obj);
117121
X509_STORE_CTX_free(store_ctx);
118122
crl = X509_OBJECT_get0_X509_CRL(obj);
119123
if (rc > 0 && crl) {
@@ -169,7 +173,7 @@ tlsauth_verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)
169173
* the current certificate in order to verify it's integrity */
170174
memset((char *)&obj, 0, sizeof obj);
171175
X509_STORE_CTX_init(&store_ctx, opts->crl_store, NULL, NULL);
172-
rc = X509_STORE_get_by_subject(&store_ctx, X509_LU_CRL, subject, &obj);
176+
rc = X509_STORE_CTX_get_by_subject(&store_ctx, X509_LU_CRL, subject, &obj);
173177
X509_STORE_CTX_cleanup(&store_ctx);
174178
crl = obj.data.crl;
175179
if (rc > 0 && crl) {
@@ -207,7 +211,7 @@ tlsauth_verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)
207211
* the current certificate in order to check for revocation */
208212
memset((char *)&obj, 0, sizeof obj);
209213
X509_STORE_CTX_init(&store_ctx, opts->crl_store, NULL, NULL);
210-
rc = X509_STORE_get_by_subject(&store_ctx, X509_LU_CRL, issuer, &obj);
214+
rc = X509_STORE_CTX_get_by_subject(&store_ctx, X509_LU_CRL, issuer, &obj);
211215
X509_STORE_CTX_cleanup(&store_ctx);
212216
crl = obj.data.crl;
213217
if (rc > 0 && crl) {

src/session_server_tls.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
#include "session_server_ch.h"
2929
#include "libnetconf.h"
3030

31+
#if OPENSSL_VERSION_NUMBER < 0x10100000L
32+
#define X509_STORE_CTX_get_by_subject X509_STORE_get_by_subject
33+
#endif
34+
3135
struct nc_server_tls_opts tls_ch_opts;
3236
pthread_mutex_t tls_ch_opts_lock = PTHREAD_MUTEX_INITIALIZER;
3337
extern struct nc_server_opts server_opts;
@@ -563,7 +567,7 @@ nc_tlsclb_verify(int preverify_ok, X509_STORE_CTX *x509_ctx)
563567
store_ctx = X509_STORE_CTX_new();
564568
obj = X509_OBJECT_new();
565569
X509_STORE_CTX_init(store_ctx, opts->crl_store, NULL, NULL);
566-
rc = X509_STORE_get_by_subject(store_ctx, X509_LU_CRL, subject, obj);
570+
rc = X509_STORE_CTX_get_by_subject(store_ctx, X509_LU_CRL, subject, obj);
567571
X509_STORE_CTX_free(store_ctx);
568572
crl = X509_OBJECT_get0_X509_CRL(obj);
569573
if (rc > 0 && crl) {
@@ -616,7 +620,7 @@ nc_tlsclb_verify(int preverify_ok, X509_STORE_CTX *x509_ctx)
616620
store_ctx = X509_STORE_CTX_new();
617621
obj = X509_OBJECT_new();
618622
X509_STORE_CTX_init(store_ctx, opts->crl_store, NULL, NULL);
619-
rc = X509_STORE_get_by_subject(store_ctx, X509_LU_CRL, issuer, obj);
623+
rc = X509_STORE_CTX_get_by_subject(store_ctx, X509_LU_CRL, issuer, obj);
620624
X509_STORE_CTX_free(store_ctx);
621625
crl = X509_OBJECT_get0_X509_CRL(obj);
622626
if (rc > 0 && crl) {
@@ -776,7 +780,7 @@ nc_tlsclb_verify(int preverify_ok, X509_STORE_CTX *x509_ctx)
776780
* the current certificate in order to verify it's integrity */
777781
memset((char *)&obj, 0, sizeof(obj));
778782
X509_STORE_CTX_init(&store_ctx, opts->crl_store, NULL, NULL);
779-
rc = X509_STORE_get_by_subject(&store_ctx, X509_LU_CRL, subject, &obj);
783+
rc = X509_STORE_CTX_get_by_subject(&store_ctx, X509_LU_CRL, subject, &obj);
780784
X509_STORE_CTX_cleanup(&store_ctx);
781785
crl = obj.data.crl;
782786
if (rc > 0 && crl) {
@@ -828,7 +832,7 @@ nc_tlsclb_verify(int preverify_ok, X509_STORE_CTX *x509_ctx)
828832
* the current certificate in order to check for revocation */
829833
memset((char *)&obj, 0, sizeof(obj));
830834
X509_STORE_CTX_init(&store_ctx, opts->crl_store, NULL, NULL);
831-
rc = X509_STORE_get_by_subject(&store_ctx, X509_LU_CRL, issuer, &obj);
835+
rc = X509_STORE_CTX_get_by_subject(&store_ctx, X509_LU_CRL, issuer, &obj);
832836
X509_STORE_CTX_cleanup(&store_ctx);
833837
crl = obj.data.crl;
834838
if (rc > 0 && crl) {

0 commit comments

Comments
 (0)