Skip to content
Snippets Groups Projects
Commit 31ec5431 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Add workaround for cryptlib bug.

CryptCert.export_cert(CryptCert.FORMAT.TEXT_CERTIFICATE) should
now work properly instead of always returning an error.
parent 91d98c5e
No related branches found
No related tags found
No related merge requests found
Pipeline #4968 passed
......@@ -195,13 +195,19 @@ js_export(JSContext *cx, uintN argc, jsval *arglist)
js_cryptcert_error(cx, p->cert, status);
return JS_FALSE;
}
buf = malloc(len);
/*
* We're adding an extra 12 bytes here because of a bug in ceryptlib.
* for TEXT_CERTIFICATE, it calcilates the length as though the start
* is -----BEGIN CERTIFICATE----- but uses -----BEGIN CERTIFICATE CHAIN-----
* instead. This, plus the end uses and extra 12 bytes.
*/
buf = malloc(len+12);
if (buf == NULL) {
JS_RESUMEREQUEST(cx, rc);
JS_ReportError(cx, "Unable to allocate %d bytes\n", len);
return JS_FALSE;
}
status = cryptExportCert(buf, len, &len, format, p->cert);
status = cryptExportCert(buf, len+12, &len, format, p->cert);
JS_RESUMEREQUEST(cx, rc);
if (cryptStatusError(status)) {
JS_RESUMEREQUEST(cx, rc);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment