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.

96 lines
3.3 KiB

  1. diff --git a/src/node_crypto.cc b/src/node_crypto.cc
  2. index c3779c0..611fb43 100644
  3. --- a/src/node_crypto.cc
  4. +++ b/src/node_crypto.cc
  5. @@ -43,6 +43,11 @@
  6. #include <string.h>
  7. #include <vector>
  8. +#if OPENSSL_VERSION_NUMBER < 0x10100000L
  9. +#define X509_get0_notBefore X509_get_notBefore
  10. +#define X509_get0_notAfter X509_get_notAfter
  11. +#endif
  12. +
  13. #define THROW_AND_RETURN_IF_NOT_STRING_OR_BUFFER(val, prefix) \
  14. do { \
  15. if (!Buffer::HasInstance(val) && !val->IsString()) { \
  16. @@ -536,6 +541,7 @@ void SecureContext::Init(const FunctionCallbackInfo<Value>& args) {
  17. method = SSLv23_server_method();
  18. } else if (strcmp(*sslmethod, "SSLv23_client_method") == 0) {
  19. method = SSLv23_client_method();
  20. +#if OPENSSL_VERSION_NUMBER < 0x10100000L
  21. } else if (strcmp(*sslmethod, "TLSv1_method") == 0) {
  22. method = TLSv1_method();
  23. } else if (strcmp(*sslmethod, "TLSv1_server_method") == 0) {
  24. @@ -554,6 +560,14 @@ void SecureContext::Init(const FunctionCallbackInfo<Value>& args) {
  25. method = TLSv1_2_server_method();
  26. } else if (strcmp(*sslmethod, "TLSv1_2_client_method") == 0) {
  27. method = TLSv1_2_client_method();
  28. +#else
  29. + } else if (strcmp(*sslmethod, "TLS_method") == 0) {
  30. + method = TLS_method();
  31. + } else if (strcmp(*sslmethod, "TLS_server_method") == 0) {
  32. + method = TLS_server_method();
  33. + } else if (strcmp(*sslmethod, "TLS_client_method") == 0) {
  34. + method = TLS_client_method();
  35. +#endif
  36. } else {
  37. return env->ThrowError("Unknown method");
  38. }
  39. @@ -1799,7 +1813,7 @@ static Local<Object> X509ToObject(Environment* env, X509* cert) {
  40. rsa = nullptr;
  41. }
  42. - ASN1_TIME_print(bio, X509_get_notBefore(cert));
  43. + ASN1_TIME_print(bio, X509_get0_notBefore(cert));
  44. BIO_get_mem_ptr(bio, &mem);
  45. info->Set(context, env->valid_from_string(),
  46. String::NewFromUtf8(env->isolate(), mem->data,
  47. @@ -1807,7 +1821,7 @@ static Local<Object> X509ToObject(Environment* env, X509* cert) {
  48. mem->length)).FromJust();
  49. (void) BIO_reset(bio);
  50. - ASN1_TIME_print(bio, X509_get_notAfter(cert));
  51. + ASN1_TIME_print(bio, X509_get0_notAfter(cert));
  52. BIO_get_mem_ptr(bio, &mem);
  53. info->Set(context, env->valid_to_string(),
  54. String::NewFromUtf8(env->isolate(), mem->data,
  55. @@ -6191,8 +6205,12 @@ void TimingSafeEqual(const FunctionCallbackInfo<Value>& args) {
  56. }
  57. void InitCryptoOnce() {
  58. +#if OPENSSL_VERSION_NUMBER < 0x10100000L
  59. SSL_load_error_strings();
  60. OPENSSL_no_config();
  61. +#else
  62. + OPENSSL_init_crypto(OPENSSL_INIT_NO_LOAD_CONFIG, NULL);
  63. +#endif
  64. // --openssl-config=...
  65. if (!openssl_config.empty()) {
  66. @@ -6214,10 +6232,10 @@ void InitCryptoOnce() {
  67. }
  68. }
  69. +#if OPENSSL_VERSION_NUMBER < 0x10100000L
  70. SSL_library_init();
  71. OpenSSL_add_all_algorithms();
  72. -#if OPENSSL_VERSION_NUMBER < 0x10100000L
  73. crypto_lock_init();
  74. CRYPTO_set_locking_callback(crypto_lock_cb);
  75. CRYPTO_THREADID_set_callback(crypto_threadid_cb);
  76. diff --git a/src/node_crypto.h b/src/node_crypto.h
  77. index 58f5b72..875a787 100644
  78. --- a/src/node_crypto.h
  79. +++ b/src/node_crypto.h
  80. @@ -37,6 +37,9 @@
  81. #include "v8.h"
  82. #include <openssl/ssl.h>
  83. +#include <openssl/bn.h>
  84. +#include <openssl/rsa.h>
  85. +#include <openssl/dh.h>
  86. #include <openssl/ec.h>
  87. #include <openssl/ecdh.h>
  88. #ifndef OPENSSL_NO_ENGINE