Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. convert XML X.509Certificates

convert XML X.509Certificates

Scheduled Pinned Locked Moved C#
securitycryptographyxmlquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pelos
    wrote on last edited by
    #1

    hi forum, I have made a signed XML document with MS Infopath 2003. Is possible to extract a X.509 Certificate from the XML document and import it to a CAPICOM.Certificate class or a System.Security.Cryptography.X509Certificate class? thanks in advance.

    H 1 Reply Last reply
    0
    • P pelos

      hi forum, I have made a signed XML document with MS Infopath 2003. Is possible to extract a X.509 Certificate from the XML document and import it to a CAPICOM.Certificate class or a System.Security.Cryptography.X509Certificate class? thanks in advance.

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      You can use the classes in the System.Security.Cryptography.Xml namespace to get the SignedXml.SigningKey, which is an AsymmetricAlgorithm. From that an other information you can reconstruct the X.509 certificate that contains the public key. While I don't cover this topic exactly, you might find some helpful hints in my article, Using XML Digital Signatures for Application Licensing[^]. Both this and the signatures used by InfoPath use the industry standard XML Digital Signature specification. You can find more information about that on the W3C[^] site as WS-Signature.

      Microsoft MVP, Visual C# My Articles

      P 1 Reply Last reply
      0
      • H Heath Stewart

        You can use the classes in the System.Security.Cryptography.Xml namespace to get the SignedXml.SigningKey, which is an AsymmetricAlgorithm. From that an other information you can reconstruct the X.509 certificate that contains the public key. While I don't cover this topic exactly, you might find some helpful hints in my article, Using XML Digital Signatures for Application Licensing[^]. Both this and the signatures used by InfoPath use the industry standard XML Digital Signature specification. You can find more information about that on the W3C[^] site as WS-Signature.

        Microsoft MVP, Visual C# My Articles

        P Offline
        P Offline
        pelos
        wrote on last edited by
        #3

        thank you, finally, i did this: System.Xml.XmlNodeList nodeList = XmlDoc.GetElementsByTagName("X509Certificate"); // get the first certificate XmlNode node = (XMLNode)nodelist[0]; CAPICOM.Certificate certificates = new CAPICOM.CertificateClass() certificate.Import(node.InnerText); ..and it seems that works well :confused:

        H 1 Reply Last reply
        0
        • P pelos

          thank you, finally, i did this: System.Xml.XmlNodeList nodeList = XmlDoc.GetElementsByTagName("X509Certificate"); // get the first certificate XmlNode node = (XMLNode)nodelist[0]; CAPICOM.Certificate certificates = new CAPICOM.CertificateClass() certificate.Import(node.InnerText); ..and it seems that works well :confused:

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          What are you confused about? The InnerText is the base64-encoded X.509 certificate, so Import should have no problem reading it (as long as such a method accepts base64-encoded text, which that one obviously does). You should really try to avoid interop'ing the CryptoAPI, however. Most of the functionality you most likely need is already in the .NET Framework SDK. Mixing like this creates additional requirements, not to mentioning that marshaling data types from managed to unmanaged code can be very time consuming for certain types.

          Microsoft MVP, Visual C# My Articles

          P 1 Reply Last reply
          0
          • H Heath Stewart

            What are you confused about? The InnerText is the base64-encoded X.509 certificate, so Import should have no problem reading it (as long as such a method accepts base64-encoded text, which that one obviously does). You should really try to avoid interop'ing the CryptoAPI, however. Most of the functionality you most likely need is already in the .NET Framework SDK. Mixing like this creates additional requirements, not to mentioning that marshaling data types from managed to unmanaged code can be very time consuming for certain types.

            Microsoft MVP, Visual C# My Articles

            P Offline
            P Offline
            pelos
            wrote on last edited by
            #5

            ok. i'll try to do it without CryptoAPI. thank you.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups