GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: crypto/crypto_x509.cc Lines: 262 299 87.6 %
Date: 2021-09-25 04:12:41 Branches: 100 192 52.1 %

Line Branch Exec Source
1
#include "base_object-inl.h"
2
#include "crypto_x509.h"
3
#include "crypto_common.h"
4
#include "crypto_context.h"
5
#include "crypto_keys.h"
6
#include "crypto_bio.h"
7
#include "env-inl.h"
8
#include "memory_tracker-inl.h"
9
#include "node_errors.h"
10
#include "util-inl.h"
11
#include "v8.h"
12
13
#include <string>
14
#include <vector>
15
16
namespace node {
17
18
using v8::ArrayBufferView;
19
using v8::Context;
20
using v8::EscapableHandleScope;
21
using v8::Function;
22
using v8::FunctionCallbackInfo;
23
using v8::FunctionTemplate;
24
using v8::Local;
25
using v8::MaybeLocal;
26
using v8::Object;
27
using v8::Uint32;
28
using v8::Value;
29
30
namespace crypto {
31
32
5
ManagedX509::ManagedX509(X509Pointer&& cert) : cert_(std::move(cert)) {}
33
34
ManagedX509::ManagedX509(const ManagedX509& that) {
35
  *this = that;
36
}
37
38
ManagedX509& ManagedX509::operator=(const ManagedX509& that) {
39
  cert_.reset(that.get());
40
41
  if (cert_)
42
    X509_up_ref(cert_.get());
43
44
  return *this;
45
}
46
47
void ManagedX509::MemoryInfo(MemoryTracker* tracker) const {
48
  // This is an approximation based on the der encoding size.
49
  int size = i2d_X509(cert_.get(), nullptr);
50
  tracker->TrackFieldWithSize("cert", size);
51
}
52
53
8
Local<FunctionTemplate> X509Certificate::GetConstructorTemplate(
54
    Environment* env) {
55
8
  Local<FunctionTemplate> tmpl = env->x509_constructor_template();
56
8
  if (tmpl.IsEmpty()) {
57
2
    tmpl = FunctionTemplate::New(env->isolate());
58
4
    tmpl->InstanceTemplate()->SetInternalFieldCount(
59
        BaseObject::kInternalFieldCount);
60
2
    tmpl->Inherit(BaseObject::GetConstructorTemplate(env));
61
2
    tmpl->SetClassName(
62
        FIXED_ONE_BYTE_STRING(env->isolate(), "X509Certificate"));
63
2
    env->SetProtoMethod(tmpl, "subject", Subject);
64
2
    env->SetProtoMethod(tmpl, "subjectAltName", SubjectAltName);
65
2
    env->SetProtoMethod(tmpl, "infoAccess", InfoAccess);
66
2
    env->SetProtoMethod(tmpl, "issuer", Issuer);
67
2
    env->SetProtoMethod(tmpl, "validTo", ValidTo);
68
2
    env->SetProtoMethod(tmpl, "validFrom", ValidFrom);
69
2
    env->SetProtoMethod(tmpl, "fingerprint", Fingerprint);
70
2
    env->SetProtoMethod(tmpl, "fingerprint256", Fingerprint256);
71
2
    env->SetProtoMethod(tmpl, "keyUsage", KeyUsage);
72
2
    env->SetProtoMethod(tmpl, "serialNumber", SerialNumber);
73
2
    env->SetProtoMethod(tmpl, "pem", Pem);
74
2
    env->SetProtoMethod(tmpl, "raw", Raw);
75
2
    env->SetProtoMethod(tmpl, "publicKey", PublicKey);
76
2
    env->SetProtoMethod(tmpl, "checkCA", CheckCA);
77
2
    env->SetProtoMethod(tmpl, "checkHost", CheckHost);
78
2
    env->SetProtoMethod(tmpl, "checkEmail", CheckEmail);
79
2
    env->SetProtoMethod(tmpl, "checkIP", CheckIP);
80
2
    env->SetProtoMethod(tmpl, "checkIssued", CheckIssued);
81
2
    env->SetProtoMethod(tmpl, "checkPrivateKey", CheckPrivateKey);
82
2
    env->SetProtoMethod(tmpl, "verify", Verify);
83
2
    env->SetProtoMethod(tmpl, "toLegacy", ToLegacy);
84
2
    env->SetProtoMethod(tmpl, "getIssuerCert", GetIssuerCert);
85
2
    env->set_x509_constructor_template(tmpl);
86
  }
87
8
  return tmpl;
88
}
89
90
2
bool X509Certificate::HasInstance(Environment* env, Local<Object> object) {
91
4
  return GetConstructorTemplate(env)->HasInstance(object);
92
}
93
94
5
MaybeLocal<Object> X509Certificate::New(
95
    Environment* env,
96
    X509Pointer cert,
97
    STACK_OF(X509)* issuer_chain) {
98
5
  std::shared_ptr<ManagedX509> mcert(new ManagedX509(std::move(cert)));
99
5
  return New(env, std::move(mcert), issuer_chain);
100
}
101
102
6
MaybeLocal<Object> X509Certificate::New(
103
    Environment* env,
104
    std::shared_ptr<ManagedX509> cert,
105
    STACK_OF(X509)* issuer_chain) {
106
6
  EscapableHandleScope scope(env->isolate());
107
  Local<Function> ctor;
108
18
  if (!GetConstructorTemplate(env)->GetFunction(env->context()).ToLocal(&ctor))
109
    return MaybeLocal<Object>();
110
111
  Local<Object> obj;
112
12
  if (!ctor->NewInstance(env->context()).ToLocal(&obj))
113
    return MaybeLocal<Object>();
114
115
6
  new X509Certificate(env, obj, std::move(cert), issuer_chain);
116
6
  return scope.Escape(obj);
117
}
118
119
1
MaybeLocal<Object> X509Certificate::GetCert(
120
    Environment* env,
121
    const SSLPointer& ssl) {
122
1
  ClearErrorOnReturn clear_error_on_return;
123
1
  X509* cert = SSL_get_certificate(ssl.get());
124
1
  if (cert == nullptr)
125
    return MaybeLocal<Object>();
126
127
1
  X509Pointer ptr(X509_dup(cert));
128
1
  return New(env, std::move(ptr));
129
}
130
131
1
MaybeLocal<Object> X509Certificate::GetPeerCert(
132
    Environment* env,
133
    const SSLPointer& ssl,
134
    GetPeerCertificateFlag flag) {
135
1
  ClearErrorOnReturn clear_error_on_return;
136
  Local<Object> obj;
137
  MaybeLocal<Object> maybe_cert;
138
139
1
  bool is_server =
140
1
      static_cast<int>(flag) & static_cast<int>(GetPeerCertificateFlag::SERVER);
141
142
2
  X509Pointer cert(is_server ? SSL_get_peer_certificate(ssl.get()) : nullptr);
143
1
  STACK_OF(X509)* ssl_certs = SSL_get_peer_cert_chain(ssl.get());
144


1
  if (!cert && (ssl_certs == nullptr || sk_X509_num(ssl_certs) == 0))
145
    return MaybeLocal<Object>();
146
147
1
  std::vector<Local<Value>> certs;
148
149
1
  if (!cert) {
150
1
    cert.reset(sk_X509_value(ssl_certs, 0));
151
1
    sk_X509_delete(ssl_certs, 0);
152
  }
153
154
1
  return sk_X509_num(ssl_certs)
155
2
      ? New(env, std::move(cert), ssl_certs)
156

2
      : New(env, std::move(cert));
157
}
158
159
2
void X509Certificate::Parse(const FunctionCallbackInfo<Value>& args) {
160
2
  Environment* env = Environment::GetCurrent(args);
161
162
2
  CHECK(args[0]->IsArrayBufferView());
163
4
  ArrayBufferViewContents<unsigned char> buf(args[0].As<ArrayBufferView>());
164
2
  const unsigned char* data = buf.data();
165
2
  unsigned data_len = buf.length();
166
167
  ClearErrorOnReturn clear_error_on_return;
168
2
  BIOPointer bio(LoadBIO(env, args[0]));
169
2
  if (!bio)
170
    return ThrowCryptoError(env, ERR_get_error());
171
172
  Local<Object> cert;
173
174
  X509Pointer pem(PEM_read_bio_X509_AUX(
175
2
      bio.get(), nullptr, NoPasswordCallback, nullptr));
176
2
  if (!pem) {
177
    // Try as DER, but return the original PEM failure if it isn't DER.
178
    MarkPopErrorOnReturn mark_here;
179
180
    X509Pointer der(d2i_X509(nullptr, &data, data_len));
181
    if (!der)
182
      return ThrowCryptoError(env, ERR_get_error());
183
184
    if (!X509Certificate::New(env, std::move(der)).ToLocal(&cert))
185
      return;
186
4
  } else if (!X509Certificate::New(env, std::move(pem)).ToLocal(&cert)) {
187
    return;
188
  }
189
190
4
  args.GetReturnValue().Set(cert);
191
}
192
193
1
void X509Certificate::Subject(const FunctionCallbackInfo<Value>& args) {
194
1
  Environment* env = Environment::GetCurrent(args);
195
  X509Certificate* cert;
196
1
  ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder());
197
2
  BIOPointer bio(BIO_new(BIO_s_mem()));
198
  Local<Value> ret;
199
2
  if (GetSubject(env, bio, cert->get()).ToLocal(&ret))
200
2
    args.GetReturnValue().Set(ret);
201
}
202
203
1
void X509Certificate::Issuer(const FunctionCallbackInfo<Value>& args) {
204
1
  Environment* env = Environment::GetCurrent(args);
205
  X509Certificate* cert;
206
1
  ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder());
207
2
  BIOPointer bio(BIO_new(BIO_s_mem()));
208
  Local<Value> ret;
209
2
  if (GetIssuerString(env, bio, cert->get()).ToLocal(&ret))
210
2
    args.GetReturnValue().Set(ret);
211
}
212
213
1
void X509Certificate::SubjectAltName(const FunctionCallbackInfo<Value>& args) {
214
1
  Environment* env = Environment::GetCurrent(args);
215
  X509Certificate* cert;
216
1
  ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder());
