Click here to Skip to main content
15,887,975 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,

Good Day,

I am working on a SOAP Web Service, where i want to make soap message signing. i have done the Message signing using the rsa, but i need to create the signature based on RSA SHA256. When i am trying to import the key and perform the message signature, i want to get the below

<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>

but i am still getting

<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>

Can anybody help me what i have to do to achieve..

What I have tried:

public static void SignedXmlDocumentwithCertificate(XmlDocument doc, X509Certificate2 cert)
{
try
{
SignedXml signedxml = new SignedXml(doc);
signedxml.SigningKey = cert.PrivateKey;
Reference referece = new Reference();
referece.Uri = "";
XmlDsigEnvelopedSignatureTransform env = new XmlDsigEnvelopedSignatureTransform();
referece.AddTransform(env);
signedxml.AddReference(referece);
KeyInfo KeyInfo = new KeyInfo();
KeyInfoX509Data keyData = new KeyInfoX509Data(cert);
keyData.AddSubjectName(cert.SubjectName.Name);
KeyInfo.AddClause(keyData);
// KeyInfo.AddClause(new KeyInfoX509Data(cert));
signedxml.KeyInfo = KeyInfo;
signedxml.ComputeSignature();
XmlElement xmlsig = signedxml.GetXml();
XmlNode parentNode = doc.SelectSingleNode("HedeNode/XMLAuthenticateRequest");
//parentNode.FirstChild.RemoveAll();
parentNode.AppendChild(doc.ImportNode(xmlsig, true));
// check the validity before send to the api
}
catch (Exception ex)
{
throw ex;
}

}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900