@@ -113,6 +113,28 @@ using v8::String;
113113using v8::Value;
114114
115115
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+
116138// Subject DER of CNNIC ROOT CA and CNNIC EV ROOT CA are taken from
117139// https://hg.mozilla.org/mozilla-central/file/98820360ab66/security/
118140// certverifier/NSSCertDBTrustDomain.cpp#l672
@@ -159,11 +181,19 @@ template void SSLWrap<TLSWrap>::AddMethods(Environment* env,
159181template void SSLWrap<TLSWrap>::InitNPN(SecureContext* sc);
160182template void SSLWrap<TLSWrap>::SetSNIContext(SecureContext* sc);
161183template int SSLWrap<TLSWrap>::SetCACerts(SecureContext* sc);
184+ #if OPENSSL_VERSION_NUMBER < 0x10100000L
162185template SSL_SESSION* SSLWrap<TLSWrap>::GetSessionCallback(
163186 SSL* s,
164187 unsigned char* key,
165188 int len,
166189 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
167197template int SSLWrap<TLSWrap>::NewSessionCallback(SSL* s,
168198 SSL_SESSION* sess);
169199template void SSLWrap<TLSWrap>::OnClientHello(
@@ -760,22 +790,6 @@ void SecureContext::SetCert(const FunctionCallbackInfo<Value>& args) {
760790}
761791
762792
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-
779793static X509_STORE* NewRootCertStore() {
780794 static std::vector<X509*> root_certs_vector;
781795 if (root_certs_vector.empty()) {
@@ -1225,7 +1239,7 @@ void SecureContext::SetTicketKeys(const FunctionCallbackInfo<Value>& args) {
12251239
12261240
12271241void SecureContext::SetFreeListLength(const FunctionCallbackInfo<Value>& args) {
1228- #if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(OPENSSL_IS_BORINGSSL)
1242+ #if OPENSSL_VERSION_NUMBER < 0x10100000L
12291243 // |freelist_max_len| was removed in OpenSSL 1.1.0. In that version OpenSSL
12301244 // mallocs and frees buffers directly, without the use of a freelist.
12311245 SecureContext* wrap;
@@ -1432,11 +1446,19 @@ void SSLWrap<Base>::InitNPN(SecureContext* sc) {
14321446}
14331447
14341448
1449+ #if OPENSSL_VERSION_NUMBER < 0x10100000L
14351450template <class Base>
14361451SSL_SESSION* SSLWrap<Base>::GetSessionCallback(SSL* s,
14371452 unsigned char* key,
14381453 int len,
14391454 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
14401462 Base* w = static_cast<Base*>(SSL_get_app_data(s));
14411463
14421464 *copy = 0;
@@ -1946,13 +1968,18 @@ void SSLWrap<Base>::GetTLSTicket(const FunctionCallbackInfo<Value>& args) {
19461968 Environment* env = w->ssl_env();
19471969
19481970 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)
19501979 return;
19511980
19521981 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();
19561983
19571984 args.GetReturnValue().Set(buff);
19581985}
@@ -2479,7 +2506,7 @@ int SSLWrap<Base>::SSLCertCallback(SSL* s, void* arg) {
24792506
24802507 bool ocsp = false;
24812508#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;
24832510#endif
24842511
24852512 info->Set(env->ocsp_request_string(), Boolean::New(env->isolate(), ocsp));
0 commit comments