I am using TCPDF to generate a pdf document and sign it. TCPDF itself just calls PHP's openssl_pkcs7_sign
function, which seems to me to be calling C's PKCS7_sign
function based on source code.
Until recently things were working fine. Then I changed certificate provider. I just updated the private key, the certificate, and the certificate chain :
$pdf->setSignature(
$this->public_certificate_path,
$this->private_key_path,
$this->private_key_password,
$this->extra_certificates_path,
1);
I copied the new root certificate and intermediate certificate in PEM format inside the extra_certificates_path
file. I verified this file using openssl
and it seems fine.
Now when I open a signed PDF in Adobe Reader, it shows these errors :
- While opening the file, it says
This file is damaged but is being repaired
- The blue ribbon on top says
Certification by is invalid
- When I open the signature panel, it says
Certified by %s
- Details of errors say
There are errors in the formatting or information contained in this signature (support information: SigDict /Contents illegal data)
- When I click on "Certificate details", nothing happens
See screenshot below.
Any idea what could be wrong ?
PKCS7_sign
appears to only create the CMS signature container, reserving a placeholder in the pdf for that container must have happened before thePKCS7_sign
call. – mkl