Skip to content

githuseyingur/PAdES_LTV_Pdf_Signer_SHA256_with_Timestamp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PAdES LTV Pdf Signer with Timestamp & SHA-256

What we need for signing a Pdf with Timestamp?

  • pfx (PKCS12) file
  • an exist Pdf file with random data (You can write a string inside the file like "Hello World") -- sha256.pdf

Generating a pfx(PKCS12) FILE for Testing

Open Command Line(CMD) and apply following lines:

Install OpenSSL --> Download OpenSSL

Go OpenSSL Directory with 'cd' Command :

cd C:\Openssl\bin

Generate an RSA private key:

C:\Openssl\bin\openssl.exe genrsa -out my_key.key 2048

Generate a Certificate Signing Request:

C:\Openssl\bin\openssl.exe req -new -key my_key.key -out my_request.csr

Generate a self-signed public certificate based on the request:

C:\Openssl\bin\openssl.exe x509 -req -days 3650 -in my_request.csr -signkey my_key.key -out my_cert.crt

Generate a PKCS12 file:

C:\Openssl\bin\openssl.exe pkcs12 -keypbe PBE-SHA1-3DES -certpbe PBE-SHA1-3DES -export -in my_cert.crt -inkey my_key.key -out my_pkcs12.pfx -name "my-name"



Sign Your Pdf with Certificate(Pkcs12) using SHA-256 & Timestamp

Change Files Directories and add TSA Client In Program.cs

const string originalPdfPath = @"C:\padestest\sha256.pdf";  // unsigned pdf file path (an existing pdf file)
const string finalPdfPath = @"C:\padestest\signed.pdf";  // output signed pdf file path

settings.SetTsaClient("http://timestamp.identrust.com/", "", "");

What is TSA Client?

We need TSA url, user id and password for add timestamp into our pdf file. There are many free TSA Client Servers for test --> Free Timestamp Servers

RUN - FINISH

OUTPUT :

Ekran görüntüsü 2023-05-17 162332

Ekran görüntüsü 2023-05-17 162726

Add this line if you want see the signature in your pdf file:

 appearance.SetVisibleSignature(new Rectangle(36, 748, 144, 780), 1, "sig");

this will be the output :

sign

Releases

No releases published

Packages

No packages published

Languages