You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

160 lines
6.6 KiB

  1. --- a/src/session.c
  2. +++ b/src/session.c
  3. @@ -1372,11 +1372,11 @@ tls_thread_id_func(CRYPTO_THREADID *tid)
  4. static void
  5. nc_tls_init(void)
  6. {
  7. +#if OPENSSL_VERSION_NUMBER < 0x10100000L // < 1.1.0
  8. SSL_load_error_strings();
  9. ERR_load_BIO_strings();
  10. SSL_library_init();
  11. -#if OPENSSL_VERSION_NUMBER < 0x10100000L // < 1.1.0
  12. int i;
  13. tls_locks = malloc(CRYPTO_num_locks() * sizeof *tls_locks);
  14. @@ -1400,6 +1400,7 @@ nc_tls_init(void)
  15. static void
  16. nc_tls_destroy(void)
  17. {
  18. +#if OPENSSL_VERSION_NUMBER < 0x10100000L // < 1.1.0
  19. FIPS_mode_set(0);
  20. CRYPTO_cleanup_all_ex_data();
  21. nc_thread_destroy();
  22. @@ -1411,7 +1412,6 @@ nc_tls_destroy(void)
  23. SSL_COMP_free_compression_methods();
  24. #endif
  25. -#if OPENSSL_VERSION_NUMBER < 0x10100000L // < 1.1.0
  26. int i;
  27. CRYPTO_THREADID_set_callback(NULL);
  28. @@ -1434,13 +1434,13 @@ nc_tls_destroy(void)
  29. static void
  30. nc_ssh_tls_init(void)
  31. {
  32. +#if OPENSSL_VERSION_NUMBER < 0x10100000L // < 1.1.0
  33. SSL_load_error_strings();
  34. ERR_load_BIO_strings();
  35. SSL_library_init();
  36. nc_ssh_init();
  37. -#if OPENSSL_VERSION_NUMBER < 0x10100000L // < 1.1.0
  38. CRYPTO_set_dynlock_create_callback(tls_dyn_create_func);
  39. CRYPTO_set_dynlock_lock_callback(tls_dyn_lock_func);
  40. CRYPTO_set_dynlock_destroy_callback(tls_dyn_destroy_func);
  41. @@ -1450,6 +1450,7 @@ nc_ssh_tls_init(void)
  42. static void
  43. nc_ssh_tls_destroy(void)
  44. {
  45. +#if OPENSSL_VERSION_NUMBER < 0x10100000L // < 1.1.0
  46. ERR_free_strings();
  47. #if OPENSSL_VERSION_NUMBER < 0x10002000L // < 1.0.2
  48. sk_SSL_COMP_free(SSL_COMP_get_compression_methods());
  49. @@ -1459,7 +1460,6 @@ nc_ssh_tls_destroy(void)
  50. nc_ssh_destroy();
  51. -#if OPENSSL_VERSION_NUMBER < 0x10100000L // < 1.1.0
  52. CRYPTO_set_dynlock_create_callback(NULL);
  53. CRYPTO_set_dynlock_lock_callback(NULL);
  54. CRYPTO_set_dynlock_destroy_callback(NULL);
  55. --- a/src/session_client_tls.c
  56. +++ b/src/session_client_tls.c
  57. @@ -29,6 +29,10 @@
  58. #include "session_client_ch.h"
  59. #include "libnetconf.h"
  60. +#if OPENSSL_VERSION_NUMBER < 0x10100000L
  61. +#define X509_STORE_CTX_get_by_subject X509_STORE_get_by_subject
  62. +#endif
  63. +
  64. struct nc_client_context *nc_client_context_location(void);
  65. int nc_session_new_ctx( struct nc_session *session, struct ly_ctx *ctx);
  66. @@ -74,7 +78,7 @@ tlsauth_verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)
  67. store_ctx = X509_STORE_CTX_new();
  68. obj = X509_OBJECT_new();
  69. X509_STORE_CTX_init(store_ctx, opts->crl_store, NULL, NULL);
  70. - rc = X509_STORE_get_by_subject(store_ctx, X509_LU_CRL, subject, obj);
  71. + rc = X509_STORE_CTX_get_by_subject(store_ctx, X509_LU_CRL, subject, obj);
  72. X509_STORE_CTX_free(store_ctx);
  73. crl = X509_OBJECT_get0_X509_CRL(obj);
  74. if (rc > 0 && crl) {
  75. @@ -113,7 +117,7 @@ tlsauth_verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)
  76. store_ctx = X509_STORE_CTX_new();
  77. obj = X509_OBJECT_new();
  78. X509_STORE_CTX_init(store_ctx, opts->crl_store, NULL, NULL);
  79. - rc = X509_STORE_get_by_subject(store_ctx, X509_LU_CRL, issuer, obj);
  80. + rc = X509_STORE_CTX_get_by_subject(store_ctx, X509_LU_CRL, issuer, obj);
  81. X509_STORE_CTX_free(store_ctx);
  82. crl = X509_OBJECT_get0_X509_CRL(obj);
  83. if (rc > 0 && crl) {
  84. @@ -169,7 +173,7 @@ tlsauth_verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)
  85. * the current certificate in order to verify it's integrity */
  86. memset((char *)&obj, 0, sizeof obj);
  87. X509_STORE_CTX_init(&store_ctx, opts->crl_store, NULL, NULL);
  88. - rc = X509_STORE_get_by_subject(&store_ctx, X509_LU_CRL, subject, &obj);
  89. + rc = X509_STORE_CTX_get_by_subject(&store_ctx, X509_LU_CRL, subject, &obj);
  90. X509_STORE_CTX_cleanup(&store_ctx);
  91. crl = obj.data.crl;
  92. if (rc > 0 && crl) {
  93. @@ -207,7 +211,7 @@ tlsauth_verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)
  94. * the current certificate in order to check for revocation */
  95. memset((char *)&obj, 0, sizeof obj);
  96. X509_STORE_CTX_init(&store_ctx, opts->crl_store, NULL, NULL);
  97. - rc = X509_STORE_get_by_subject(&store_ctx, X509_LU_CRL, issuer, &obj);
  98. + rc = X509_STORE_CTX_get_by_subject(&store_ctx, X509_LU_CRL, issuer, &obj);
  99. X509_STORE_CTX_cleanup(&store_ctx);
  100. crl = obj.data.crl;
  101. if (rc > 0 && crl) {
  102. --- a/src/session_server_tls.c
  103. +++ b/src/session_server_tls.c
  104. @@ -28,6 +28,10 @@
  105. #include "session_server_ch.h"
  106. #include "libnetconf.h"
  107. +#if OPENSSL_VERSION_NUMBER < 0x10100000L
  108. +#define X509_STORE_CTX_get_by_subject X509_STORE_get_by_subject
  109. +#endif
  110. +
  111. struct nc_server_tls_opts tls_ch_opts;
  112. pthread_mutex_t tls_ch_opts_lock = PTHREAD_MUTEX_INITIALIZER;
  113. extern struct nc_server_opts server_opts;
  114. @@ -563,7 +567,7 @@ nc_tlsclb_verify(int preverify_ok, X509_STORE_CTX *x509_ctx)
  115. store_ctx = X509_STORE_CTX_new();
  116. obj = X509_OBJECT_new();
  117. X509_STORE_CTX_init(store_ctx, opts->crl_store, NULL, NULL);
  118. - rc = X509_STORE_get_by_subject(store_ctx, X509_LU_CRL, subject, obj);
  119. + rc = X509_STORE_CTX_get_by_subject(store_ctx, X509_LU_CRL, subject, obj);
  120. X509_STORE_CTX_free(store_ctx);
  121. crl = X509_OBJECT_get0_X509_CRL(obj);
  122. if (rc > 0 && crl) {
  123. @@ -616,7 +620,7 @@ nc_tlsclb_verify(int preverify_ok, X509_STORE_CTX *x509_ctx)
  124. store_ctx = X509_STORE_CTX_new();
  125. obj = X509_OBJECT_new();
  126. X509_STORE_CTX_init(store_ctx, opts->crl_store, NULL, NULL);
  127. - rc = X509_STORE_get_by_subject(store_ctx, X509_LU_CRL, issuer, obj);
  128. + rc = X509_STORE_CTX_get_by_subject(store_ctx, X509_LU_CRL, issuer, obj);
  129. X509_STORE_CTX_free(store_ctx);
  130. crl = X509_OBJECT_get0_X509_CRL(obj);
  131. if (rc > 0 && crl) {
  132. @@ -776,7 +780,7 @@ nc_tlsclb_verify(int preverify_ok, X509_STORE_CTX *x509_ctx)
  133. * the current certificate in order to verify it's integrity */
  134. memset((char *)&obj, 0, sizeof(obj));
  135. X509_STORE_CTX_init(&store_ctx, opts->crl_store, NULL, NULL);
  136. - rc = X509_STORE_get_by_subject(&store_ctx, X509_LU_CRL, subject, &obj);
  137. + rc = X509_STORE_CTX_get_by_subject(&store_ctx, X509_LU_CRL, subject, &obj);
  138. X509_STORE_CTX_cleanup(&store_ctx);
  139. crl = obj.data.crl;
  140. if (rc > 0 && crl) {
  141. @@ -828,7 +832,7 @@ nc_tlsclb_verify(int preverify_ok, X509_STORE_CTX *x509_ctx)
  142. * the current certificate in order to check for revocation */
  143. memset((char *)&obj, 0, sizeof(obj));
  144. X509_STORE_CTX_init(&store_ctx, opts->crl_store, NULL, NULL);
  145. - rc = X509_STORE_get_by_subject(&store_ctx, X509_LU_CRL, issuer, &obj);
  146. + rc = X509_STORE_CTX_get_by_subject(&store_ctx, X509_LU_CRL, issuer, &obj);
  147. X509_STORE_CTX_cleanup(&store_ctx);
  148. crl = obj.data.crl;
  149. if (rc > 0 && crl) {