| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent cc744b9 commit 6a9c528
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -113,6 +113,28 @@ using v8::String; | |||
| 113 | 113 | using v8::Value; | |
| 114 | 114 | ||
| 115 | 115 | ||
| 116 | + #if OPENSSL_VERSION_NUMBER < 0x10100000L | ||
| 117 | + static void SSL_SESSION_get0_ticket(const SSL_SESSION* s, | ||
| 118 | + const unsigned char** tick, size_t* len) { | ||
| 119 | + *len = s->tlsext_ticklen; | ||
| 120 | + if (tick != nullptr) { | ||
| 121 | + *tick = s->tlsext_tick; | ||
| 122 | + } | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + #define SSL_get_tlsext_status_type(ssl) (ssl->tlsext_status_type) | ||
| 126 | + | ||
| 127 | + static int X509_STORE_up_ref(X509_STORE* store) { | ||
| 128 | + CRYPTO_add(&store->references, 1, CRYPTO_LOCK_X509_STORE); | ||
| 129 | + return 1; | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + static int X509_up_ref(X509* cert) { | ||
| 133 | + CRYPTO_add(&cert->references, 1, CRYPTO_LOCK_X509); | ||
| 134 | + return 1; | ||
| 135 | + } | ||
| 136 | + #endif // OPENSSL_VERSION_NUMBER < 0x10100000L | ||
| 137 | + | ||
| 116 | 138 | // Subject DER of CNNIC ROOT CA and CNNIC EV ROOT CA are taken from | |
| 117 | 139 | // https://hg.mozilla.org/mozilla-central/file/98820360ab66/security/ | |
| 118 | 140 | // certverifier/NSSCertDBTrustDomain.cpp#l672 | |
@@ -159,11 +181,19 @@ template void SSLWrap<TLSWrap>::AddMethods(Environment* env, | |||
| 159 | 181 | template void SSLWrap<TLSWrap>::InitNPN(SecureContext* sc); | |
| 160 | 182 | template void SSLWrap<TLSWrap>::SetSNIContext(SecureContext* sc); | |
| 161 | 183 | template int SSLWrap<TLSWrap>::SetCACerts(SecureContext* sc); | |
| 184 | + #if OPENSSL_VERSION_NUMBER < 0x10100000L | ||
| 162 | 185 | template SSL_SESSION* SSLWrap<TLSWrap>::GetSessionCallback( | |
| 163 | 186 | SSL* s, | |
| 164 | 187 | unsigned char* key, | |
| 165 | 188 | int len, | |
| 166 | 189 | int* copy); | |
| 190 | + #else | ||
| 191 | + template SSL_SESSION* SSLWrap<TLSWrap>::GetSessionCallback( | ||
| 192 | + SSL* s, | ||
| 193 | + const unsigned char* key, | ||
| 194 | + int len, | ||
| 195 | + int* copy); | ||
| 196 | + #endif | ||
| 167 | 197 | template int SSLWrap<TLSWrap>::NewSessionCallback(SSL* s, | |
| 168 | 198 | SSL_SESSION* sess); | |
| 169 | 199 | template void SSLWrap<TLSWrap>::OnClientHello( | |
@@ -760,22 +790,6 @@ void SecureContext::SetCert(const FunctionCallbackInfo<Value>& args) { | |||
| 760 | 790 | } | |
| 761 | 791 | ||
| 762 | 792 | ||
| 763 | - #if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(OPENSSL_IS_BORINGSSL) | ||
| 764 | - // This section contains OpenSSL 1.1.0 functions reimplemented for OpenSSL | ||
| 765 | - // 1.0.2 so that the following code can be written without lots of #if lines. | ||
| 766 | - | ||
| 767 | - static int X509_STORE_up_ref(X509_STORE* store) { | ||
| 768 | - CRYPTO_add(&store->references, 1, CRYPTO_LOCK_X509_STORE); | ||
| 769 | - return 1; | ||
| 770 | - } | ||
| 771 | - | ||
| 772 | - static int X509_up_ref(X509* cert) { | ||
| 773 | - CRYPTO_add(&cert->references, 1, CRYPTO_LOCK_X509); | ||
| 774 | - return 1; | ||
| 775 | - } | ||
| 776 | - #endif // OPENSSL_VERSION_NUMBER < 0x10100000L && !OPENSSL_IS_BORINGSSL | ||
| 777 | - | ||
| 778 | - | ||
| 779 | 793 | static X509_STORE* NewRootCertStore() { | |
| 780 | 794 | static std::vector<X509*> root_certs_vector; | |
| 781 | 795 | if (root_certs_vector.empty()) { | |
@@ -1225,7 +1239,7 @@ void SecureContext::SetTicketKeys(const FunctionCallbackInfo<Value>& args) { | |||
| 1225 | 1239 | ||
| 1226 | 1240 | ||
| 1227 | 1241 | void SecureContext::SetFreeListLength(const FunctionCallbackInfo<Value>& args) { | |
| 1228 | - #if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(OPENSSL_IS_BORINGSSL) | ||
| 1242 | + #if OPENSSL_VERSION_NUMBER < 0x10100000L | ||
| 1229 | 1243 | // |freelist_max_len| was removed in OpenSSL 1.1.0. In that version OpenSSL | |
| 1230 | 1244 | // mallocs and frees buffers directly, without the use of a freelist. | |
| 1231 | 1245 | SecureContext* wrap; | |
@@ -1432,11 +1446,19 @@ void SSLWrap<Base>::InitNPN(SecureContext* sc) { | |||
| 1432 | 1446 | } | |
| 1433 | 1447 | ||
| 1434 | 1448 | ||
| 1449 | + #if OPENSSL_VERSION_NUMBER < 0x10100000L | ||
| 1435 | 1450 | template <class Base> | |
| 1436 | 1451 | SSL_SESSION* SSLWrap<Base>::GetSessionCallback(SSL* s, | |
| 1437 | 1452 | unsigned char* key, | |
| 1438 | 1453 | int len, | |
| 1439 | 1454 | int* copy) { | |
| 1455 | + #else | ||
| 1456 | + template <class Base> | ||
| 1457 | + SSL_SESSION* SSLWrap<Base>::GetSessionCallback(SSL* s, | ||
| 1458 | + const unsigned char* key, | ||
| 1459 | + int len, | ||
| 1460 | + int* copy) { | ||
| 1461 | + #endif | ||
| 1440 | 1462 | Base* w = static_cast<Base*>(SSL_get_app_data(s)); | |
| 1441 | 1463 | ||
| 1442 | 1464 | *copy = 0; | |
@@ -1946,13 +1968,18 @@ void SSLWrap<Base>::GetTLSTicket(const FunctionCallbackInfo<Value>& args) { | |||
| 1946 | 1968 | Environment* env = w->ssl_env(); | |
| 1947 | 1969 | ||
| 1948 | 1970 | SSL_SESSION* sess = SSL_get_session(w->ssl_); | |
| 1949 | - if (sess == nullptr || sess->tlsext_tick == nullptr) | ||
| 1971 | + if (sess == nullptr) | ||
| 1972 | + return; | ||
| 1973 | + | ||
| 1974 | + const unsigned char *ticket; | ||
| 1975 | + size_t length; | ||
| 1976 | + SSL_SESSION_get0_ticket(sess, &ticket, &length); | ||
| 1977 | + | ||
| 1978 | + if (ticket == nullptr) | ||
| 1950 | 1979 | return; | |
| 1951 | 1980 | ||
| 1952 | 1981 | Local<Object> buff = Buffer::Copy( | |
| 1953 | - env, | ||
| 1954 | - reinterpret_cast<char*>(sess->tlsext_tick), | ||
| 1955 | - sess->tlsext_ticklen).ToLocalChecked(); | ||
| 1982 | + env, reinterpret_cast<const char*>(ticket), length).ToLocalChecked(); | ||
| 1956 | 1983 | ||
| 1957 | 1984 | args.GetReturnValue().Set(buff); | |
| 1958 | 1985 | } | |
@@ -2479,7 +2506,7 @@ int SSLWrap<Base>::SSLCertCallback(SSL* s, void* arg) { | |||
| 2479 | 2506 | ||
| 2480 | 2507 | bool ocsp = false; | |
| 2481 | 2508 | #ifdef NODE__HAVE_TLSEXT_STATUS_CB | |
| 2482 | - ocsp = s->tlsext_status_type == TLSEXT_STATUSTYPE_ocsp; | ||
| 2509 | + ocsp = SSL_get_tlsext_status_type(s) == TLSEXT_STATUSTYPE_ocsp; | ||
| 2483 | 2510 | #endif | |
| 2484 | 2511 | ||
| 2485 | 2512 | info->Set(env->ocsp_request_string(), Boolean::New(env->isolate(), ocsp)); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -241,10 +241,17 @@ class SSLWrap { | |||
| 241 | 241 | static void InitNPN(SecureContext* sc); | |
| 242 | 242 | static void AddMethods(Environment* env, v8::Local<v8::FunctionTemplate> t); | |
| 243 | 243 | ||
| 244 | + #if OPENSSL_VERSION_NUMBER < 0x10100000L | ||
| 244 | 245 | static SSL_SESSION* GetSessionCallback(SSL* s, | |
| 245 | 246 | unsigned char* key, | |
| 246 | 247 | int len, | |
| 247 | 248 | int* copy); | |
| 249 | + #else | ||
| 250 | + static SSL_SESSION* GetSessionCallback(SSL* s, | ||
| 251 | + const unsigned char* key, | ||
| 252 | + int len, | ||
| 253 | + int* copy); | ||
| 254 | + #endif | ||
| 248 | 255 | static int NewSessionCallback(SSL* s, SSL_SESSION* sess); | |
| 249 | 256 | static void OnClientHello(void* arg, | |
| 250 | 257 | const ClientHelloParser::ClientHello& hello); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments