have "Parse X.509 certificate" emit user-friendly message on certificate load error
This commit is contained in:
parent
ed8bd34915
commit
5a507aa1ba
@ -57,23 +57,29 @@ class ParseX509Certificate extends Operation {
|
|||||||
const cert = new r.X509(),
|
const cert = new r.X509(),
|
||||||
inputFormat = args[0];
|
inputFormat = args[0];
|
||||||
|
|
||||||
switch (inputFormat) {
|
let undefinedInputFormat = false;
|
||||||
case "DER Hex":
|
try {
|
||||||
input = input.replace(/\s/g, "");
|
switch (inputFormat) {
|
||||||
cert.readCertHex(input);
|
case "DER Hex":
|
||||||
break;
|
input = input.replace(/\s/g, "");
|
||||||
case "PEM":
|
cert.readCertHex(input);
|
||||||
cert.readCertPEM(input);
|
break;
|
||||||
break;
|
case "PEM":
|
||||||
case "Base64":
|
cert.readCertPEM(input);
|
||||||
cert.readCertHex(toHex(fromBase64(input, null, "byteArray"), ""));
|
break;
|
||||||
break;
|
case "Base64":
|
||||||
case "Raw":
|
cert.readCertHex(toHex(fromBase64(input, null, "byteArray"), ""));
|
||||||
cert.readCertHex(toHex(Utils.strToByteArray(input), ""));
|
break;
|
||||||
break;
|
case "Raw":
|
||||||
default:
|
cert.readCertHex(toHex(Utils.strToByteArray(input), ""));
|
||||||
throw "Undefined input format";
|
break;
|
||||||
|
default:
|
||||||
|
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(),
|
||||||
|
Loading…
Reference in New Issue
Block a user