217
2
  BIOPointer bio(BIO_new(BIO_s_mem()));
218
  Local<Value> ret;
219
2
  if (GetInfoString<NID_subject_alt_name>(env, bio, cert->get()).ToLocal(&ret))
220
2
    args.GetReturnValue().Set(ret);
221
}
222
223
1
void X509Certificate::InfoAccess(const FunctionCallbackInfo<Value>& args) {
224
1
  Environment* env = Environment::GetCurrent(args);
225
  X509Certificate* cert;
226
1
  ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder());
227
2
  BIOPointer bio(BIO_new(BIO_s_mem()));
228
  Local<Value> ret;
229
2
  if (GetInfoString<NID_info_access>(env, bio, cert->get()).ToLocal(&ret))
230
2
    args.GetReturnValue().Set(ret);
231
}
232
233
1
void X509Certificate::ValidFrom(const FunctionCallbackInfo<Value>& args) {
234
1
  Environment* env = Environment::GetCurrent(args);
235
  X509Certificate* cert;
236
1
  ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder());
237
2
  BIOPointer bio(BIO_new(BIO_s_mem()));
238
  Local<Value> ret;
239
2
  if (GetValidFrom(env, cert->get(), bio).ToLocal(&ret))
240
2
    args.GetReturnValue().Set(ret);
241
}
242
243
1
void X509Certificate::ValidTo(const FunctionCallbackInfo<Value>& args) {
244
1
  Environment* env = Environment::GetCurrent(args);
245
  X509Certificate* cert;
246
1
  ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder());
247
2
  BIOPointer bio(BIO_new(BIO_s_mem()));
248
  Local<Value> ret;
249
2
  if (GetValidTo(env, cert->get(), bio).ToLocal(&ret))
250
2
    args.GetReturnValue().Set(ret);
251
}
252
253
1
void X509Certificate::Fingerprint(const FunctionCallbackInfo<Value>& args) {
254
1
  Environment* env = Environment::GetCurrent(args);
255
  X509Certificate* cert;
256
1
  ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder());
257
  Local<Value> ret;
258
2
  if (GetFingerprintDigest(env, EVP_sha1(), cert->get()).ToLocal(&ret))
259
2
    args.GetReturnValue().Set(ret);
260
}
261
262
1
void X509Certificate::Fingerprint256(const FunctionCallbackInfo<Value>& args) {
263
1
  Environment* env = Environment::GetCurrent(args);
264
  X509Certificate* cert;
265
1
  ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder());
266
  Local<Value> ret;
267
2
  if (GetFingerprintDigest(env, EVP_sha256(), cert->get()).ToLocal(&ret))
268
2
    args.GetReturnValue().Set(ret);
269
}
270
271
1
void X509Certificate::KeyUsage(const FunctionCallbackInfo<Value>& args) {
272
1
  Environment* env = Environment::GetCurrent(args);
273
  X509Certificate* cert;
274
1
  ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder());
275
  Local<Value> ret;
276
2
  if (GetKeyUsage(env, cert->get()).ToLocal(&ret))
277
2
    args.GetReturnValue().Set(ret);
278
}
279
280
3
void X509Certificate::SerialNumber(const FunctionCallbackInfo<Value>& args) {
281
3
  Environment* env = Environment::GetCurrent(args);
282
  X509Certificate* cert;
283
3
  ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder());
284
  Local<Value> ret;
285
6
  if (GetSerialNumber(env, cert->get()).ToLocal(&ret))
286
6
    args.GetReturnValue().Set(ret);
287
}
288
289
2
void X509Certificate::Raw(const FunctionCallbackInfo<Value>& args) {
290
2
  Environment* env = Environment::GetCurrent(args);
291
  X509Certificate* cert;
292
2
  ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder());
293
  Local<Value> ret;
294
4
  if (GetRawDERCertificate(env, cert->get()).ToLocal(&ret))
295
4
    args.GetReturnValue().Set(ret);
296
}
297
298
2
void X509Certificate::PublicKey(const FunctionCallbackInfo<Value>& args) {
299
2
  Environment* env = Environment::GetCurrent(args);
300
  X509Certificate* cert;
301
2
  ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder());
302
303
4
  EVPKeyPointer pkey(X509_get_pubkey(cert->get()));
304
4
  ManagedEVPPKey epkey(std::move(pkey));
305
  std::shared_ptr<KeyObjectData> key_data =
306
4
      KeyObjectData::CreateAsymmetric(kKeyTypePublic, epkey);
307
308
  Local<Value> ret;
309
4
  if (KeyObjectHandle::Create(env, key_data).ToLocal(&ret))
310
4
    args.GetReturnValue().Set(ret);
311
}
312
313
1
void X509Certificate::Pem(const FunctionCallbackInfo<Value>& args) {
314
1
  Environment* env = Environment::GetCurrent(args);
315
  X509Certificate* cert;
316
1
  ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder());
317
2
  BIOPointer bio(BIO_new(BIO_s_mem()));
318
1
  if (PEM_write_bio_X509(bio.get(), cert->get()))
319
2
    args.GetReturnValue().Set(ToV8Value(env, bio));
320
}
321
322
1
void X509Certificate::CheckCA(const FunctionCallbackInfo<Value>& args) {
323
  X509Certificate* cert;
324
1
  ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder());
325
2
  args.GetReturnValue().Set(X509_check_ca(cert->get()) == 1);
326
}
327
328
3
void X509Certificate::CheckHost(const FunctionCallbackInfo<Value>& args) {
329
3
  Environment* env = Environment::GetCurrent(args);
330
  X509Certificate* cert;
331
3
  ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder());
332
333
6
  CHECK(args[0]->IsString());  // name
334
3
  CHECK(args[1]->IsUint32());  // flags
335
336
6
  Utf8Value name(env->isolate(), args[0]);
337
6
  uint32_t flags = args[1].As<Uint32>()->Value();
338
  char* peername;
339
340

6
  switch (X509_check_host(
341
              cert->get(),
342
3
              *name,
343
              name.length(),
344
              flags,
345
              &peername)) {
346
1
    case 1:  {  // Match!
347
1
      Local<Value> ret = args[0];
348
1
      if (peername != nullptr) {
349
1
        ret = OneByteString(env->isolate(), peername);
350
1
        OPENSSL_free(peername);
351
      }
352
2
      return args.GetReturnValue().Set(ret);
353
    }
354
1
    case 0:  // No Match!
355
1
      return;  // No return value is set
356
1
    case -2:  // Error!
357
1
      return THROW_ERR_INVALID_ARG_VALUE(env, "Invalid name");
358
    default:  // Error!
359
      return THROW_ERR_CRYPTO_OPERATION_FAILED(env);
360
  }
361
}
362
363
3
void X509Certificate::CheckEmail(const FunctionCallbackInfo<Value>& args) {
364
3
  Environment* env = Environment::GetCurrent(args);
365
  X509Certificate* cert;
366
3
  ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder());
367
368
6
  CHECK(args[0]->IsString());  // name
369
3
  CHECK(args[1]->IsUint32());  // flags
370
371
6
  Utf8Value name(env->isolate(), args[0]);
372
6
  uint32_t flags = args[1].As<Uint32>()->Value();
373
374

6
  switch (X509_check_email(
375
              cert->get(),
376
3
              *name,
377
              name.length(),
378
              flags)) {
379
1
    case 1:  // Match!
380
2
      return args.GetReturnValue().Set(args[0]);
381
1
    case 0:  // No Match!
382
1
      return;  // No return value is set
383
1
    case -2:  // Error!
384
1
      return THROW_ERR_INVALID_ARG_VALUE(env, "Invalid name");
385
    default:  // Error!
386
      return THROW_ERR_CRYPTO_OPERATION_FAILED(env);
387
  }
388
}
389
390
3
void X509Certificate::CheckIP(const FunctionCallbackInfo<Value>& args) {
391
3
  Environment* env = Environment::GetCurrent(args);
392
  X509Certificate* cert;
393
3
  ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder());
394
395
6
  CHECK(args[0]->IsString());  // IP
396
3
  CHECK(args[1]->IsUint32());  // flags
397
398
6
  Utf8Value name(env->isolate(), args[0]);
399
6
  uint32_t flags = args[1].As<Uint32>()->Value();
400
401

3
  switch (X509_check_ip_asc(cert->get(), *name, flags)) {
402
    case 1:  // Match!
403
      return args.GetReturnValue().Set(args[0]);
404
2
    case 0:  // No Match!
405
2
      return;  // No return value is set
406
1
    case -2:  // Error!
407
1
      return THROW_ERR_INVALID_ARG_VALUE(env, "Invalid IP");
408
    default:  // Error!
409
      return THROW_ERR_CRYPTO_OPERATION_FAILED(env);
410
  }
411
}
412
413
2
void X509Certificate::CheckIssued(const FunctionCallbackInfo<Value>& args) {
414
2
  Environment* env = Environment::GetCurrent(args);
415
  X509Certificate* cert;
416
2
  ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder());
417
418
2
  CHECK(args[0]->IsObject());
419
4
  CHECK(X509Certificate::HasInstance(env, args[0].As<Object>()));
420
421
  X509Certificate* issuer;
422
2
  ASSIGN_OR_RETURN_UNWRAP(&issuer, args[0]);
423
424
4
  args.GetReturnValue().Set(
425
2
    X509_check_issued(issuer->get(), cert->get()) == X509_V_OK);
426
}
427
428
1
void X509Certificate::CheckPrivateKey(const FunctionCallbackInfo<Value>& args) {
429
  X509Certificate* cert;
430
1
  ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder());
431
432
1
  CHECK(args[0]->IsObject());
433
  KeyObjectHandle* key;
434
1
  ASSIGN_OR_RETURN_UNWRAP(&key, args[0]);
435
1
  CHECK_EQ(key->Data()->GetKeyType(), kKeyTypePrivate);
436
437
1
  args.GetReturnValue().Set(
438
1
      X509_check_private_key(
439
1
          cert->get(),
440
2
          key->Data()->GetAsymmetricKey().get()) == 1);
441
}
442
443
2
void X509Certificate::Verify(const FunctionCallbackInfo<Value>& args) {
444
  X509Certificate* cert;
445
2
  ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder());
446
447
2
  CHECK(args[0]->IsObject());
448
  KeyObjectHandle* key;
