I Want sign XML doc. I am doing following for generating signature(ruby).
unsigned_xml = <<-xml
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
xml
sdoc = Xmldsig::SignedDocument.new(unsigned_xml)
signature_xml = File.read('signature.xml')
sdoc.document.children.children.last.add_next_sibling(signature_xml)
privkey = OpenSSL::PKey::RSA.new(File.read('bd-key.pem'))
sdoc.sign(privkey)
Please see signature.xml and output below,
signature.xml
<Signature xmlns="http://ift.tt/uq6naF">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://ift.tt/y9fQ1c"/>
<SignatureMethod Algorithm="http://ift.tt/zf1Wx4"/>
<Reference URI="">
<Transforms>
<Transform Algorithm="http://ift.tt/A1C4L2"/>
</Transforms>
<DigestMethod Algorithm="http://ift.tt/1jbsD3O"/>
<DigestValue/>
</Reference>
</SignedInfo>
<SignatureValue/>
<KeyInfo>
<KeyValue>
<RSAKeyValue>
<Modulus></Modulus>
<Exponent></Exponent>
</RSAKeyValue>
</KeyValue>
</KeyInfo>
</Signature>
output.xml
<?xml version="1.0"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
<Signature xmlns="http://ift.tt/uq6naF">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://ift.tt/y9fQ1c"/>
<SignatureMethod Algorithm="http://ift.tt/zf1Wx4"/>
<Reference URI="">
<Transforms>
<Transform Algorithm="http://ift.tt/A1C4L2"/>
</Transforms>
<DigestMethod Algorithm="http://ift.tt/1jbsD3O"/>
<DigestValue>IssCQWd+dCUvTL9QuVgE/TzecC3wSbzQQ71CLrjpJGQ=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>COI61D+lQ1lLJ17wIBKr+O2kV4au97BMqM+EVPePw6g/itAq4UGBueGhANvYvElzyQcd12dTyh3QUhh/4rUorP6PXuO6eF6f9m13h3rRUupgeKaQbE65j1uvOGj1uXqMoNEuNHSUatATBkXJlfg3PCQfKyywHmW2GTtSKsvfj7WaQ7X9qnJMaCJXdOFS7eEFZ5C9KIutxIKRrH+YsaibwkVOfBYoVNVF08PjUfEpUMHCL6+z2WedRSwLxDPe0ByAN3eLsqGfVOLPSXvB7q3Y+sjE9cE5+vIxHlKhNzlYYayaY0B8Txa79b/g2Rl3fcajKHqVH+FD2lGFVdfktrksjg==</SignatureValue>
<KeyInfo>
<KeyValue>
<RSAKeyValue>
<Modulus/>
<Exponent/>
</RSAKeyValue>
</KeyValue>
</KeyInfo>
</Signature>
</note>
But 3rd party service return SIGNATURE MISMATCHING when posting above XML payload. I think issue is due to Modulus and Exponent are missing from output.xml.
My question is how to generate Modulus and Exponent?
Aucun commentaire:
Enregistrer un commentaire