Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In .NET, If you get your X509 cert from a .pfx file, like this: </p> <pre><code> X509Certificate2 certificate = new X509Certificate2(certFile, pfxPassword); RSACryptoServiceProvider rsaCsp = (RSACryptoServiceProvider) certificate.PrivateKey; </code></pre> <p>Then you can export the public key portion like so: </p> <pre><code> rsaCsp.ToXmlString(false); </code></pre> <p>The "false" part says, only export the public piece, don't export the private piece. (doc for <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.rsa.toxmlstring.aspx" rel="noreferrer">RSA.ToXmlString</a>)</p> <p>And then in the verifying application, use </p> <pre><code> RSACryptoServiceProvider csp = new RSACryptoServiceProvider(); csp.FromXmlString(PublicKeyXml); bool isValid = VerifyXml(xmlDoc, rsa2); </code></pre> <p>And the VerifyXml calls <code>CheckSignature()</code>. It looks something like this: </p> <pre><code>private Boolean VerifyXml(XmlDocument Doc, RSA Key) { // Create a new SignedXml object and pass it // the XML document class. var signedXml = new System.Security.Cryptography.Xml.SignedXml(Doc); // Find the "Signature" node and create a new XmlNodeList object. XmlNodeList nodeList = Doc.GetElementsByTagName("Signature"); // Throw an exception if no signature was found. if (nodeList.Count &lt;= 0) { throw new CryptographicException("Verification failed: No Signature was found in the document."); } // Though it is possible to have multiple signatures on // an XML document, this app only supports one signature for // the entire XML document. Throw an exception // if more than one signature was found. if (nodeList.Count &gt;= 2) { throw new CryptographicException("Verification failed: More that one signature was found for the document."); } // Load the first &lt;signature&gt; node. signedXml.LoadXml((XmlElement)nodeList[0]); // Check the signature and return the result. return signedXml.CheckSignature(Key); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload