From ac8dba32247a2f074f820ceff5f627b1d1a0bd06 Mon Sep 17 00:00:00 2001 From: James M Snell 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 PR-URL: https://github.com/nodejs/node/pull/33107 Reviewed-By: Anna Henningsen Reviewed-By: Sam Roberts --- 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 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 GetValidationErrorCode(Environment* env, int err) { + if (err == 0) + return Undefined(env->isolate()); return OneByteString(env->isolate(), X509ErrorCode(err)); }