Skip to content

Commit

Permalink
src: return undefined when validation err == 0
Browse files Browse the repository at this point in the history
Extracted from the QUIC PR. Not specific to QUIC even if the
behavior is currently only used there.

Signed-off-by: James M Snell <[email protected]>

PR-URL: #33107
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Sam Roberts <[email protected]>
  • Loading branch information
jasnell authored and targos committed May 4, 2020
1 parent f4e5ab1 commit f61928b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/node_crypto_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ using v8::NewStringType;
using v8::Null;
using v8::Object;
using v8::String;
using v8::Undefined;
using v8::Value;

namespace crypto {
Expand Down Expand Up @@ -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));
}

Expand Down

0 comments on commit f61928b

Please sign in to comment.