c # – Sign an xml with digital certificate

I'm trying to sign an XML file, from an NFS-e.
These are the functions that have happened to me:

public static MemoryStream stringToStream (data string)
{
MemoryStream memoryStream;
try
{
byte[] byteArray = new byte[dados.Length];
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding ();
byteArray = encoding.GetBytes (data);
memoryStream = new MemoryStream (byteArray);
memoryStream.Seek (0, SeekOrigin.Begin);
}
catch (Exception ex)
{
return null;
}

return memoryStream;
}

private void montaEnvelope (HttpWebRequest webRequest, XmlDocument document)
{
string soapEnvelope = string.Empty;
"soapEnvelope + ="";
"soapEnvelope + ="";
soapEnvelope + = document.LastChild.OuterXml.Replace ("", string.Empty);
"soapEnvelope + ="01001001000113123456";

MemoryStream stream = stringToStream (soapEnvelope);
webRequest.ContentLength = stream.Length;
Stream requestStream = webRequest.GetRequestStream ();
stream.WriteTo (requestStream);

document.LoadXml (SoapEnvelope);
document.Save (@ "E:  _ Xml.xml");
this.XmlDocNFSe = document;
}

private static string getSoapResponse (HttpWebRequest webRequest)
{
string soapResult = string.Empty;

WebResponse webResponse = webRequest.GetResponse ();
StreamReader rd = new StreamReader (webResponse.GetResponseStream ());
soapResult = rd.ReadToEnd ();

XmlDocument xmlResponse = new XmlDocument ();
xmlResponse.LoadXml (soapResult);
XmlNode responseNode = xmlResponse.LastChild.LastChild.FirstChild;
return responseNode.InnerXml;
}

private static HttpWebRequest getWebRequest (string url, string method)
{
HttpWebRequest webRequest = (HttpWebRequest) HttpWebRequest.Create (url);
webRequest.Timeout = 100000;
webRequest.Headers.Add ("SOAPAction", method);
webRequest.ContentType = "text / xml; charset = " utf-8  "";
webRequest.Accept = "text / xml";
webRequest.Method = "POST";
return webRequest;
}

private string post (string url, string method, string xml, X509Certificate2 certificate)
{
try
{
XmlDocument doc = new XmlDocument ();
doc.LoadXml (XML);

HttpWebRequest webRequest = getWebRequest (url, method);
webRequest.ClientCertificates.Add (certificate);

(in the case of companies).
return getSoapResponse (webRequest);
}
catch (Exception ex)
{
return null;
}
}

But since the code was not what I developed, I have some doubts, and I do not know how to pass the certificate to the variable, I know the other data, which are like this:

                ("http: //es.ffx.html"), "Exercise", "Exercise", "Exercise"
certificateaqui);

How do I change to the certificate function? In the event that this is not the case,