mirror of
https://github.com/gchq/CyberChef
synced 2025-12-15 07:43:22 +00:00
have "Parse X.509 certificate" emit user-friendly message on certificate load error
This commit is contained in:
@@ -57,6 +57,8 @@ class ParseX509Certificate extends Operation {
|
|||||||
const cert = new r.X509(),
|
const cert = new r.X509(),
|
||||||
inputFormat = args[0];
|
inputFormat = args[0];
|
||||||
|
|
||||||
|
let undefinedInputFormat = false;
|
||||||
|
try {
|
||||||
switch (inputFormat) {
|
switch (inputFormat) {
|
||||||
case "DER Hex":
|
case "DER Hex":
|
||||||
input = input.replace(/\s/g, "");
|
input = input.replace(/\s/g, "");
|
||||||
@@ -72,8 +74,12 @@ class ParseX509Certificate extends Operation {
|
|||||||
cert.readCertHex(toHex(Utils.strToByteArray(input), ""));
|
cert.readCertHex(toHex(Utils.strToByteArray(input), ""));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw "Undefined input format";
|
undefinedInputFormat = true;
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
throw "Certificate load error (non-certificate input?)";
|
||||||
|
}
|
||||||
|
if (undefinedInputFormat) throw "Undefined input format";
|
||||||
|
|
||||||
const sn = cert.getSerialNumberHex(),
|
const sn = cert.getSerialNumberHex(),
|
||||||
issuer = cert.getIssuer(),
|
issuer = cert.getIssuer(),
|
||||||
|
|||||||
Reference in New Issue
Block a user