tls: add "ca" property to certificate object by bnoordhuis · Pull Request #44935 · nodejs/node · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/api/tls.md
6 changes: 5 additions & 1 deletion src/crypto/crypto_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace node {
using v8::Array;
using v8::ArrayBuffer;
using v8::BackingStore;
using v8::Boolean;
using v8::Context;
using v8::EscapableHandleScope;
using v8::Integer;
Expand Down Expand Up @@ -1266,6 +1267,8 @@ MaybeLocal<Object> X509ToObject(
BIOPointer bio(BIO_new(BIO_s_mem()));
CHECK(bio);

// X509_check_ca() returns a range of values. Only 1 means "is a CA"
auto is_ca = Boolean::New(env->isolate(), 1 == X509_check_ca(cert));
if (!Set<Value>(context,
info,
env->subject_string(),
Expand All @@ -1281,7 +1284,8 @@ MaybeLocal<Object> X509ToObject(
!Set<Value>(context,
info,
env->infoaccess_string(),
GetInfoAccessString(env, bio, cert))) {
GetInfoAccessString(env, bio, cert)) ||
!Set<Boolean>(context, info, env->ca_string(), is_ca)) {
return MaybeLocal<Object>();
}

Expand Down
1 change: 1 addition & 0 deletions src/env_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
V(bytes_parsed_string, "bytesParsed") \
V(bytes_read_string, "bytesRead") \
V(bytes_written_string, "bytesWritten") \
V(ca_string, "ca") \
V(cached_data_produced_string, "cachedDataProduced") \
V(cached_data_rejected_string, "cachedDataRejected") \
V(cached_data_string, "cachedData") \
Expand Down
2 changes: 2 additions & 0 deletions test/parallel/test-tls-peer-certificate.js