Skip to content

Commit

Permalink
src: test and code review updates [squash]
Browse files Browse the repository at this point in the history
  • Loading branch information
jasnell committed Jul 10, 2024
1 parent 067c59f commit 590774a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion deps/ncrypto/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions deps/ncrypto/ncrypto.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "ncrypto.h"
#include <algorithm>
#include <cstring>
#include "openssl/bn.h"
#if OPENSSL_VERSION_MAJOR >= 3
#include "openssl/provider.h"
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/crypto_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ void SecureContext::SetEngineKey(const FunctionCallbackInfo<Value>& 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");
}
Expand Down
16 changes: 6 additions & 10 deletions src/crypto/crypto_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ bool CryptoErrorStore::Empty() const {
return errors_.empty();
}

v8::MaybeLocal<v8::Value> cryptoErrorListToException(
MaybeLocal<Value> 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
Expand All @@ -261,7 +261,7 @@ v8::MaybeLocal<v8::Value> cryptoErrorListToException(
if (!String::NewFromUtf8(
env->isolate(), last.data(), NewStringType::kNormal, last.size())
.ToLocal(&message)) {
return MaybeLocal<Value>();
return {};
}

Local<Value> exception = Exception::Error(message);
Expand All @@ -277,13 +277,9 @@ v8::MaybeLocal<v8::Value> cryptoErrorListToException(
auto last = errors.end();
last--;
while (current != last) {
Local<String> error;
if (!String::NewFromUtf8(env->isolate(),
current->data(),
NewStringType::kNormal,
current->size())
.ToLocal(&error)) {
return MaybeLocal<Value>();
Local<Value> error;
if (!ToV8Value(env->context(), *current).ToLocal(&error)) {
return {};
}
stack.push_back(error);
++current;
Expand All @@ -295,7 +291,7 @@ v8::MaybeLocal<v8::Value> cryptoErrorListToException(
if (!exception_obj
->Set(env->context(), env->openssl_error_stack(), stackArray)
.IsNothing()) {
return MaybeLocal<Value>();
return {};
}
}
return exception;
Expand Down
2 changes: 1 addition & 1 deletion src/node_metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#endif
#endif // HAVE_OPENSSL

#ifdef OPENSSL_INFO_QUIC
#ifdef HAVE_OPENSSL && OPENSSL_INFO_QUIC
#include <ngtcp2/version.h>
#include <nghttp3/version.h>
#endif
Expand Down
2 changes: 2 additions & 0 deletions test/parallel/test-process-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ if (hasUndici) {

if (common.hasCrypto) {
expected_keys.push('openssl');
expected_keys.push('ncrypto');
}

if (common.hasQuic) {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 590774a

Please sign in to comment.