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;
}
}