@@ -85,16 +85,18 @@ void ExportPublicKey(const FunctionCallbackInfo<Value>& args) {
85
85
args.GetReturnValue ().Set (pkey.ToBuffer ().FromMaybe (Local<Value>()));
86
86
}
87
87
88
- OpenSSLBuffer ExportChallenge (const ArrayBufferOrViewContents<char >& input) {
88
+ ByteSource ExportChallenge (const ArrayBufferOrViewContents<char >& input) {
89
89
NetscapeSPKIPointer sp (
90
90
NETSCAPE_SPKI_b64_decode (input.data (), input.size ()));
91
91
if (!sp)
92
- return nullptr ;
92
+ return ByteSource () ;
93
93
94
- unsigned char * buf = nullptr ;
95
- ASN1_STRING_to_UTF8 (&buf, sp->spkac ->challenge );
94
+ char * buf = nullptr ;
95
+ ASN1_STRING_to_UTF8 (
96
+ reinterpret_cast <unsigned char **>(&buf),
97
+ sp->spkac ->challenge );
96
98
97
- return OpenSSLBuffer ( reinterpret_cast < char *> (buf));
99
+ return ByteSource::Allocated (buf, strlen (buf));
98
100
}
99
101
100
102
void ExportChallenge (const FunctionCallbackInfo<Value>& args) {
@@ -107,12 +109,12 @@ void ExportChallenge(const FunctionCallbackInfo<Value>& args) {
107
109
if (UNLIKELY (!input.CheckSizeInt32 ()))
108
110
return THROW_ERR_OUT_OF_RANGE (env, " spkac is too large" );
109
111
110
- OpenSSLBuffer cert = ExportChallenge (input);
112
+ ByteSource cert = ExportChallenge (input);
111
113
if (!cert)
112
114
return args.GetReturnValue ().SetEmptyString ();
113
115
114
116
Local<Value> outString =
115
- Encode (env->isolate (), cert.get (), strlen ( cert.get () ), BUFFER);
117
+ Encode (env->isolate (), cert.get (), cert.size ( ), BUFFER);
116
118
117
119
args.GetReturnValue ().Set (outString);
118
120
}
0 commit comments