https://gist.github.com/trueroad/5fc2de151f717e34b250ac99fa141604
Copyright (C) 2019 Masamichi Hosoda. All rights reserved.
License: BSD-2-Clause
Extract PDF signature tools can extract PKCS#7 signed-data from digitally signed PDF. You can verify the signature with OpenSSL.
Experiment PDF sign tool can create digitally signed PDF.
- qpdf 9.0.2 with following pull requests
- C++11 compiler
- OpenSSL 1.1.1
- GNU make, sh, etc.
- Edit
QPDF_PREFIX
valiable in Makefile - Run
make
command
$ ./extract-pdf-sign input.pdf prefix
extract-pdf-sig
Copyright (C) Masamichi Hosoda 2019
License: BSD-2-Clause
INPUT.pdf : input-signed.pdf
OUTPUT_PREFIX: prefix
--- signature dictionary 21/0 ---
offset sig dict = 59515 (0xe87b)
offset contents = 59599 (0xe8cf)
size contents = 2243
File: /ByteRange [ 0 59599 64087 4759 ]
offset /ByteRange offset1 = 59529 (0xe889)
offset /ByteRange length1 = 59531 (0xe88b)
offset /ByteRange offset2 = 59537 (0xe891)
offset /ByteRange length2 = 59543 (0xe897)
offset eof = 68846 (0x10cee)
Correct: /ByteRange [ 0 59599 64087 4759 ]
writing prefix-21-0-sigdict-contents.p7s ...
writing prefix-21-0-for-md-calc.bin ...
complete
$ openssl smime -verify \
-in prefix-21-0-sigdict-contents.p7s -inform DER \
-content prefix-21-0-for-md-calc.bin \
-noverify -out /dev/null
Verification successful
$
$ ./extract-pdf-sig input-cacert-signed.pdf input-cacert-signed
extract-pdf-sig
Copyright (C) Masamichi Hosoda 2019
License: BSD-2-Clause
INPUT.pdf : input-cacert-signed.pdf
OUTPUT_PREFIX: input-cacert-signed
--- signature dictionary 5/0 ---
offset sig dict = 691 (0x2b3)
offset contents = 754 (0x2f2)
size contents = 8192
File: /ByteRange [ 0 754 17140 1080 ]
offset /ByteRange offset1 = 707 (0x2c3)
offset /ByteRange length1 = 709 (0x2c5)
offset /ByteRange offset2 = 713 (0x2c9)
offset /ByteRange length2 = 719 (0x2cf)
offset eof = 18220 (0x472c)
Correct: /ByteRange [ 0 754 17140 1080 ]
writing input-cacert-signed-5-0-sigdict-contents.p7s ...
writing input-cacert-signed-5-0-for-md-calc.bin ...
complete
$ openssl smime -verify \
-in input-cacert-signed-5-0-sigdict-contents.p7s -inform DER \
-content input-cacert-signed-5-0-for-md-calc.bin \
-CAfile root_X0F.crt \
-out /dev/null
Verification successful
$
Do you have a compiled version for windows?