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.

177 lines
6.3 KiB

  1. --- a/modules/ssl/mod_ssl.c
  2. +++ b/modules/ssl/mod_ssl.c
  3. @@ -328,6 +328,7 @@ static int modssl_is_prelinked(void)
  4. static apr_status_t ssl_cleanup_pre_config(void *data)
  5. {
  6. +#if MODSSL_USE_OPENSSL_PRE_1_1_API
  7. /*
  8. * Try to kill the internals of the SSL library.
  9. */
  10. @@ -343,11 +344,9 @@ static apr_status_t ssl_cleanup_pre_config(void *data)
  11. #if OPENSSL_VERSION_NUMBER >= 0x1000200fL
  12. #ifndef OPENSSL_NO_COMP
  13. SSL_COMP_free_compression_methods();
  14. -#endif
  15. #endif
  16. /* Usually needed per thread, but this parent process is single-threaded */
  17. -#if MODSSL_USE_OPENSSL_PRE_1_1_API
  18. #if OPENSSL_VERSION_NUMBER >= 0x1000000fL
  19. ERR_remove_thread_state(NULL);
  20. #else
  21. @@ -376,6 +375,7 @@ static apr_status_t ssl_cleanup_pre_config(void *data)
  22. * (when enabled) at this late stage in the game:
  23. * CRYPTO_mem_leaks_fp(stderr);
  24. */
  25. +#endif
  26. return APR_SUCCESS;
  27. }
  28. @@ -400,14 +400,16 @@ static int ssl_hook_pre_config(apr_pool_t *pconf,
  29. #else
  30. OPENSSL_malloc_init();
  31. #endif
  32. +#if MODSSL_USE_OPENSSL_PRE_1_1_API
  33. ERR_load_crypto_strings();
  34. SSL_load_error_strings();
  35. SSL_library_init();
  36. + OpenSSL_add_all_algorithms();
  37. + OPENSSL_load_builtin_modules();
  38. +#endif
  39. #if HAVE_ENGINE_LOAD_BUILTIN_ENGINES
  40. ENGINE_load_builtin_engines();
  41. #endif
  42. - OpenSSL_add_all_algorithms();
  43. - OPENSSL_load_builtin_modules();
  44. if (OBJ_txt2nid("id-on-dnsSRV") == NID_undef) {
  45. (void)OBJ_create("1.3.6.1.5.5.7.8.7", "id-on-dnsSRV",
  46. --- a/modules/ssl/ssl_engine_init.c
  47. +++ b/modules/ssl/ssl_engine_init.c
  48. @@ -88,6 +88,8 @@ static int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g)
  49. return 1;
  50. }
  51. +
  52. +#define OpenSSL_version_num SSLeay
  53. #endif
  54. /*
  55. @@ -223,7 +225,7 @@ apr_status_t ssl_init_Module(apr_pool_t *p, apr_pool_t *plog,
  56. apr_status_t rv;
  57. apr_array_header_t *pphrases;
  58. - if (SSLeay() < MODSSL_LIBRARY_VERSION) {
  59. + if (OpenSSL_version_num() < MODSSL_LIBRARY_VERSION) {
  60. ap_log_error(APLOG_MARK, APLOG_WARNING, 0, base_server, APLOGNO(01882)
  61. "Init: this version of mod_ssl was compiled against "
  62. "a newer library (%s, version currently loaded is %s)"
  63. --- a/modules/ssl/ssl_engine_io.c
  64. +++ b/modules/ssl/ssl_engine_io.c
  65. @@ -1255,9 +1255,9 @@ static apr_status_t ssl_io_filter_handshake(ssl_filter_ctx_t *filter_ctx)
  66. if (dc->proxy->ssl_check_peer_expire != FALSE) {
  67. if (!cert
  68. || (X509_cmp_current_time(
  69. - X509_get_notBefore(cert)) >= 0)
  70. + X509_get0_notBefore(cert)) >= 0)
  71. || (X509_cmp_current_time(
  72. - X509_get_notAfter(cert)) <= 0)) {
  73. + X509_get0_notAfter(cert)) <= 0)) {
  74. proxy_ssl_check_peer_ok = FALSE;
  75. ap_log_cerror(APLOG_MARK, APLOG_INFO, 0, c, APLOGNO(02004)
  76. "SSL Proxy: Peer certificate is expired");
  77. --- a/modules/ssl/ssl_engine_log.c
  78. +++ b/modules/ssl/ssl_engine_log.c
  79. @@ -163,10 +163,10 @@ static void ssl_log_cert_error(const char *file, int line, int level,
  80. BIO_puts(bio, "(ERROR)");
  81. BIO_puts(bio, " / notbefore: ");
  82. - ASN1_TIME_print(bio, X509_get_notBefore(cert));
  83. + ASN1_TIME_print(bio, X509_get0_notBefore(cert));
  84. BIO_puts(bio, " / notafter: ");
  85. - ASN1_TIME_print(bio, X509_get_notAfter(cert));
  86. + ASN1_TIME_print(bio, X509_get0_notAfter(cert));
  87. BIO_puts(bio, "]");
  88. --- a/modules/ssl/ssl_engine_vars.c
  89. +++ b/modules/ssl/ssl_engine_vars.c
  90. @@ -495,13 +495,13 @@ static char *ssl_var_lookup_ssl_cert(apr_pool_t *p, request_rec *r, X509 *xs,
  91. result = ssl_var_lookup_ssl_cert_serial(p, xs);
  92. }
  93. else if (strcEQ(var, "V_START")) {
  94. - result = ssl_var_lookup_ssl_cert_valid(p, X509_get_notBefore(xs));
  95. + result = ssl_var_lookup_ssl_cert_valid(p, X509_getm_notBefore(xs));
  96. }
  97. else if (strcEQ(var, "V_END")) {
  98. - result = ssl_var_lookup_ssl_cert_valid(p, X509_get_notAfter(xs));
  99. + result = ssl_var_lookup_ssl_cert_valid(p, X509_getm_notAfter(xs));
  100. }
  101. else if (strcEQ(var, "V_REMAIN")) {
  102. - result = ssl_var_lookup_ssl_cert_remain(p, X509_get_notAfter(xs));
  103. + result = ssl_var_lookup_ssl_cert_remain(p, X509_getm_notAfter(xs));
  104. resdup = FALSE;
  105. }
  106. else if (*var && strcEQ(var+1, "_DN")) {
  107. --- a/modules/ssl/ssl_private.h
  108. +++ b/modules/ssl/ssl_private.h
  109. @@ -92,6 +92,8 @@
  110. #include <openssl/x509.h>
  111. #include <openssl/pem.h>
  112. #include <openssl/crypto.h>
  113. +#include <openssl/bn.h>
  114. +#include <openssl/dh.h>
  115. #include <openssl/evp.h>
  116. #include <openssl/rand.h>
  117. #include <openssl/x509v3.h>
  118. @@ -234,6 +236,10 @@
  119. #define BIO_get_shutdown(x) (x->shutdown)
  120. #define BIO_set_shutdown(x,v) (x->shutdown=v)
  121. #define DH_bits(x) (BN_num_bits(x->p))
  122. +#define X509_get0_notBefore X509_get_notBefore
  123. +#define X509_get0_notAfter X509_get_notAfter
  124. +#define X509_getm_notBefore X509_get_notBefore
  125. +#define X509_getm_notAfter X509_get_notAfter
  126. #else
  127. void init_bio_methods(void);
  128. void free_bio_methods(void);
  129. --- a/support/ab.c
  130. +++ b/support/ab.c
  131. @@ -205,6 +205,10 @@ typedef STACK_OF(X509) X509_STACK_TYPE;
  132. #define SSL_CTX_set_max_proto_version(ctx, version) \
  133. SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MAX_PROTO_VERSION, version, NULL)
  134. #endif
  135. +#if OPENSSL_VERSION_NUMBER < 0x10100000L
  136. +#define X509_get0_notBefore X509_get_notBefore
  137. +#define X509_get0_notAfter X509_get_notAfter
  138. +#endif
  139. #endif
  140. #include <math.h>
  141. @@ -652,11 +656,11 @@ static void ssl_print_cert_info(BIO *bio, X509 *cert)
  142. BIO_printf(bio, "Certificate version: %ld\n", X509_get_version(cert)+1);
  143. BIO_printf(bio,"Valid from: ");
  144. - ASN1_UTCTIME_print(bio, X509_get_notBefore(cert));
  145. + ASN1_UTCTIME_print(bio, X509_get0_notBefore(cert));
  146. BIO_printf(bio,"\n");
  147. BIO_printf(bio,"Valid to : ");
  148. - ASN1_UTCTIME_print(bio, X509_get_notAfter(cert));
  149. + ASN1_UTCTIME_print(bio, X509_get0_notAfter(cert));
  150. BIO_printf(bio,"\n");
  151. pk = X509_get_pubkey(cert);
  152. @@ -2634,8 +2638,10 @@ int main(int argc, const char * const argv[])
  153. CRYPTO_malloc_init();
  154. #endif
  155. #endif
  156. +#if OPENSSL_VERSION_NUMBER < 0x10100000L
  157. SSL_load_error_strings();
  158. SSL_library_init();
  159. +#endif
  160. bio_out=BIO_new_fp(stdout,BIO_NOCLOSE);
  161. bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);