1

I am working on an application which will do digital signatures on PDF. Every thing is working fine till we are putting the pdfRevocationInfoArchival(1.2.840.113583.1.1.8) attribute in CMSSignedData(PKCS#7) as signed attribute. After putting the signature(PKCS#7) the document we are getting and empty signature field in the signed PDF.

For Reference: Empty Signature filed

We are getting valid signed document if we are not adding the pdfRevocationInfoArchival(1.2.840.113583.1.1.8) attribute in the CMSSignedData(PKCS#7) object.

For Reference: Valid Signature

Source code reference: 1. Adding CRLs in ASN1EncodableVector:

private static ASN1EncodableVector genPdfInfoArchival(List<X509CRL> crls) {

        ASN1EncodableVector v1 = new ASN1EncodableVector();

        try {

                        
            if (!crls.isEmpty()) {
                ASN1EncodableVector v11 = new ASN1EncodableVector();
                for (Iterator<X509CRL> i = crls.iterator(); i.hasNext();) {
                    ASN1InputStream t = new ASN1InputStream(new ByteArrayInputStream(i.next().getEncoded()));
                    v11.add(t.readObject());
                }
                // 0 for CRL
                v1.add(new DERTaggedObject(true, 0, new DERSequence(v11)));
            }
        } catch (Exception ex) {

        }

        return v1;
    }

2. Adding CRL revocation attribute in CMSSignedData as signed attribute

CMSSignedData cmsSignedData = null;
CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
Store certStore = new JcaCertStore(Arrays.asList(dscCert.getCertChain()));

ASN1EncodableVector signedAttr = new ASN1EncodableVector();
ASN1EncodableVector crlVector = genPdfInfoArchival(crlDetails);
Attribute pdfRevocationAttr = new Attribute(new ASN1ObjectIdentifier(ID_ADBE_REVOCATION),   new DERSet (new DERSequence(crlVector)));
signedAttr.add(pdfRevocationAttr);

Attribute attrHash = new Attribute(CMSAttributes.messageDigest, new DERSet(new DEROctetString(pdfHash)));               
signedAttr.add(attrHash);

// Adding signed atribute in the CMSSignedData

ContentSigner sha1Signer = new JcaContentSignerBuilder(dscCert.getSigAlgName()) .build(dscCert.getPrivateKey());
gen.addSignerInfoGenerator( new JcaSignerInfoGeneratorBuilder(new JcaDigestCalculatorProviderBuilder().build()) .setSignedAttributeGenerator( new DefaultSignedAttributeTableGenerator(new AttributeTable(signedAttr))).build(sha1Signer, dscCert.getCertificate()));

gen.addCertificates(certStore);


cmsSignedData = gen.generate(new CMSAbsentContent());

Please help us in this issue.

We have tried every thing but no luck.

0 Answers0