I need to digitally sign a pdf in java.
All My tracing links are taking me to c# references but I need in java [Java references required private key to sign but based on document and api response there are no private key].
Reference Link : Sign multiple location with same response xml signature in PKCS7 (CMS) How to sign digital signature in pdf using python Why I am getting an error while opening digitally signed pdf document using PKCS7 and X509Certificate in C#?
As same as the above link i am getting the same xml response from API. Below is the sample of API Response.
<?xml version="1.0" encoding="UTF-8"?>
<EsignResp errCode="NA" errMsg="NA" resCode="1233333333333312121" status="1" ts="2024-03-14T14:59:39" txn="reference-transaction">
<UserX509Certificate>base64 value of eSign user certificate(.cer)</UserX509Certificate>
<Signatures>
<DocSignature error="" id="1" sigHashAlgorithm="SHA256">Signature data in raw (PKCS#1) or raw( ECDSA ) or PKCS7 (CMS) signature as requested
</DocSignature>
</Signatures>
<Signature
xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"></CanonicalizationMethod>
<SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"></SignatureMethod>
<Reference URI="">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></Transform>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
<DigestValue>xxxxxxxx</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>xxxxxxxxxxxxxxxxxxxx</SignatureValue>
<KeyInfo>
<KeyValue>
<RSAKeyValue>
<Modulus>xxxxxxxxxxxx</Modulus>
<Exponent>xxxxx</Exponent>
</RSAKeyValue>
</KeyValue>
<X509Data>
<X509SubjectName>xxxxxxxxxxxxxxx</X509SubjectName>
<X509Certificate>xxxxxxxxxx</X509Certificate>
</X509Data>
</KeyInfo>
</Signature>
</EsignResp>
As per API DOC:
UserX509Certificaterefers to This element will contain the Base 64 value of the Certificate. No private key information is shared. For manual verification, this value can be copied and saved as .cer fileSignaturesrefers to This element contains the sub-elements of signatures corresponding to InputHash.DocSignaturerefers to This element will contain the Signed value in raw (PKCS#1) or raw( ECDSA ) or PKCS7 (CMS) signature format as per the request XML which will be verifiable against original document
Thanks every one.