@@ -523,8 +523,12 @@ int SSL_CTX_use_certificate_chain(SSL_CTX* ctx,
523
523
for (int i = 0 ; i < sk_X509_num (extra_certs); i++) {
524
524
X509* ca = sk_X509_value (extra_certs, i);
525
525
526
+ #ifdef LIBRESSL_VERSION_NUMBER
527
+ r = SSL_CTX_add_extra_chain_cert (ctx, ca);
528
+ #else
526
529
// NOTE: Increments reference count on `ca`
527
530
r = SSL_CTX_add1_chain_cert (ctx, ca);
531
+ #endif // LIBRESSL_VERSION_NUMBER
528
532
529
533
if (!r) {
530
534
ret = 0 ;
@@ -680,7 +684,7 @@ void SecureContext::SetCert(const FunctionCallbackInfo<Value>& args) {
680
684
}
681
685
682
686
683
- #if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(OPENSSL_IS_BORINGSSL)
687
+ #if ( OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(OPENSSL_IS_BORINGSSL)) || defined(LIBRESSL_VERSION_NUMBER )
684
688
// This section contains OpenSSL 1.1.0 functions reimplemented for OpenSSL
685
689
// 1.0.2 so that the following code can be written without lots of #if lines.
686
690
@@ -693,7 +697,7 @@ static int X509_up_ref(X509* cert) {
693
697
CRYPTO_add (&cert->references , 1 , CRYPTO_LOCK_X509);
694
698
return 1 ;
695
699
}
696
- #endif // OPENSSL_VERSION_NUMBER < 0x10100000L && !OPENSSL_IS_BORINGSSL
700
+ #endif // ( OPENSSL_VERSION_NUMBER < 0x10100000L && !OPENSSL_IS_BORINGSSL) || defined(LIBRESSL_VERSION_NUMBER)
697
701
698
702
699
703
static X509_STORE* NewRootCertStore () {
@@ -1153,7 +1157,7 @@ void SecureContext::SetTicketKeys(const FunctionCallbackInfo<Value>& args) {
1153
1157
1154
1158
1155
1159
void SecureContext::SetFreeListLength (const FunctionCallbackInfo<Value>& args) {
1156
- #if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(OPENSSL_IS_BORINGSSL)
1160
+ #if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(OPENSSL_IS_BORINGSSL) && !defined(LIBRESSL_VERSION_NUMBER)
1157
1161
// |freelist_max_len| was removed in OpenSSL 1.1.0. In that version OpenSSL
1158
1162
// mallocs and frees buffers directly, without the use of a freelist.
1159
1163
SecureContext* wrap;
@@ -1930,6 +1934,10 @@ void SSLWrap<Base>::RequestOCSP(
1930
1934
template <class Base >
1931
1935
void SSLWrap<Base>::GetEphemeralKeyInfo(
1932
1936
const v8::FunctionCallbackInfo<v8::Value>& args) {
1937
+ #ifdef LIBRESSL_VERSION_NUMBER
1938
+ Environment* env = Environment::GetCurrent (args);
1939
+ env->ThrowError (" getEphemeralKeyInfo() not supported when using LibreSSL" );
1940
+ #else
1933
1941
Base* w;
1934
1942
ASSIGN_OR_RETURN_UNWRAP (&w, args.Holder ());
1935
1943
Environment* env = Environment::GetCurrent (args);
@@ -1968,7 +1976,8 @@ void SSLWrap<Base>::GetEphemeralKeyInfo(
1968
1976
EVP_PKEY_free (key);
1969
1977
}
1970
1978
1971
- return args.GetReturnValue ().Set (info);
1979
+ args.GetReturnValue ().Set (info);
1980
+ #endif // LIBRESSL_VERSION_NUMBER
1972
1981
}
1973
1982
1974
1983
@@ -2449,8 +2458,9 @@ void SSLWrap<Base>::CertCbDone(const FunctionCallbackInfo<Value>& args) {
2449
2458
w->sni_context_ .Reset ();
2450
2459
w->sni_context_ .Reset (env->isolate (), ctx);
2451
2460
2452
- int rv;
2461
+ int rv = 1 ;
2453
2462
2463
+ #ifndef LIBRESSL_VERSION_NUMBER
2454
2464
// NOTE: reference count is not increased by this API methods
2455
2465
X509* x509 = SSL_CTX_get0_certificate (sc->ctx_ );
2456
2466
EVP_PKEY* pkey = SSL_CTX_get0_privatekey (sc->ctx_ );
@@ -2463,6 +2473,8 @@ void SSLWrap<Base>::CertCbDone(const FunctionCallbackInfo<Value>& args) {
2463
2473
rv = SSL_use_PrivateKey (w->ssl_ , pkey);
2464
2474
if (rv && chain != nullptr )
2465
2475
rv = SSL_set1_chain (w->ssl_ , chain);
2476
+ #endif // LIBRESSL_VERSION_NUMBER
2477
+
2466
2478
if (rv)
2467
2479
rv = w->SetCACerts (sc);
2468
2480
if (!rv) {
@@ -2526,9 +2538,11 @@ void SSLWrap<Base>::SetSNIContext(SecureContext* sc) {
2526
2538
2527
2539
template <class Base >
2528
2540
int SSLWrap<Base>::SetCACerts(SecureContext* sc) {
2541
+ #ifndef LIBRESSL_VERSION_NUMBER
2529
2542
int err = SSL_set1_verify_cert_store (ssl_, SSL_CTX_get_cert_store (sc->ctx_ ));
2530
2543
if (err != 1 )
2531
2544
return err;
2545
+ #endif // LIBRESSL_VERSION_NUMBER
2532
2546
2533
2547
STACK_OF (X509_NAME)* list = SSL_dup_CA_list (
2534
2548
SSL_CTX_get_client_CA_list (sc->ctx_ ));
@@ -2841,7 +2855,7 @@ inline int VerifyCallback(int preverify_ok, X509_STORE_CTX* ctx) {
2841
2855
SSL* ssl = static_cast <SSL*>(
2842
2856
X509_STORE_CTX_get_ex_data (ctx, SSL_get_ex_data_X509_STORE_CTX_idx ()));
2843
2857
2844
- if (SSL_is_server ( ssl) )
2858
+ if (ssl-> server )
2845
2859
return 1 ;
2846
2860
2847
2861
// Client needs to check if the server cert is listed in the
@@ -2924,7 +2938,9 @@ void Connection::New(const FunctionCallbackInfo<Value>& args) {
2924
2938
2925
2939
InitNPN (sc);
2926
2940
2941
+ #ifndef LIBRESSL_VERSION_NUMBER
2927
2942
SSL_set_cert_cb (conn->ssl_ , SSLWrap<Connection>::SSLCertCallback, conn);
2943
+ #endif // LIBRESSL_VERSION_NUMBER
2928
2944
2929
2945
#ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
2930
2946
if (is_server) {
@@ -5976,11 +5992,11 @@ void SetEngine(const FunctionCallbackInfo<Value>& args) {
5976
5992
#endif // !OPENSSL_NO_ENGINE
5977
5993
5978
5994
void GetFipsCrypto (const FunctionCallbackInfo<Value>& args) {
5979
- if ( FIPS_mode ()) {
5980
- args.GetReturnValue ().Set (1 );
5981
- } else {
5982
- args.GetReturnValue ().Set (0 );
5983
- }
5995
+ # ifdef NODE_FIPS_MODE
5996
+ args.GetReturnValue ().Set (FIPS_mode () );
5997
+ # else
5998
+ args.GetReturnValue ().Set (0 );
5999
+ # endif
5984
6000
}
5985
6001
5986
6002
void SetFipsCrypto (const FunctionCallbackInfo<Value>& args) {
0 commit comments