File tree Expand file tree Collapse file tree 1 file changed +3
-0
lines changed
examples/src/main/java/org/apache/pdfbox/examples/signature Expand file tree Collapse file tree 1 file changed +3
-0
lines changed Original file line number Diff line number Diff line change @@ -138,6 +138,9 @@ public byte[] sign(InputStream content) throws IOException
138138 {
139139 CMSSignedDataGenerator gen = new CMSSignedDataGenerator ();
140140 X509Certificate cert = (X509Certificate ) certificateChain [0 ];
141+ // cert.getSigAlgName() returns the algorithm the certificate itself has been signed with,
142+ // this is usually also the algorithm to use for signing, but not always.
143+ // See also the comment by mkl at the bottom of https://issues.apache.org/jira/browse/PDFBOX-5940
141144 ContentSigner sha1Signer = new JcaContentSignerBuilder (cert .getSigAlgName ()).build (privateKey );
142145 gen .addSignerInfoGenerator (new JcaSignerInfoGeneratorBuilder (new JcaDigestCalculatorProviderBuilder ().build ()).build (sha1Signer , cert ));
143146 gen .addCertificates (new JcaCertStore (Arrays .asList (certificateChain )));
You can’t perform that action at this time.
0 commit comments