Skip to content

Commit

Permalink
Add fingerprints to 'Parse X.509 certificate' operation
Browse files Browse the repository at this point in the history
  • Loading branch information
JSCU-CNI committed Jul 24, 2024
1 parent a477f47 commit fb3c36a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/core/operations/ParseX509Certificate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

import r from "jsrsasign";
import { fromBase64 } from "../lib/Base64.mjs";
import { toHex } from "../lib/Hex.mjs";
import { runHash } from "../lib/Hash.mjs";
import { fromHex, toHex } from "../lib/Hex.mjs";
import { formatByteStr, formatDnObj } from "../lib/PublicKey.mjs";
import Operation from "../Operation.mjs";
import Utils from "../Utils.mjs";
Expand Down Expand Up @@ -81,7 +82,8 @@ class ParseX509Certificate extends Operation {
}
if (undefinedInputFormat) throw "Undefined input format";

const sn = cert.getSerialNumberHex(),
const hex = Utils.strToArrayBuffer(Utils.byteArrayToChars(fromHex(cert.hex))),
sn = cert.getSerialNumberHex(),
issuer = cert.getIssuer(),
subject = cert.getSubject(),
pk = cert.getPublicKey(),
Expand Down Expand Up @@ -191,6 +193,10 @@ Issuer
${issuerStr}
Subject
${subjectStr}
Fingerprints
MD5: ${runHash("md5", hex)}
SHA1: ${runHash("sha1", hex)}
SHA256: ${runHash("sha256", hex)}
Public Key
${pkStr.slice(0, -1)}
Certificate Signature
Expand Down

0 comments on commit fb3c36a

Please sign in to comment.