I saw a similar reply to a C# question about signature data being hashed twice, however not sure why my signature data here.
C# PKCS7 Smartchard Digital Signature corrupted
String provider = sdk.getProviderName();
List certList = new ArrayList();
certList.add(signerCert);
Store certs = new JcaCertStore(certList);
CMSSignedDataGenerator cmsSignedDataGenerator = new CMSSignedDataGenerator();
DigestCalculatorProvider digProvider = new JcaDigestCalculatorProviderBuilder().setProvider(provider).build();
JcaSignerInfoGeneratorBuilder signerInfoGeneratorBuilder = new JcaSignerInfoGeneratorBuilder(digProvider);
ContentSigner sha256Signer = new JcaContentSignerBuilder("SHA256withRSA").setProvider(provider).build(signerKey);
cmsSignedDataGenerator.addSignerInfoGenerator(signerInfoGeneratorBuilder.build(sha256Signer, signerCert));
cmsSignedDataGenerator.addCertificates(certs);
CMSTypedData msg = new CMSProcessableByteArray(digest);
CMSSignedData cmsSignedData = cmsSignedDataGenerator.generate(msg);
Map hashes = new HashMap();
hashes.put(CMSAlgorithm.SHA256, digest);
CMSSignedData finalCMSSignedData = new CMSSignedData(hashes, cmsSignedData.getEncoded());
return finalCMSSignedData.getEncoded();`
.pkcs7
signature file next to the.pdf
file) or an PDF integrated signature - visible or invisible embedded in the PDF (as it can be created using Acrobat for example)? – Robert