diff --git a/deps/ncrypto/engine.cc b/deps/ncrypto/engine.cc index cffd95a38eb612..7e74f73f212fd7 100644 --- a/deps/ncrypto/engine.cc +++ b/deps/ncrypto/engine.cc @@ -70,7 +70,7 @@ bool EnginePointer::setAsDefault(uint32_t flags, CryptoErrorList* errors) { bool EnginePointer::init(bool finish_on_exit) { if (engine == nullptr) return false; if (finish_on_exit) setFinishOnExit(); - return ENGINE_init(engine) != 0; + return ENGINE_init(engine) == 1; } EVPKeyPointer EnginePointer::loadPrivateKey(const std::string_view key_name) { diff --git a/deps/ncrypto/ncrypto.cc b/deps/ncrypto/ncrypto.cc index 919dc4791667a4..b3e6a57edc1b0e 100644 --- a/deps/ncrypto/ncrypto.cc +++ b/deps/ncrypto/ncrypto.cc @@ -1,5 +1,6 @@ #include "ncrypto.h" #include +#include #include "openssl/bn.h" #if OPENSSL_VERSION_MAJOR >= 3 #include "openssl/provider.h" diff --git a/src/crypto/crypto_context.cc b/src/crypto/crypto_context.cc index b844c9bd205188..8206e941dc1f7d 100644 --- a/src/crypto/crypto_context.cc +++ b/src/crypto/crypto_context.cc @@ -671,7 +671,7 @@ void SecureContext::SetEngineKey(const FunctionCallbackInfo& args) { return; } - if (engine.init(true /* finish on exit*/)) { + if (!engine.init(true /* finish on exit*/)) { return THROW_ERR_CRYPTO_OPERATION_FAILED( env, "Failure to initialize engine"); } diff --git a/src/crypto/crypto_util.cc b/src/crypto/crypto_util.cc index bb3a66a9cd9e62..9c8f6d6f447294 100644 --- a/src/crypto/crypto_util.cc +++ b/src/crypto/crypto_util.cc @@ -243,7 +243,7 @@ bool CryptoErrorStore::Empty() const { return errors_.empty(); } -v8::MaybeLocal cryptoErrorListToException( +MaybeLocal cryptoErrorListToException( Environment* env, const ncrypto::CryptoErrorList& errors) { // The CryptoErrorList contains a listing of zero or more errors. // If there are no errors, it is likely a bug but we will return @@ -261,7 +261,7 @@ v8::MaybeLocal cryptoErrorListToException( if (!String::NewFromUtf8( env->isolate(), last.data(), NewStringType::kNormal, last.size()) .ToLocal(&message)) { - return MaybeLocal(); + return {}; } Local exception = Exception::Error(message); @@ -277,13 +277,9 @@ v8::MaybeLocal cryptoErrorListToException( auto last = errors.end(); last--; while (current != last) { - Local error; - if (!String::NewFromUtf8(env->isolate(), - current->data(), - NewStringType::kNormal, - current->size()) - .ToLocal(&error)) { - return MaybeLocal(); + Local error; + if (!ToV8Value(env->context(), *current).ToLocal(&error)) { + return {}; } stack.push_back(error); ++current; @@ -295,7 +291,7 @@ v8::MaybeLocal cryptoErrorListToException( if (!exception_obj ->Set(env->context(), env->openssl_error_stack(), stackArray) .IsNothing()) { - return MaybeLocal(); + return {}; } } return exception; diff --git a/src/node_metadata.cc b/src/node_metadata.cc index 0709501b5ea891..918a3b4ecfc0ea 100644 --- a/src/node_metadata.cc +++ b/src/node_metadata.cc @@ -31,7 +31,7 @@ #endif #endif // HAVE_OPENSSL -#ifdef OPENSSL_INFO_QUIC +#ifdef HAVE_OPENSSL && OPENSSL_INFO_QUIC #include #include #endif diff --git a/test/parallel/test-process-versions.js b/test/parallel/test-process-versions.js index bab483a7e2637e..108ea9d67d7c70 100644 --- a/test/parallel/test-process-versions.js +++ b/test/parallel/test-process-versions.js @@ -34,6 +34,7 @@ if (hasUndici) { if (common.hasCrypto) { expected_keys.push('openssl'); + expected_keys.push('ncrypto'); } if (common.hasQuic) { @@ -78,6 +79,7 @@ assert.match(process.versions.modules, /^\d+$/); assert.match(process.versions.cjs_module_lexer, commonTemplate); if (common.hasCrypto) { + assert.match(process.versions.ncrypto, commonTemplate); if (process.config.variables.node_shared_openssl) { assert.ok(process.versions.openssl); } else {