Created
April 9, 2023 18:29
-
-
Save ediskandarov/2ecd33a16ac73fda04279d6b83d8b888 to your computer and use it in GitHub Desktop.
node cades script example that verifies attached signature
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Compile node module first `https://github.com/boriborm/cryptopro-node-cades` | |
const fs = require("node:fs"); | |
const cades = require("./NodeCades"); | |
const signedData = new cades.SignedData(); | |
const message = fs.readFileSync("message.txt", { encoding: "utf-8" }); | |
signedData.content = message; // string | |
const signatureRaw = fs.readFileSync("message.txt.sig"); // buffer | |
signedData.verifyCades(signatureRaw, cades.CADESCOM_CADES_X_LONG_TYPE_1); | |
console.log("verified"); | |
console.log("Content", signedData.content); | |
console.log("Number of signers", signedData.signers.length); | |
for (const signer of signedData.signers) { | |
const signerCert = signer.certificate; | |
console.log("signer", signerCert.subjectName); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment