@@ -5470,29 +5470,7 @@ void GetCurves(const FunctionCallbackInfo<Value>& args) {
5470
5470
}
5471
5471
5472
5472
5473
- void Certificate::Initialize (Environment* env, Local<Object> target) {
5474
- HandleScope scope (env->isolate ());
5475
-
5476
- Local<FunctionTemplate> t = env->NewFunctionTemplate (New);
5477
-
5478
- t->InstanceTemplate ()->SetInternalFieldCount (1 );
5479
-
5480
- env->SetProtoMethod (t, " verifySpkac" , VerifySpkac);
5481
- env->SetProtoMethod (t, " exportPublicKey" , ExportPublicKey);
5482
- env->SetProtoMethod (t, " exportChallenge" , ExportChallenge);
5483
-
5484
- target->Set (FIXED_ONE_BYTE_STRING (env->isolate (), " Certificate" ),
5485
- t->GetFunction ());
5486
- }
5487
-
5488
-
5489
- void Certificate::New (const FunctionCallbackInfo<Value>& args) {
5490
- Environment* env = Environment::GetCurrent (args);
5491
- new Certificate (env, args.This ());
5492
- }
5493
-
5494
-
5495
- bool Certificate::VerifySpkac (const char * data, unsigned int len) {
5473
+ bool VerifySpkac (const char * data, unsigned int len) {
5496
5474
bool i = 0 ;
5497
5475
EVP_PKEY* pkey = nullptr ;
5498
5476
NETSCAPE_SPKI* spki = nullptr ;
@@ -5518,9 +5496,8 @@ bool Certificate::VerifySpkac(const char* data, unsigned int len) {
5518
5496
}
5519
5497
5520
5498
5521
- void Certificate::VerifySpkac (const FunctionCallbackInfo<Value>& args) {
5522
- Certificate* certificate = Unwrap<Certificate>(args.Holder ());
5523
- Environment* env = certificate->env ();
5499
+ void VerifySpkac (const FunctionCallbackInfo<Value>& args) {
5500
+ Environment* env = Environment::GetCurrent (args);
5524
5501
bool i = false ;
5525
5502
5526
5503
if (args.Length () < 1 )
@@ -5535,13 +5512,13 @@ void Certificate::VerifySpkac(const FunctionCallbackInfo<Value>& args) {
5535
5512
char * data = Buffer::Data (args[0 ]);
5536
5513
CHECK_NE (data, nullptr );
5537
5514
5538
- i = certificate-> VerifySpkac (data, length);
5515
+ i = VerifySpkac (data, length);
5539
5516
5540
5517
args.GetReturnValue ().Set (i);
5541
5518
}
5542
5519
5543
5520
5544
- const char * Certificate:: ExportPublicKey (const char * data, int len) {
5521
+ const char * ExportPublicKey (const char * data, int len) {
5545
5522
char * buf = nullptr ;
5546
5523
EVP_PKEY* pkey = nullptr ;
5547
5524
NETSCAPE_SPKI* spki = nullptr ;
@@ -5582,11 +5559,9 @@ const char* Certificate::ExportPublicKey(const char* data, int len) {
5582
5559
}
5583
5560
5584
5561
5585
- void Certificate:: ExportPublicKey (const FunctionCallbackInfo<Value>& args) {
5562
+ void ExportPublicKey (const FunctionCallbackInfo<Value>& args) {
5586
5563
Environment* env = Environment::GetCurrent (args);
5587
5564
5588
- Certificate* certificate = Unwrap<Certificate>(args.Holder ());
5589
-
5590
5565
if (args.Length () < 1 )
5591
5566
return env->ThrowTypeError (" Missing argument" );
5592
5567
@@ -5599,7 +5574,7 @@ void Certificate::ExportPublicKey(const FunctionCallbackInfo<Value>& args) {
5599
5574
char * data = Buffer::Data (args[0 ]);
5600
5575
CHECK_NE (data, nullptr );
5601
5576
5602
- const char * pkey = certificate-> ExportPublicKey (data, length);
5577
+ const char * pkey = ExportPublicKey (data, length);
5603
5578
if (pkey == nullptr )
5604
5579
return args.GetReturnValue ().SetEmptyString ();
5605
5580
@@ -5611,7 +5586,7 @@ void Certificate::ExportPublicKey(const FunctionCallbackInfo<Value>& args) {
5611
5586
}
5612
5587
5613
5588
5614
- const char * Certificate:: ExportChallenge (const char * data, int len) {
5589
+ const char * ExportChallenge (const char * data, int len) {
5615
5590
NETSCAPE_SPKI* sp = nullptr ;
5616
5591
5617
5592
sp = NETSCAPE_SPKI_b64_decode (data, len);
@@ -5627,11 +5602,9 @@ const char* Certificate::ExportChallenge(const char* data, int len) {
5627
5602
}
5628
5603
5629
5604
5630
- void Certificate:: ExportChallenge (const FunctionCallbackInfo<Value>& args) {
5605
+ void ExportChallenge (const FunctionCallbackInfo<Value>& args) {
5631
5606
Environment* env = Environment::GetCurrent (args);
5632
5607
5633
- Certificate* crt = Unwrap<Certificate>(args.Holder ());
5634
-
5635
5608
if (args.Length () < 1 )
5636
5609
return env->ThrowTypeError (" Missing argument" );
5637
5610
@@ -5644,7 +5617,7 @@ void Certificate::ExportChallenge(const FunctionCallbackInfo<Value>& args) {
5644
5617
char * data = Buffer::Data (args[0 ]);
5645
5618
CHECK_NE (data, nullptr );
5646
5619
5647
- const char * cert = crt-> ExportChallenge (data, len);
5620
+ const char * cert = ExportChallenge (data, len);
5648
5621
if (cert == nullptr )
5649
5622
return args.GetReturnValue ().SetEmptyString ();
5650
5623
@@ -5753,8 +5726,10 @@ void InitCrypto(Local<Object> target,
5753
5726
Hash::Initialize (env, target);
5754
5727
Sign::Initialize (env, target);
5755
5728
Verify::Initialize (env, target);
5756
- Certificate::Initialize (env, target);
5757
5729
5730
+ env->SetMethod (target, " certVerifySpkac" , VerifySpkac);
5731
+ env->SetMethod (target, " certExportPublicKey" , ExportPublicKey);
5732
+ env->SetMethod (target, " certExportChallenge" , ExportChallenge);
5758
5733
#ifndef OPENSSL_NO_ENGINE
5759
5734
env->SetMethod (target, " setEngine" , SetEngine);
5760
5735
#endif // !OPENSSL_NO_ENGINE
0 commit comments