In order to sign a PDF i use signDetached.
...
OcspClient ocspClient = new OcspClientBouncyCastle();
MakeSignature.signDetached(appearance, digest, pks, chain, crlList, ocspClient, tsaClient, estimatedSize, subfilter);
The PDF is signed without errors, nevertheless the embedded OCSP response is missing:
- The OCSP server works properly, but
- The CA i'm using signs OCSP responses with a trusted responderCert (different from the issuerCert).
How could i force signDetached to embed the OCSP status without verifing the OCSP response (or pass to signDetached the responderCert to trust) ?
Moreover
when I try to verify the OCSP status via com.itextpdf.text.pdf.security.OCSPVerifier verify i get the error:
Java::JavaSecurity::SignatureException: certificate does not verify with supplied key
In this case we use the Swiss Government CA:
Swiss Government Root CA I
`- Swiss Government Enhanced CA 01 < issuer certificate
`- Mor... < signature certificate
The OCSP responses are signed by :
Swiss Government Root CA II
`- Swiss Government SSL CA 01
`- Swiss Government OCSP < OCSP responderCert
Root and intermediate certificates are available here:
- https://www.bit.admin.ch/adminpki/00247/00790/index.html?lang=de (SG Root CA I)
- https://www.bit.admin.ch/adminpki/00247/05329/index.html?lang=de (SG Root CA II)
Inspecting the sample PDF one can clearly see that the OCSP response is embedded:
Thus to answer the question:
There is no need to force, iText does embed the retrieved OCSP response without further checks (a quick code review supports this).
But it still is no surprise you are getting into trouble with that Swiss Government CA and their certificate structure.
According to RFC 2560 (which is explicitly referenced from the PDF specification ISO 32000-1 and, therefore, has to be used here in spite of it been obsoleted by RFC 6960):
For Swiss Government CA signatures this means:
So generally those OCSP responses MUST be rejected.
And if you also look at the newer RFC 6960 you'll see:
So nowadays the certificate structure used by the Swiss Government CA even is explicitly strongly discouraged (which essentially means that the IETF would have forbidden it if they had been able/allowed to).