Click or drag to resize

CmsInformation Class

This class represents the CMS information used to sign a PDF document.
Inheritance Hierarchy
SystemObject
  Atalasoft.PdfDoc.DigitalSignaturesCmsInformation

Namespace:  Atalasoft.PdfDoc.DigitalSignatures
Assembly:  Atalasoft.PdfDoc (in Atalasoft.PdfDoc.dll) Version: 11.0.0.0.0.297 (.NET 4.5.2, x86)
Syntax
public class CmsInformation

The CmsInformation type exposes the following members.

Constructors
  NameDescription
Public methodCmsInformation(X509Certificate2Collection)
Initializes a new instance of the CmsInformation class.
Public methodCmsInformation(X509Certificate2Collection, PdfContentDigestMethod, UnsupportedContentDigestAlgorithmAction)
Initializes a new instance of the CmsInformation class.
Top
Properties
  NameDescription
Public propertyCertificates
Gets the certificates collection. This represents the certificate or chain of certificates used to sign the document. The actual signer will always be the first.
Public propertyContentDigestMethod
Gets the content digest method that will be used to create a message digest of the PDF file.

Note that this is currently only used for signature creation and not for reflecting the method used in a signed file.

Public propertyContentDigestMethodIsSupported
Gets a value indicating whether the ContentDigestMethod is supported by the provided certificate if it is supported, it will be used as is. If it is unsupported, at the time of saving the document (in PdfDocument or PdfGeneratedDocument) or signing (in PdfDocumentSigner), the UnsupportedContentDigestAlgorithmAction will be invoked.
Public propertyUnsupportedContentDigestAlgorithmAction
Gets the action that will be taken when the ContentDigestMethod is not supported.
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Remarks
When a PDF document is signed, the X509Certificate2Collection is used to create a cryptographic signature that will be embedded in the PDF file. If the certificate uses RSA encryption and the RSACryptoServiceProvider object in the certificate does not support the specified digest algorithm, DotPdf will attempt to use BouncyCastle to perform the signing. This will only work as a fall back method if the certificate came from a file and the file was opened as having the private key exportable.

Otherwise, the property ContentDigestMethodIsSupported will be false and at the time of signing, DotPdf will invoke the action in the property UnsupportedContentDigestAlgorithmAction. Almost certainly, certificates that come from the Windows certificate store will NOT have an exportable private key.

Examples
This sample shows how to open a certificate file to allow exporting a private key.
X509Certificate2 cert = new X509Certificate2(pathToACertFile, yourCertPassword, X509KeyStorageFlags.Exportable);
Examples
How to determine the set of supported digest methods.
public IList<PdfContentDigestMethod> GetSupportedDigestMethods(X509Certificate2Collection certificates)
{
    List<PdfContentDigestMethod> meths = new List<PdfContentDigestMethod>();
    foreach (PdfContentDigestMethod method in Enum.GetValues(typeof(PdfContentDigestMethod)))
    {
        CmsInformation cms = new CmsInformation(certificate, method, UnsupportedContentDigestAlgorithmAction.FallBackToSHA1);
        if (cms.ContentDigestMethodIsSupported)
            meths.Add(method);
    }
    return meths;
}
See Also