DigitalSignature.DigitalSignature

DigitalSignature(X509Certificate2, string, DateTime)

Constructor of digitalSignature. Uses .Net implementation.

public DigitalSignature(X509Certificate2 certificate, string comments, DateTime signTime)
ParameterTypeDescription
certificateX509Certificate2Certificate object that was used to sign the document.
commentsStringThe purpose to signature.
signTimeDateTimeThe utc time when the document was signed.

Examples

The following example shows how to create digital signature.

[C#]
//signature collection contains one or more signature needed to sign
DigitalSignatureCollection dsc = new DigitalSignatureCollection();
//The cert must contain private key, it can be contructed from cert file or windows certificate collection.
//123456 is password of cert
X509Certificate2 cert = new X509Certificate2("mykey2.pfx", "123456");
DigitalSignature ds = new DigitalSignature(cert, "test for sign", DateTime.Now);
dsc.Add(ds);
Workbook wb = new Workbook();
//set all signatures to workbook
wb.SetDigitalSignature(dsc);
wb.Save(@"newfile.xlsx");


[Visual Basic]
'signature collection contains one or more signature needed to sign
Dim dsc As DigitalSignatureCollection = New DigitalSignatureCollection()
'The cert must contain private key, it can be contructed from cert file or windows certificate collection.
Dim cert As X509Certificate2 = New X509Certificate2("mykey2.pfx", "123456")
'create a signature with certificate, sign purpose and sign time
Dim ds As DigitalSignature = New DigitalSignature(cert, "test for sign", DateTime.Now)
dsc.Add(ds)
Dim wb As Workbook = New Workbook()
'set all signatures to workbook
wb.SetDigitalSignature(dsc)
wb.Save("newfile.xlsx")

See Also


DigitalSignature(byte[], string, string, DateTime)

Constructor of digitalSignature. Uses Bouncy Castle implementation.

public DigitalSignature(byte[] rawData, string password, string comments, DateTime signTime)
ParameterTypeDescription
rawDataByte[]A byte array containing data from an X.509 certificate.
passwordStringThe password required to access the X.509 certificate data.
commentsStringThe purpose to signature.
signTimeDateTimeThe utc time when the document was signed.

See Also