Node.js経由のC++を使ったデジタル署名の割り当てと検証
紹介
デジタル署名を添付するには、デジタル署名ダイアログを使用します。デジタル署名ダイアログには有効な証明書が一覧表示されます。デジタル署名ダイアログでは、証明書を表示し、使用する証明書を選択することができます。ブックにデジタル署名がある場合、署名の名前が証明書名フィールドに表示されます。デジタル署名ダイアログの削除ボタンをクリックすると、Microsoft Excelはデジタル署名も削除します。
Excelにデジタル署名を追加する方法
Aspose.CellsはDigitalSignatureモジュールを提供し、デジタル署名の割り当てと検証を行います。このモジュールには、デジタル署名を追加・検証するための便利な機能があります。
以下のサンプルコードをご覧ください。これにより、Aspose.Cells for Node.js via C++ APIを使ったタスクの実行方法がわかります。
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const certPassword = "aa";
// dsc is signature collection that contains one or more signatures needed to sign
const dsc = new AsposeCells.DigitalSignatureCollection();
// Cert must contain a private key, it can be constructed from a cert file or Windows certificate collection.
const cert = new AsposeCells.DigitalSignature(dataDir + "mykey2.pfx", certPassword, "test for sign", new Date());
dsc.add(cert);
const wb = new AsposeCells.Workbook();
// wb.setDigitalSignature signs all signatures in dsc
wb.setDigitalSignature(dsc);
wb.save(path.join(dataDir, "newfile_out.xlsx"));
// open the file
const wb2 = new AsposeCells.Workbook(path.join(dataDir, "newfile_out.xlsx"));
console.log(wb2.isDigitallySigned);
// Get digitalSignature collection from workbook
const dsc2 = wb2.getDigitalSignature();
const digitalSignatures = dsc2.getEnumerator();
for (var dst of digitalSignatures)
{
console.log(dst.getComments()); // test for sign - OK
console.log(dst.getSignTime()); // 11/25/2010 1:22:01 PM - OK
console.log(dst.isValid()); // True - OK
}