/// <summary> /// Signs the XML document. /// </summary> /// <param name="doc">The document.</param> /// <param name="cert">The cert.</param> /// <returns></returns> private XmlElement SignXmlDocument(XmlDocument doc, X509Certificate2 cert) { //Full Framework Only //var xmlPrivateKey = cert.PrivateKey.ToXmlString(true); //.Net Standard Extension var xmlPrivateKey = RSAKeyExtensions.ToXmlString((RSA)cert.PrivateKey, true); return(SignXmlDocument(doc, cert, xmlPrivateKey)); }
/// <summary> /// Gets the signed authentication request. /// </summary> /// <param name="cert">The cert.</param> /// <returns></returns> public string GetSignedAuthRequest(X509Certificate2 cert) { var xmlPrivateKey = ""; #if NETFULL xmlPrivateKey = cert.PrivateKey.ToXmlString(true); #else xmlPrivateKey = RSAKeyExtensions.ToXmlString((RSA)cert.PrivateKey, true); #endif return(GetSignedAuthRequest(cert, xmlPrivateKey)); }
/// <summary> /// Signs the XML document. /// </summary> /// <param name="doc">The document.</param> /// <param name="cert">The cert.</param> /// <returns></returns> public static XmlElement SignXmlDocument(XmlDocument doc, X509Certificate2 cert) { string xmlPrivateKey = ""; //Full Framework Only #if NETFULL xmlPrivateKey = cert.PrivateKey.ToXmlString(true); #else //.Net Standard Extension xmlPrivateKey = RSAKeyExtensions.ToXmlString((RSA)cert.PrivateKey, true); #endif return(SignXmlDocument(doc, cert, xmlPrivateKey)); }
/// <summary> /// Gets the signed authentication request. /// </summary> /// <param name="cert">The cert.</param> /// <returns></returns> public string GetSignedAuthRequest(X509Certificate2 cert) { var xmlPrivateKey = ""; //Full Framework Only //var xmlPrivateKey = cert.PrivateKey.ToXmlString(true); //.Net Standard Extension //var xmlPrivateKey = RSAKeyExtensions.ToXmlString((RSA)cert.PrivateKey, true); #if NETFULL xmlPrivateKey = cert.PrivateKey.ToXmlString(true); #endif #if NETSTANDARD1_0 xmlPrivateKey = RSAKeyExtensions.ToXmlString((RSA)cert.PrivateKey, true); #endif return(GetSignedAuthRequest(cert, xmlPrivateKey)); }