Class DigitalSignature
Namespace: Aspose.Cells.DigitalSignatures
Assembly: Aspose.Cells.dll (25.2.0)
Signature in file.
public class DigitalSignature
Inheritance
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Constructors
DigitalSignature(X509Certificate2, string, DateTime)
Constructor of digitalSignature. Uses .Net implementation.
public DigitalSignature(X509Certificate2 certificate, string comments, DateTime signTime)
Parameters
certificate
X509Certificate2
Certificate object that was used to sign the document.
comments
string
The purpose to signature.
signTime
DateTime
The utc time when the document was signed.
Examples
The following example shows how to create digital signature.
//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");
'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")
DigitalSignature(byte[], string, string, DateTime)
Constructor of digitalSignature. Uses Bouncy Castle implementation.
public DigitalSignature(byte[] rawData, string password, string comments, DateTime signTime)
Parameters
rawData
byte[]
A byte array containing data from an X.509 certificate.
password
string
The password required to access the X.509 certificate data.
comments
string
The purpose to signature.
signTime
DateTime
The utc time when the document was signed.
Properties
Certificate
Certificate object that was used to sign the document.
public X509Certificate2 Certificate { get; set; }
Property Value
Comments
The purpose to signature.
public string Comments { get; set; }
Property Value
Id
Specifies a GUID which can be cross-referenced with the GUID of the signature line stored in the document content. Default value is Empty (all zeroes) Guid.
public Guid Id { get; set; }
Property Value
Remarks
When set, it associates Aspose.Cells.Drawing.SignatureLine with corresponding Aspose.Cells.DigitalSignatures.DigitalSignature.
Image
Specifies an image for the digital signature. Default value is null.
public byte[] Image { get; set; }
Property Value
byte[]
IsValid
If this digital signature is valid and the document has not been tampered with, this value will be true.
public bool IsValid { get; }
Property Value
ProviderId
Specifies the class ID of the signature provider. Default value is Empty (all zeroes) Guid.
public Guid ProviderId { get; set; }
Property Value
Remarks
The cryptographic service provider (CSP) is an independent software module that actually performs cryptography algorithms for authentication, encoding, and encryption. Microsoft Office reserves the value of {00000000-0000-0000-0000-000000000000} for its default signature provider, and {000CD6A4-0000-0000-C000-000000000046} for its East Asian signature provider.
The GUID of the additionally installed provider should be obtained from the documentation shipped with the provider.
SignTime
The time when the document was signed.
public DateTime SignTime { get; set; }
Property Value
Text
Specifies the text of actual signature in the digital signature. Default value is Empty.
public string Text { get; set; }
Property Value
XAdESType
XAdES type. Default value is None(XAdES is off).
public XAdESType XAdESType { get; set; }