デジタル署名の割り当てと検証
Contents
[
Hide
]
デジタル署名は、ブック ファイルが有効であり、誰も変更していないことを保証します。を使用して、個人のデジタル署名を作成できます。Microsoft Selfcert.exeまたはその他のツールを使用するか、デジタル署名を購入できます。デジタル署名を作成したら、それをブックに添付する必要があります。デジタル署名を添付することは、封筒を封印することに似ています。封筒が封印された状態で届いた場合、だれもその内容を改ざんしていないことをある程度保証できます。
序章
デジタル署名ダイアログを使用して、デジタル署名を添付します。 [デジタル署名] ダイアログに有効な証明書が一覧表示されます。 [デジタル署名] ダイアログを使用して、証明書を表示し、使用する証明書を選択できます。ワークブックにデジタル署名がある場合、署名の名前が証明書名分野。をクリックすると削除するボタンをクリックすると、Microsoft Excel はデジタル署名も削除します。
Aspose.Cells はAspose.Cells.DigitalSignatures名前空間を使用してジョブを実行します (デジタル署名の割り当てと検証)。名前空間には、デジタル署名を追加および検証するための便利な機能がいくつかあります。
Aspose.Cells for .NET API を使用してタスクを実行する方法を説明する次のサンプル コードを参照してください。
This file contains 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
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// dsc is signature collection contains one or more signature needed to sign | |
DigitalSignatureCollection dsc = new DigitalSignatureCollection(); | |
// Cert must contain private key, it can be contructed from cert file or windows certificate collection. aa is password of cert | |
X509Certificate2 cert = new X509Certificate2(dataDir + "mykey2.pfx", "aa"); | |
DigitalSignature ds = new DigitalSignature(cert, "test for sign", DateTime.Now); | |
dsc.Add(ds); | |
Workbook wb = new Workbook(); | |
// wb.SetDigitalSignature signs all signatures in dsc | |
wb.SetDigitalSignature(dsc); | |
wb.Save(dataDir + @"newfile_out.xlsx"); | |
// open the file | |
wb = new Workbook(dataDir + @"newfile_out.xlsx"); | |
System.Console.WriteLine(wb.IsDigitallySigned); | |
// Get digitalSignature collection from workbook | |
dsc = wb.GetDigitalSignature(); | |
foreach (DigitalSignature dst in dsc) | |
{ | |
System.Console.WriteLine(dst.Comments); //test for sign -OK | |
System.Console.WriteLine(dst.SignTime); //11/25/2010 1:22:01 PM -OK | |
System.Console.WriteLine(dst.IsValid); //True -OK | |
} |