I need to sign (and verify eventually) one of the nodes of an XML document using RSA-SHA1 algorithm. w3.org link
RSA-SHA1 URI:
http://www.w3.org/2000/09/xmldsig#rsa-sha1
Specified in:
section 6.4.2 of [XMLDSIG-CORE2002]
I am following this example, however cannot figure how to change the algorithm to required.
The signature generation happens here:
signedXml.ComputeSignature();
The only override with a parameter expects KeyedHashAlgorithm
:
public void ComputeSignature(KeyedHashAlgorithm macAlg);
(link)
KeyedHashAlgorithm
(link) in turn only allows creating HMAC* and MAC* algorithms and has no RSA-SHA1.
What is the most painless way of signing an XML with RSA-SHA1 in .Net?
Edit:
I'm trying to use a X509 certificate to extract the key. Certificate's signature algorithm property is sha1RSA
.
This is how I'm assigning it:
var signedXml = new SignedXml(xmlDoc);
...
signedXml.SigningKey = (RSACryptoServiceProvider)cert.PrivateKey;
...
signedXml.ComputeSignature();
The resulting signature xml format matches expected one, however digest
and signature
values are invalid.