Back to all Bounties
Earn 45,000 ($450.00)
due 12 months ago
Open
XML Digital Signing and Verification using NodeJS
AkhilJayaprakas
Details
Applications
7
Discussion
Bounty Description
Problem Description
I have an XML payload that I want to digitally sign with a private key and a certificate. It should follow this spec https://www.w3.org/TR/2002/REC-xmldsig-core-20020212/
The input is going to be like this
<ABC:Pay><Head msgId=“ABN0001234" orgId=“XYZ” ts=“2024-07-02T09:00:00" ver=“1.0”/><Meta/><Txn id=“AB1324536435423" note=“” orgTxnId=“” refId=“” refUrl=“” ts=“2024-07-02T09:00:00” type=“DEBIT”><VehicleDetails><Detail name=“AVC” value=“1"/><Detail name=“LPNumber” value=“AABB12345"/></VehicleDetails></Vehicle><Payment></Payment></ABC:Pay>
While the output needs to be like this
<ABC:Pay><Head msgId=“ABN0001234" orgId=“XYZ” ts=“2024-07-02T09:00:00" ver=“1.0”/><Meta/><Txn id=“AB1324536435423" note=“” orgTxnId=“” refId=“” refUrl=“” ts=“2024-07-02T09:00:00” type=“DEBIT”><VehicleDetails><Detail name=“AVC” value=“1"/><Detail name=“LPNumber” value=“AABB12345"/></VehicleDetails></Vehicle><Payment></Payment><Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/><SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/><Reference><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/><Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/></Transforms><DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/><DigestValue>9Td/39PSMwhahkY+......</DigestValue></Reference></SignedInfo><SignatureValue>PDFA7NBJbg7........</SignatureValue><KeyInfo><X509Data><X509SubjectName>CN=www.google.com</X509SubjectName><X509Certificate>MIIGPDCCBSSgAwIBAgIQLzbO....</X509Certificate></X509Data></KeyInfo></Signature></ABC:Pay>
Acceptance Criteria
The code needs to fulfil all the following requirements
- The base path / should load up a website with a form where I can enter the XML payload I wish to sign and click on submit
- The signed output should be printed on the same website before the submit button
- Below the signed output, there should be a field which should if the signature is valid (or not valid), and if the digest is valid (or not valid)
- As a user I should be able to clone the replit, add my own private_key.pem and certifcate.pem file into the root folder and run the code to digitally sign the XML.