Click or drag to resize
Pdf Library for .NET

PdfCertificateStoreSigner Class

Signs with a certificate from the system certificate store, found by its thumbprint - including a certificate whose private key lives on a smart card or USB token registered by its middleware.
Inheritance Hierarchy
SystemObject
  SelectPdf.UniversalPdfCertificateStoreSigner

Namespace: SelectPdf.Universal
Assembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.5
Syntax
public sealed class PdfCertificateStoreSigner : IPdfExternalSigner, 
	IDisposable

The PdfCertificateStoreSigner type exposes the following members.

Constructors
 NameDescription
Public methodPdfCertificateStoreSigner(String) Creates a signer for the certificate with the given thumbprint in the personal certificate store.
Public methodPdfCertificateStoreSigner(String, PdfCertificateSystem) Creates a signer for the certificate with the given thumbprint in the given certificate store.
Top
Properties
 NameDescription
Public propertyCertificate Gets the signing certificate.
Public propertyCertificates Gets the certificates embedded in the signature, each DER-encoded: the signing certificate first, then the certificates of its issuers.
Top
Methods
 NameDescription
Public methodDispose Releases the certificate taken from the store. The signer can no longer sign afterwards, so dispose of it after the documents it signs are saved. Calling it more than once does nothing.
Public methodSign Signs the request with the certificate's private key.
Top
Remarks

The private key never leaves the store: the signature is made by the store's key provider, which for a smart card or token is the device itself, and which asks for the PIN when the device requires one. The issuer certificates are found the way the platform builds a certificate chain and are embedded in the signature.

The certificate is looked up in the current user's store and then in the local machine's. RSA (PKCS#1 v1.5) and ECDSA keys are supported.

Example
// The thumbprint shown by the certificate manager (certmgr.msc).
// Dispose of the signer after the save: the document is signed when it is saved.
using var signer = new PdfCertificateStoreSigner(
    "BABEA413778B70C92E266D2458E193BD6E62A6E3");

using PdfSecurityManager manager = new PdfSecurityManager();
manager.Load("contract.pdf");
manager.Sign(signer, "Signature1");
manager.Save("contract-signed.pdf");
See Also