You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2025/01/27 18:40:43 UTC

svn commit: r1923408 - /pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignatureBase.java

Author: tilman
Date: Mon Jan 27 18:40:43 2025
New Revision: 1923408

URL: http://svn.apache.org/viewvc?rev=1923408&view=rev
Log:
PDFBOX-5940: add comment based on remarks by mkl

Modified:
    pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignatureBase.java

Modified: pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignatureBase.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignatureBase.java?rev=1923408&r1=1923407&r2=1923408&view=diff
==============================================================================
--- pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignatureBase.java (original)
+++ pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignatureBase.java Mon Jan 27 18:40:43 2025
@@ -136,6 +136,9 @@ public abstract class CreateSignatureBas
         {
             CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
             X509Certificate cert = (X509Certificate) certificateChain[0];
+            // cert.getSigAlgName() returns the algorithm the certificate itself has been signed with,
+            // this is usually also the algorithm to use for signing, but not always.
+            // See also the comment by mkl at the bottom of https://issues.apache.org/jira/browse/PDFBOX-5940
             ContentSigner sha1Signer = new JcaContentSignerBuilder(cert.getSigAlgName()).build(privateKey);
             gen.addSignerInfoGenerator(new JcaSignerInfoGeneratorBuilder(new JcaDigestCalculatorProviderBuilder().build()).build(sha1Signer, cert));
             gen.addCertificates(new JcaCertStore(Arrays.asList(certificateChain)));