https://github.com/githuseyingur/pades_ltv_pdf_signer_with_sha256_timestamp
PAdES LTV PDF signer with Timestamp & SHA-256, C# Console App
https://github.com/githuseyingur/pades_ltv_pdf_signer_with_sha256_timestamp
csharp pades pades-ltv padesltv pdf-sign pdf-signing pdfsign sha-256 sha256 timestamp
Last synced: 3 months ago
JSON representation
PAdES LTV PDF signer with Timestamp & SHA-256, C# Console App
- Host: GitHub
- URL: https://github.com/githuseyingur/pades_ltv_pdf_signer_with_sha256_timestamp
- Owner: githuseyingur
- License: other
- Created: 2023-05-17T10:55:26.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-21T17:18:18.000Z (over 2 years ago)
- Last Synced: 2025-07-03T22:07:17.873Z (3 months ago)
- Topics: csharp, pades, pades-ltv, padesltv, pdf-sign, pdf-signing, pdfsign, sha-256, sha256, timestamp
- Language: C#
- Homepage:
- Size: 62.5 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# 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](https://slproweb.com/products/Win32OpenSSL.html)*
*Go OpenSSL Directory with 'cd' Command :*
```bash
cd C:\Openssl\bin
```#### Generate an RSA private key:
```bash
C:\Openssl\bin\openssl.exe genrsa -out my_key.key 2048
```#### Generate a Certificate Signing Request:
```bash
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:
```bash
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:
```bash
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*
```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 pathsettings.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](https://gist.github.com/Manouchehri/fd754e402d98430243455713efada710)*### RUN - FINISH
#### OUTPUT :

Add this line if you want see the signature in your pdf file:
```cs
appearance.SetVisibleSignature(new Rectangle(36, 748, 144, 780), 1, "sig");
```
*this will be the output :*