449
2
  ASSIGN_OR_RETURN_UNWRAP(&key, args[0]);
450
2
  CHECK_EQ(key->Data()->GetKeyType(), kKeyTypePublic);
451
452
2
  args.GetReturnValue().Set(
453
2
      X509_verify(
454
          cert->get(),
455
4
          key->Data()->GetAsymmetricKey().get()) > 0);
456
}
457
458
1
void X509Certificate::ToLegacy(const FunctionCallbackInfo<Value>& args) {
459
1
  Environment* env = Environment::GetCurrent(args);
460
  X509Certificate* cert;
461
1
  ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder());
462
  Local<Value> ret;
463
2
  if (X509ToObject(env, cert->get()).ToLocal(&ret))
464
2
    args.GetReturnValue().Set(ret);
465
}
466
467
3
void X509Certificate::GetIssuerCert(const FunctionCallbackInfo<Value>& args) {
468
  X509Certificate* cert;
469
3
  ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder());
470
3
  if (cert->issuer_cert_)
471
4
    args.GetReturnValue().Set(cert->issuer_cert_->object());
472
}
473
474
6
X509Certificate::X509Certificate(
475
    Environment* env,
476
    Local<Object> object,
477
    std::shared_ptr<ManagedX509> cert,
478
6
    STACK_OF(X509)* issuer_chain)
479
    : BaseObject(env, object),
480
6
      cert_(std::move(cert)) {
481
6
  MakeWeak();
482
483

6
  if (issuer_chain != nullptr && sk_X509_num(issuer_chain)) {
484
1
    X509Pointer cert(X509_dup(sk_X509_value(issuer_chain, 0)));
485
1
    sk_X509_delete(issuer_chain, 0);
486
1
    Local<Object> obj = sk_X509_num(issuer_chain)
487
        ? X509Certificate::New(env, std::move(cert), issuer_chain)
488
            .ToLocalChecked()
489

2
        : X509Certificate::New(env, std::move(cert))
490
2
            .ToLocalChecked();
491
1
    issuer_cert_.reset(Unwrap<X509Certificate>(obj));
492
  }
493
6
}
494
495
void X509Certificate::MemoryInfo(MemoryTracker* tracker) const {
496
  tracker->TrackField("cert", cert_);
497
}
498
499
BaseObjectPtr<BaseObject>
500
1
X509Certificate::X509CertificateTransferData::Deserialize(
501
    Environment* env,
502
    Local<Context> context,
503
    std::unique_ptr<worker::TransferData> self) {
504
2
  if (context != env->context()) {
505
    THROW_ERR_MESSAGE_TARGET_CONTEXT_UNAVAILABLE(env);
506
    return {};
507
  }
508
509
  Local<Value> handle;
510
2
  if (!X509Certificate::New(env, data_).ToLocal(&handle))
511
    return {};
512
513
  return BaseObjectPtr<BaseObject>(
514
1
      Unwrap<X509Certificate>(handle.As<Object>()));
515
}
516
517
518
1
BaseObject::TransferMode X509Certificate::GetTransferMode() const {
519
1
  return BaseObject::TransferMode::kCloneable;
520
}
521
522
1
std::unique_ptr<worker::TransferData> X509Certificate::CloneForMessaging()
523
    const {
524
1
  return std::make_unique<X509CertificateTransferData>(cert_);
525
}
526
527
528
4297
void X509Certificate::Initialize(Environment* env, Local<Object> target) {
529
4297
  env->SetMethod(target, "parseX509", X509Certificate::Parse);
530
531
12891
  NODE_DEFINE_CONSTANT(target, X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT);
532
12891
  NODE_DEFINE_CONSTANT(target, X509_CHECK_FLAG_NEVER_CHECK_SUBJECT);
533
12891
  NODE_DEFINE_CONSTANT(target, X509_CHECK_FLAG_NO_WILDCARDS);
534
12891
  NODE_DEFINE_CONSTANT(target, X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS);
535
12891
  NODE_DEFINE_CONSTANT(target, X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS);
536
8594
  NODE_DEFINE_CONSTANT(target, X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS);
537
4297
}
538
539
}  // namespace crypto
540
}  // namespace node