Skip to content

Commit b14d4a2

Browse files
committed
PDFBOX-5940: add comment based on remarks by mkl
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1923409 13f79535-47bb-0310-9956-ffa450edef68
1 parent 8ee818f commit b14d4a2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignatureBase.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff 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)));

0 commit comments

Comments
 (0)