@@ -5484,29 +5484,7 @@ void GetCurves(const FunctionCallbackInfo<Value>& args) {
54845484}
54855485
54865486
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) {
55105488 bool i = 0 ;
55115489 EVP_PKEY* pkey = nullptr ;
55125490 NETSCAPE_SPKI* spki = nullptr ;
@@ -5532,9 +5510,8 @@ bool Certificate::VerifySpkac(const char* data, unsigned int len) {
55325510}
55335511
55345512
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);
55385515 bool i = false ;
55395516
55405517 if (args.Length () < 1 )
@@ -5549,13 +5526,13 @@ void Certificate::VerifySpkac(const FunctionCallbackInfo<Value>& args) {
55495526 char * data = Buffer::Data (args[0 ]);
55505527 CHECK_NE (data, nullptr );
55515528
5552- i = certificate-> VerifySpkac (data, length);
5529+ i = VerifySpkac (data, length);
55535530
55545531 args.GetReturnValue ().Set (i);
55555532}
55565533
55575534
5558- const char * Certificate:: ExportPublicKey (const char * data, int len) {
5535+ const char * ExportPublicKey (const char * data, int len) {
55595536 char * buf = nullptr ;
55605537 EVP_PKEY* pkey = nullptr ;
55615538 NETSCAPE_SPKI* spki = nullptr ;
@@ -5596,11 +5573,9 @@ const char* Certificate::ExportPublicKey(const char* data, int len) {
55965573}
55975574
55985575
5599- void Certificate:: ExportPublicKey (const FunctionCallbackInfo<Value>& args) {
5576+ void ExportPublicKey (const FunctionCallbackInfo<Value>& args) {
56005577 Environment* env = Environment::GetCurrent (args);
56015578
5602- Certificate* certificate = Unwrap<Certificate>(args.Holder ());
5603-
56045579 if (args.Length () < 1 )
56055580 return env->ThrowTypeError (" Missing argument" );
56065581
@@ -5613,7 +5588,7 @@ void Certificate::ExportPublicKey(const FunctionCallbackInfo<Value>& args) {
56135588 char * data = Buffer::Data (args[0 ]);
56145589 CHECK_NE (data, nullptr );
56155590
5616- const char * pkey = certificate-> ExportPublicKey (data, length);
5591+ const char * pkey = ExportPublicKey (data, length);
56175592 if (pkey == nullptr )
56185593 return args.GetReturnValue ().SetEmptyString ();
56195594
@@ -5625,7 +5600,7 @@ void Certificate::ExportPublicKey(const FunctionCallbackInfo<Value>& args) {
56255600}
56265601
56275602
5628- const char * Certificate:: ExportChallenge (const char * data, int len) {
5603+ const char * ExportChallenge (const char * data, int len) {
56295604 NETSCAPE_SPKI* sp = nullptr ;
56305605
56315606 sp = NETSCAPE_SPKI_b64_decode (data, len);
@@ -5641,11 +5616,9 @@ const char* Certificate::ExportChallenge(const char* data, int len) {
56415616}
56425617
56435618
5644- void Certificate:: ExportChallenge (const FunctionCallbackInfo<Value>& args) {
5619+ void ExportChallenge (const FunctionCallbackInfo<Value>& args) {
56455620 Environment* env = Environment::GetCurrent (args);
56465621
5647- Certificate* crt = Unwrap<Certificate>(args.Holder ());
5648-
56495622 if (args.Length () < 1 )
56505623 return env->ThrowTypeError (" Missing argument" );
56515624
@@ -5658,7 +5631,7 @@ void Certificate::ExportChallenge(const FunctionCallbackInfo<Value>& args) {
56585631 char * data = Buffer::Data (args[0 ]);
56595632 CHECK_NE (data, nullptr );
56605633
5661- const char * cert = crt-> ExportChallenge (data, len);
5634+ const char * cert = ExportChallenge (data, len);
56625635 if (cert == nullptr )
56635636 return args.GetReturnValue ().SetEmptyString ();
56645637
@@ -5797,8 +5770,10 @@ void InitCrypto(Local<Object> target,
57975770 Hash::Initialize (env, target);
57985771 Sign::Initialize (env, target);
57995772 Verify::Initialize (env, target);
5800- Certificate::Initialize (env, target);
58015773
5774+ env->SetMethod (target, " certVerifySpkac" , VerifySpkac);
5775+ env->SetMethod (target, " certExportPublicKey" , ExportPublicKey);
5776+ env->SetMethod (target, " certExportChallenge" , ExportChallenge);
58025777#ifndef OPENSSL_NO_ENGINE
58035778 env->SetMethod (target, " setEngine" , SetEngine);
58045779#endif // !OPENSSL_NO_ENGINE
0 commit comments