From f61928ba35422892a1c7225664b660998202fc08 Mon Sep 17 00:00:00 2001 From: James M Snell <jasnell@gmail.com> Date: Mon, 27 Apr 2020 13:43:50 -0700 Subject: [PATCH] src: return undefined when validation err == 0 Extracted from the QUIC PR. Not specific to QUIC even if the behavior is currently only used there. Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: https://github.com/nodejs/node/pull/33107 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> --- src/node_crypto_common.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/node_crypto_common.cc b/src/node_crypto_common.cc index 9358edb66b3cb9..3b35ee1ff7ba8a 100644 --- a/src/node_crypto_common.cc +++ b/src/node_crypto_common.cc @@ -34,6 +34,7 @@ using v8::NewStringType; using v8::Null; using v8::Object; using v8::String; +using v8::Undefined; using v8::Value; namespace crypto { @@ -330,11 +331,15 @@ const char* X509ErrorCode(long err) { // NOLINT(runtime/int) } MaybeLocal<Value> GetValidationErrorReason(Environment* env, int err) { + if (err == 0) + return Undefined(env->isolate()); const char* reason = X509_verify_cert_error_string(err); return OneByteString(env->isolate(), reason); } MaybeLocal<Value> GetValidationErrorCode(Environment* env, int err) { + if (err == 0) + return Undefined(env->isolate()); return OneByteString(env->isolate(), X509ErrorCode(err)); }