- Run
python3 extract_sig.py
to extract the signature from the input PDF file. Copy the 'Contents' value into a file called 'signature.hex' - Run
xxd -r -p signature.hex > signature.der
to convert to binary - Run
openssl pkcs7 -inform DER -in signature.der -print_certs > certs.pem
to save the certificate tocerts.pem
- Run
python3 split_certs.py
to split the certificates into individual files - Run
openssl x509 -in cert_XXX.pem -text -noout
to view the certificate contents whereXXX
is 1 2 or 3 - Run
python3 verify_sig.py
to verify the signature - Run
openssl pkcs7 -inform DER -in signature.der -print
to view the signature contents
- To verify the root certificate:
- From the root certificate, the SignatureValue signs all the data in the self certificate except the SignatureValue and SignatureAlgorithm (called the "to-be-signed")
- The root SignatureAlgorithm is the RSA + SHA algorithm that is used
- Check that the SignatureValue decrypted with the Modulus matches the hash of the "to-be-signed" data
- To verify the intermediate certificate, the same process is repeated, except the SignatureValue is signed by the pub key of the root certificate
- Signature Regex
- Nice to have - Extract Not Before and Not After timestamps
- Extract Modulus and Exponent
- Content Regex
- Nice to have, maybe just compute hash according to byte start / end array?
- Edge cases
- Certificate may have been revoked
- X.509v3 extensions can contain additional constraints or data that can influence the validity or usage of the certificate. Ensure you understand and validate any critical extensions present in the certificate.