@@ -114,6 +114,28 @@ using v8::String;
114
114
using v8::Value;
115
115
116
116
117
+ #if OPENSSL_VERSION_NUMBER < 0x10100000L
118
+ static void SSL_SESSION_get0_ticket (const SSL_SESSION* s,
119
+ const unsigned char ** tick, size_t * len) {
120
+ *len = s->tlsext_ticklen ;
121
+ if (tick != nullptr ) {
122
+ *tick = s->tlsext_tick ;
123
+ }
124
+ }
125
+
126
+ #define SSL_get_tlsext_status_type (ssl ) (ssl->tlsext_status_type)
127
+
128
+ static int X509_STORE_up_ref (X509_STORE* store) {
129
+ CRYPTO_add (&store->references , 1 , CRYPTO_LOCK_X509_STORE);
130
+ return 1 ;
131
+ }
132
+
133
+ static int X509_up_ref (X509* cert) {
134
+ CRYPTO_add (&cert->references , 1 , CRYPTO_LOCK_X509);
135
+ return 1 ;
136
+ }
137
+ #endif // OPENSSL_VERSION_NUMBER < 0x10100000L
138
+
117
139
// Subject DER of CNNIC ROOT CA and CNNIC EV ROOT CA are taken from
118
140
// https://hg.mozilla.org/mozilla-central/file/98820360ab66/security/
119
141
// certverifier/NSSCertDBTrustDomain.cpp#l672
@@ -158,11 +180,19 @@ template void SSLWrap<TLSWrap>::AddMethods(Environment* env,
158
180
template void SSLWrap<TLSWrap>::InitNPN(SecureContext* sc);
159
181
template void SSLWrap<TLSWrap>::SetSNIContext(SecureContext* sc);
160
182
template int SSLWrap<TLSWrap>::SetCACerts(SecureContext* sc);
183
+ #if OPENSSL_VERSION_NUMBER < 0x10100000L
161
184
template SSL_SESSION* SSLWrap<TLSWrap>::GetSessionCallback(
162
185
SSL* s,
163
186
unsigned char * key,
164
187
int len,
165
188
int * copy);
189
+ #else
190
+ template SSL_SESSION* SSLWrap<TLSWrap>::GetSessionCallback(
191
+ SSL* s,
192
+ const unsigned char * key,
193
+ int len,
194
+ int * copy);
195
+ #endif
166
196
template int SSLWrap<TLSWrap>::NewSessionCallback(SSL* s,
167
197
SSL_SESSION* sess);
168
198
template void SSLWrap<TLSWrap>::OnClientHello(
@@ -759,22 +789,6 @@ void SecureContext::SetCert(const FunctionCallbackInfo<Value>& args) {
759
789
}
760
790
761
791
762
- #if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(OPENSSL_IS_BORINGSSL)
763
- // This section contains OpenSSL 1.1.0 functions reimplemented for OpenSSL
764
- // 1.0.2 so that the following code can be written without lots of #if lines.
765
-
766
- static int X509_STORE_up_ref (X509_STORE* store) {
767
- CRYPTO_add (&store->references , 1 , CRYPTO_LOCK_X509_STORE);
768
- return 1 ;
769
- }
770
-
771
- static int X509_up_ref (X509* cert) {
772
- CRYPTO_add (&cert->references , 1 , CRYPTO_LOCK_X509);
773
- return 1 ;
774
- }
775
- #endif // OPENSSL_VERSION_NUMBER < 0x10100000L && !OPENSSL_IS_BORINGSSL
776
-
777
-
778
792
static X509_STORE* NewRootCertStore () {
779
793
static std::vector<X509*> root_certs_vector;
780
794
if (root_certs_vector.empty ()) {
@@ -1221,7 +1235,7 @@ void SecureContext::SetTicketKeys(const FunctionCallbackInfo<Value>& args) {
1221
1235
1222
1236
1223
1237
void SecureContext::SetFreeListLength (const FunctionCallbackInfo<Value>& args) {
1224
- #if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(OPENSSL_IS_BORINGSSL)
1238
+ #if OPENSSL_VERSION_NUMBER < 0x10100000L
1225
1239
// |freelist_max_len| was removed in OpenSSL 1.1.0. In that version OpenSSL
1226
1240
// mallocs and frees buffers directly, without the use of a freelist.
1227
1241
SecureContext* wrap;
@@ -1428,11 +1442,19 @@ void SSLWrap<Base>::InitNPN(SecureContext* sc) {
1428
1442
}
1429
1443
1430
1444
1445
+ #if OPENSSL_VERSION_NUMBER < 0x10100000L
1431
1446
template <class Base >
1432
1447
SSL_SESSION* SSLWrap<Base>::GetSessionCallback(SSL* s,
1433
1448
unsigned char * key,
1434
1449
int len,
1435
1450
int * copy) {
1451
+ #else
1452
+ template <class Base >
1453
+ SSL_SESSION* SSLWrap<Base>::GetSessionCallback (SSL* s,
1454
+ const unsigned char * key,
1455
+ int len,
1456
+ int * copy) {
1457
+ #endif
1436
1458
Base* w = static_cast <Base*>(SSL_get_app_data (s));
1437
1459
1438
1460
*copy = 0 ;
@@ -1942,13 +1964,18 @@ void SSLWrap<Base>::GetTLSTicket(const FunctionCallbackInfo<Value>& args) {
1942
1964
Environment* env = w->ssl_env ();
1943
1965
1944
1966
SSL_SESSION* sess = SSL_get_session (w->ssl_ );
1945
- if (sess == nullptr || sess->tlsext_tick == nullptr )
1967
+ if (sess == nullptr )
1968
+ return ;
1969
+
1970
+ const unsigned char *ticket;
1971
+ size_t length;
1972
+ SSL_SESSION_get0_ticket (sess, &ticket, &length);
1973
+
1974
+ if (ticket == nullptr )
1946
1975
return ;
1947
1976
1948
1977
Local<Object> buff = Buffer::Copy (
1949
- env,
1950
- reinterpret_cast <char *>(sess->tlsext_tick ),
1951
- sess->tlsext_ticklen ).ToLocalChecked ();
1978
+ env, reinterpret_cast <const char *>(ticket), length).ToLocalChecked ();
1952
1979
1953
1980
args.GetReturnValue ().Set (buff);
1954
1981
}
@@ -2475,7 +2502,7 @@ int SSLWrap<Base>::SSLCertCallback(SSL* s, void* arg) {
2475
2502
2476
2503
bool ocsp = false ;
2477
2504
#ifdef NODE__HAVE_TLSEXT_STATUS_CB
2478
- ocsp = s-> tlsext_status_type == TLSEXT_STATUSTYPE_ocsp;
2505
+ ocsp = SSL_get_tlsext_status_type (s) == TLSEXT_STATUSTYPE_ocsp;
2479
2506
#endif
2480
2507
2481
2508
info->Set (env->ocsp_request_string (), Boolean::New (env->isolate (), ocsp));
0 commit comments