79203200

Date: 2024-11-19 11:19:16
Score: 1.5
Natty:
Report link

Great! @Mr. Y for identifying the root cause, the correct approach for signing PDFs is to use certificates stored in Azure Key Vault instead of keys.

Thank you to @mkl for suggesting that I share this as an answer to help others who might face a similar issue.

enter image description here

Use the CryptographyClient.signData method to sign the raw PDF content instead of the digest.

Code:

CryptographyClient cryptoClient = new CryptographyClientBuilder()
    .keyIdentifier("<your-key-vault-url>/certificates/my-certificate")
    .credential(new DefaultAzureCredentialBuilder().build())
    .buildClient();

// Sign the raw PDF content
SignResult signResult = cryptoClient.signData(SignatureAlgorithm.RS256, pdfContent);
byte[] signature = signResult.getSignature();

The signed PDF is now valid, as it contains the required certificate chain. Adobe Acrobat validates the signature successfully.

Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Long answer (-1):
  • Has code block (-0.5):
  • Me too answer (2.5): face a similar issue
  • User mentioned (1): @mkl
  • High reputation (-1):
Posted by: Suresh Chikkam