@@ -85,16 +85,18 @@ void ExportPublicKey(const FunctionCallbackInfo<Value>& args) {
8585 args.GetReturnValue ().Set (pkey.ToBuffer ().FromMaybe (Local<Value>()));
8686}
8787
88- OpenSSLBuffer ExportChallenge (const ArrayBufferOrViewContents<char >& input) {
88+ ByteSource ExportChallenge (const ArrayBufferOrViewContents<char >& input) {
8989 NetscapeSPKIPointer sp (
9090 NETSCAPE_SPKI_b64_decode (input.data (), input.size ()));
9191 if (!sp)
92- return nullptr ;
92+ return ByteSource () ;
9393
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 );
9698
97- return OpenSSLBuffer ( reinterpret_cast < char *> (buf));
99+ return ByteSource::Allocated (buf, strlen (buf));
98100}
99101
100102void ExportChallenge (const FunctionCallbackInfo<Value>& args) {
@@ -107,12 +109,12 @@ void ExportChallenge(const FunctionCallbackInfo<Value>& args) {
107109 if (UNLIKELY (!input.CheckSizeInt32 ()))
108110 return THROW_ERR_OUT_OF_RANGE (env, " spkac is too large" );
109111
110- OpenSSLBuffer cert = ExportChallenge (input);
112+ ByteSource cert = ExportChallenge (input);
111113 if (!cert)
112114 return args.GetReturnValue ().SetEmptyString ();
113115
114116 Local<Value> outString =
115- Encode (env->isolate (), cert.get (), strlen ( cert.get () ), BUFFER);
117+ Encode (env->isolate (), cert.get (), cert.size ( ), BUFFER);
116118
117119 args.GetReturnValue ().Set (outString);
118120}
0 commit comments