pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1802185 - /pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignatureBase.java
Date Mon, 17 Jul 2017 18:21:37 GMT
Author: tilman
Date: Mon Jul 17 18:21:37 2017
New Revision: 1802185

URL: http://svn.apache.org/viewvc?rev=1802185&view=rev
Log:
PDFBOX-3017: remove certificate and use certificateChain[0] instead

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=1802185&r1=1802184&r2=1802185&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 Jul 17 18:21:37 2017
@@ -65,7 +65,6 @@ import org.bouncycastle.util.Store;
 public abstract class CreateSignatureBase implements SignatureInterface
 {
     private PrivateKey privateKey;
-    private Certificate certificate;
     private Certificate[] certificateChain;
     private TSAClient tsaClient;
     private boolean externalSigning;
@@ -101,8 +100,7 @@ public abstract class CreateSignatureBas
                 continue;
             }
             setCertificateChain(certChain);
-            cert = keystore.getCertificate(alias);
-            setCertificate(cert);
+            cert = certChain[0];
             if (cert instanceof X509Certificate)
             {
                 // avoid expired certificate
@@ -122,11 +120,6 @@ public abstract class CreateSignatureBas
         this.privateKey = privateKey;
     }
 
-    public final void setCertificate(Certificate certificate)
-    {
-        this.certificate = certificate;
-    }
-
     public final void setCertificateChain(final Certificate[] certificateChain)
     {
         this.certificateChain = certificateChain;
@@ -221,10 +214,9 @@ public abstract class CreateSignatureBas
         {
             List<Certificate> certList = new ArrayList<Certificate>();
             certList.addAll(Arrays.asList(certificateChain));
-            certList.add(certificate);
             Store certs = new JcaCertStore(certList);
             CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
-            org.bouncycastle.asn1.x509.Certificate cert = org.bouncycastle.asn1.x509.Certificate.getInstance(certificate.getEncoded());
+            org.bouncycastle.asn1.x509.Certificate cert = org.bouncycastle.asn1.x509.Certificate.getInstance(certificateChain[0].getEncoded());
             ContentSigner sha1Signer = new JcaContentSignerBuilder("SHA256WithRSA").build(privateKey);
             gen.addSignerInfoGenerator(new JcaSignerInfoGeneratorBuilder(new JcaDigestCalculatorProviderBuilder().build()).build(sha1Signer,
new X509CertificateHolder(cert)));
             gen.addCertificates(certs);



Mime
View raw message