@@ -5484,29 +5484,7 @@ void GetCurves(const FunctionCallbackInfo<Value>& args) {
5484
5484
}
5485
5485
5486
5486
5487
- void Certificate::Initialize (Environment* env, Local<Object> target) {
5488
- HandleScope scope (env->isolate ());
5489
-
5490
- Local<FunctionTemplate> t = env->NewFunctionTemplate (New);
5491
-
5492
- t->InstanceTemplate ()->SetInternalFieldCount (1 );
5493
-
5494
- env->SetProtoMethod (t, " verifySpkac" , VerifySpkac);
5495
- env->SetProtoMethod (t, " exportPublicKey" , ExportPublicKey);
5496
- env->SetProtoMethod (t, " exportChallenge" , ExportChallenge);
5497
-
5498
- target->Set (FIXED_ONE_BYTE_STRING (env->isolate (), " Certificate" ),
5499
- t->GetFunction ());
5500
- }
5501
-
5502
-
5503
- void Certificate::New (const FunctionCallbackInfo<Value>& args) {
5504
- Environment* env = Environment::GetCurrent (args);
5505
- new Certificate (env, args.This ());
5506
- }
5507
-
5508
-
5509
- bool Certificate::VerifySpkac (const char * data, unsigned int len) {
5487
+ bool VerifySpkac (const char * data, unsigned int len) {
5510
5488
bool i = 0 ;
5511
5489
EVP_PKEY* pkey = nullptr ;
5512
5490
NETSCAPE_SPKI* spki = nullptr ;
@@ -5532,9 +5510,8 @@ bool Certificate::VerifySpkac(const char* data, unsigned int len) {
5532
5510
}
5533
5511
5534
5512
5535
- void Certificate::VerifySpkac (const FunctionCallbackInfo<Value>& args) {
5536
- Certificate* certificate = Unwrap<Certificate>(args.Holder ());
5537
- Environment* env = certificate->env ();
5513
+ void VerifySpkac (const FunctionCallbackInfo<Value>& args) {
5514
+ Environment* env = Environment::GetCurrent (args);
5538
5515
bool i = false ;
5539
5516
5540
5517
if (args.Length () < 1 )
@@ -5549,13 +5526,13 @@ void Certificate::VerifySpkac(const FunctionCallbackInfo<Value>& args) {
5549
5526
char * data = Buffer::Data (args[0 ]);
5550
5527
CHECK_NE (data, nullptr );
5551
5528
5552
- i = certificate-> VerifySpkac (data, length);
5529
+ i = VerifySpkac (data, length);
5553
5530
5554
5531
args.GetReturnValue ().Set (i);
5555
5532
}
5556
5533
5557
5534
5558
- const char * Certificate:: ExportPublicKey (const char * data, int len) {
5535
+ const char * ExportPublicKey (const char * data, int len) {
5559
5536
char * buf = nullptr ;
5560
5537
EVP_PKEY* pkey = nullptr ;
5561
5538
NETSCAPE_SPKI* spki = nullptr ;
@@ -5596,11 +5573,9 @@ const char* Certificate::ExportPublicKey(const char* data, int len) {
5596
5573
}
5597
5574
5598
5575
5599
- void Certificate:: ExportPublicKey (const FunctionCallbackInfo<Value>& args) {
5576
+ void ExportPublicKey (const FunctionCallbackInfo<Value>& args) {
5600
5577
Environment* env = Environment::GetCurrent (args);
5601
5578
5602
- Certificate* certificate = Unwrap<Certificate>(args.Holder ());
5603
-
5604
5579
if (args.Length () < 1 )
5605
5580
return env->ThrowTypeError (" Missing argument" );
5606
5581
@@ -5613,7 +5588,7 @@ void Certificate::ExportPublicKey(const FunctionCallbackInfo<Value>& args) {
5613
5588
char * data = Buffer::Data (args[0 ]);
5614
5589
CHECK_NE (data, nullptr );
5615
5590
5616
- const char * pkey = certificate-> ExportPublicKey (data, length);
5591
+ const char * pkey = ExportPublicKey (data, length);
5617
5592
if (pkey == nullptr )
5618
5593
return args.GetReturnValue ().SetEmptyString ();
5619
5594
@@ -5625,7 +5600,7 @@ void Certificate::ExportPublicKey(const FunctionCallbackInfo<Value>& args) {
5625
5600
}
5626
5601
5627
5602
5628
- const char * Certificate:: ExportChallenge (const char * data, int len) {
5603
+ const char * ExportChallenge (const char * data, int len) {
5629
5604
NETSCAPE_SPKI* sp = nullptr ;
5630
5605
5631
5606
sp = NETSCAPE_SPKI_b64_decode (data, len);
@@ -5641,11 +5616,9 @@ const char* Certificate::ExportChallenge(const char* data, int len) {
5641
5616
}
5642
5617
5643
5618
5644
- void Certificate:: ExportChallenge (const FunctionCallbackInfo<Value>& args) {
5619
+ void ExportChallenge (const FunctionCallbackInfo<Value>& args) {
5645
5620
Environment* env = Environment::GetCurrent (args);
5646
5621
5647
- Certificate* crt = Unwrap<Certificate>(args.Holder ());
5648
-
5649
5622
if (args.Length () < 1 )
5650
5623
return env->ThrowTypeError (" Missing argument" );
5651
5624
@@ -5658,7 +5631,7 @@ void Certificate::ExportChallenge(const FunctionCallbackInfo<Value>& args) {
5658
5631
char * data = Buffer::Data (args[0 ]);
5659
5632
CHECK_NE (data, nullptr );
5660
5633
5661
- const char * cert = crt-> ExportChallenge (data, len);
5634
+ const char * cert = ExportChallenge (data, len);
5662
5635
if (cert == nullptr )
5663
5636
return args.GetReturnValue ().SetEmptyString ();
5664
5637
@@ -5797,8 +5770,10 @@ void InitCrypto(Local<Object> target,
5797
5770
Hash::Initialize (env, target);
5798
5771
Sign::Initialize (env, target);
5799
5772
Verify::Initialize (env, target);
5800
- Certificate::Initialize (env, target);
5801
5773
5774
+ env->SetMethod (target, " certVerifySpkac" , VerifySpkac);
5775
+ env->SetMethod (target, " certExportPublicKey" , ExportPublicKey);
5776
+ env->SetMethod (target, " certExportChallenge" , ExportChallenge);
5802
5777
#ifndef OPENSSL_NO_ENGINE
5803
5778
env->SetMethod (target, " setEngine" , SetEngine);
5804
5779
#endif // !OPENSSL_NO_ENGINE
0 commit comments