Ready-to-run C# and PowerShell samples for the .NET Digital Signature Library. Every sample is a complete Visual Studio project (or script) included in the library download; the user manual describes all the classes, properties and methods.
PDF digital signatures (PAdES)
Sign PDF documents with visible or invisible signatures, in bulk or without user intervention.
- Digitally Sign a PDF File in C#: digitally sign a PDF file with a certificate from a PFX file or a smart card, with a visible or a certification signature.
- Visible PDF Signature in C#: Image, Position and Pages: a visible PDF signature with an image, a custom text and position, on one page, on several pages or on every page.
- Sign PDF Files Without User Intervention in C#: sign PDF files with a certificate of the Windows store, without a certificate selection window or a PIN window. For services.
- Batch (Bulk) PDF Digital Signature in C#: sign all the PDF files of a folder in one operation, with one signature object, a progress count and error handling per file.
- Verify PDF Digital Signatures in C#: verify the signatures of a PDF: integrity, document coverage, certificate validity, chain, CRL and OCSP, time-stamps.
Long-term validation and archiving
Signatures that can be validated years later: time-stamps, validation data and archive time-stamps.
- PAdES-LTA PDF Signature in C#: Long-Term Archival: sign a PDF with PAdES-B-LTA (time-stamp, validation data and document time-stamp) and renew the archive time-stamp.
- CAdES-LTA Signature in C#: Long-Term Archival: create a CAdES-BASELINE-LTA signature (P7M, P7S) with signature time-stamp, validation data and archive time-stamp.
- ASiC-E LTA Signature in C#: Long-Term Archival Containers: create an ASiC-E container with XAdES-B-LTA signatures and renew its archive time-stamp for long-term archival.
- XAdES-LTA Signature in C#: Long-Term Archival XML Signatures: create a XAdES-B-LTA signature with time-stamp, validation data and archive time-stamp, and renew the archive time-stamp.
XML digital signatures (XAdES, XMLDSig)
XAdES signatures from B-B to B-LTA, the XML format of the eIDAS signatures and of e-invoicing, and basic XMLDSig signatures.
- XAdES Digital Signature in C# (XAdES-B-B, B-T, B-LT): sign XML documents and any file with XAdES (ETSI EN 319 132): enveloped or detached, time-stamped, with a signature policy.
- XML Digital Signature (XMLDSig) in C#: sign an XML document with an enveloped XMLDSig signature (SHA-256), add a second signature and verify all the signatures.
ASiC-E signature containers
Sign several files of any type together in one .asice container (ETSI EN 319 162), with signatures up to LTA.
- ASiC-E Container Digital Signature in C#: sign several files in an ASiC-E container (.asice) with XAdES signatures up to LTA, add co-signatures, extract and verify.
CAdES, P7M and P7S signatures
Sign files of any type in the CAdES / PKCS#7 format and verify P7M and P7S files.
- CAdES, P7M and P7S Digital Signature in C#: sign a file of any type in CAdES format, as a P7M file (attached) or as a detached P7S signature.
- Verify CAdES (P7M, P7S) Digital Signatures in C#: verify the signatures of a P7M or detached P7S file, read the signer and the time-stamp, and extract the signed file.
- Batch (Bulk) CAdES Digital Signature in C#: sign all the files of a folder in CAdES format as P7M files, one by one or in parallel with Parallel.ForEach.
HSM, smart cards and cloud keys
Sign with private keys that never leave a smart card, an HSM, Azure Key Vault or a remote signing service.
- PDF Signature with an External or Remote Signing Service in C#: sign a PDF when the private key is not in the application: a custom signing engine or a remote signing service (IExternalSignature).
- Sign PDF with an HSM (PKCS#11) in C#: sign a PDF with a private key stored in an HSM (Luna, Utimaco, nShield, YubiHSM) or a token, through its PKCS#11 module.
- Sign PDF with an Azure Key Vault Certificate in C#: download an exportable certificate from Azure Key Vault (PKCS#12 secret) and sign a PDF file with it.
- Sign PDF with a Non-exportable Azure Key Vault HSM Key in C#: sign a PDF with a non-exportable Azure Key Vault or Managed HSM key; the signature value is created inside Azure.
Time-stamps (RFC 3161)
Add trusted time-stamps to documents.
- Add a Timestamp to a PDF File in C# (RFC 3161): add a document time-stamp (RFC 3161) to a PDF file, without a signing certificate, and read the time-stamps of a PDF.
Office documents (DOCX, XLSX, PPTX)
Sign Word, Excel and PowerPoint documents, with signature lines.
- Digitally Sign Word, Excel and PowerPoint Documents in C#: sign Word, Excel and PowerPoint documents with the signatures shown by Microsoft Office, with signature lines, and verify them.
Digital certificates
Create test certificates and check the validity and the revocation of a certificate.
- Create a Self-Signed Digital Certificate (PFX) in C#: create a self-signed PFX certificate, a root (CA) certificate and a user certificate issued by it, with RSA or ECDSA keys.
- Verify a Digital Certificate in C#: CRL and OCSP: check the validity period of a certificate and its revocation status with the CRL and the OCSP responder, and read its key usages.
- Is a Certificate Qualified? Check It in C# with the EU Trusted Lists: check whether a certificate is qualified and which qualified trust service branch its issuer belongs to, with the free .NET eIDAS Certificate Validator.
PowerShell scripts
Sign and verify documents from Windows PowerShell, in scripts and scheduled tasks.
- Digitally Sign a PDF File in PowerShell: sign a PDF file with a PFX certificate or a smart card certificate, visible or invisible, PKCS#7 or PAdES, time-stamped.
- CAdES, P7M and P7S Digital Signature in PowerShell: sign any file in CAdES format as a P7M or a detached P7S file, add a co-signature, choose the CAdES level.
- Digitally Sign an Office Document in PowerShell: sign DOCX, XLSX and PPTX documents without Microsoft Office, with a Word signature line and a time-stamp.
- XAdES Digital Signature in PowerShell (up to XAdES-LTA): sign an XML document (enveloped) or any file (detached) with XAdES, levels B, T, LT and LTA, with a commitment type.
- Create a Self-Signed Digital Certificate in PowerShell: create a self-signed PFX certificate for document signing, with the subject, the validity, the key and the key usages.