Digital signatures can be applied for many types of documents where traditional pen-and-ink signatures were used in the past. However, the mere existence of a digital signature is not adequate assurance that a document is what it appears to be. Moreover, government and enterprise settings often need to impose additional constraints on their signature workflows, such as restricting user choices and document behavior during and after signing.
For these reasons, the PDF provides mechanisms for two broad categories of tasks:
In a PDF, signature information is contained in a signature dictionary. Objects in the dictionary are defined by the PDF Reference.
The signature dictionary can reference, or be referenced by, other dictionaries. The entries in these dictionaries determine the nature and features of the signature, and by extension, what data can be available to any PDF viewer designed to process the signature data.
While other viewers may vary in their support of PDF language features, PDF .Net by SautinSoft supports all of those features. At a high level, that process can be grouped into these categories:
Digital signatures on PDF documents can tell you if the PDF has been modified. You can use the PDF. Net library to verify digital signatures on PDF files. The library can help you read signature properties in .NET Framework and .NET Core applications.
General PDF digital signature authenticity special review:
And after loading your PDF document inside, the engine is checking the field - signatureValidationResult.IsValid:
Var signature = signatureField.Value;
if (signature != null)
{
var signatureValidationResult = signature.Validate();
if (signatureValidationResult.IsValid)
{
Console.Write("Signature '{0}' is VALID, signed by '{1}'. ", signatureField.Name, signature.Content.SignerCertificate.SubjectCommonName);
Console.WriteLine("The document has not been modified since this signature was applied.");
}
else
{
Console.Write("Signature '{0}' is INVALID. ", signatureField.Name);
Console.WriteLine("The document has been altered or corrupted since the signature was applied.");
}
To verify digital signature in PDF C# code is presented here that uses the PdfSignature class object to accomplish the task.
The result of validation will be like this:
Complete code
using SautinSoft.Pdf;
using SautinSoft.Pdf.Forms;
using System;
class Program
{
static void Main()
{
using (var document = PdfDocument.Load(@"..\..\Multiple Digital Signature.pdf"))
{
foreach (var field in document.Form.Fields)
if (field.FieldType == PdfFieldType.Signature)
{
var signatureField = (PdfSignatureField)field;
var signature = signatureField.Value;
if (signature != null)
{
var signatureValidationResult = signature.Validate();
if (signatureValidationResult.IsValid)
{
Console.Write("Signature '{0}' is VALID, signed by '{1}'. ", signatureField.Name, signature.Content.SignerCertificate.SubjectCommonName);
Console.WriteLine("The document has not been modified since this signature was applied.");
}
else
{
Console.Write("Signature '{0}' is INVALID. ", signatureField.Name);
Console.WriteLine("The document has been altered or corrupted since the signature was applied.");
}
}
}
}
}
}
Option Infer On
Imports SautinSoft.Pdf
Imports SautinSoft.Pdf.Forms
Imports System
Friend Class Program
Shared Sub Main()
Using document = PdfDocument.Load("..\..\Multiple Digital Signature.pdf")
For Each field In document.Form.Fields
If field.FieldType = PdfFieldType.Signature Then
Dim signatureField = CType(field, PdfSignatureField)
Dim signature = signatureField.Value
If signature IsNot Nothing Then
Dim signatureValidationResult = signature.Validate()
If signatureValidationResult.IsValid Then
Console.Write("Signature '{0}' is VALID, signed by '{1}'. ", signatureField.Name, signature.Content.SignerCertificate.SubjectCommonName)
Console.WriteLine("The document has not been modified since this signature was applied.")
Else
Console.Write("Signature '{0}' is INVALID. ", signatureField.Name)
Console.WriteLine("The document has been altered or corrupted since the signature was applied.")
End If
End If
End If
Next field
End Using
End Sub
End Class
If you need a new code example or have a question: email us at support@sautinsoft.com or ask at Online Chat (right-bottom corner of this page) or use the Form below: