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. Web Development
  3. SSL, but not via a web server

SSL, but not via a web server

Scheduled Pinned Locked Moved Web Development
sysadminsecuritycryptographytutorialquestion
2 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.
  • T Offline
    T Offline
    TimWallace
    wrote on last edited by
    #1

    I have an application that basically acts as a web server (it's more involved then that, but this gets the point across). I am putting the code in place to use SSL to secure the stream. I need to test this on my local PC, so of course I need a test cert. Try as I might, I cannot get makecert.exe create a certificate that will let me export it to a file as an X.509 certificate for use in my code (e.g. X509Certificate.CreateFromCertFile()). Can anyone point me toward a good tutorial on the whole process of doing this, please?

    R 1 Reply Last reply
    0
    • T TimWallace

      I have an application that basically acts as a web server (it's more involved then that, but this gets the point across). I am putting the code in place to use SSL to secure the stream. I need to test this on my local PC, so of course I need a test cert. Try as I might, I cannot get makecert.exe create a certificate that will let me export it to a file as an X.509 certificate for use in my code (e.g. X509Certificate.CreateFromCertFile()). Can anyone point me toward a good tutorial on the whole process of doing this, please?

      R Offline
      R Offline
      Rob Smiley
      wrote on last edited by
      #2

      You need 2 or 3 files to implement this - .cer for the public key, .pvk for the private key and optionally (recommended) a .pfx for the combined certificate store key. This is the sequence i've used before to generate all the bits: makecert -n "CN=My Secure Key" -sv "MyKey.pvk" MyKey.cer cert2spc "MyKey.cer" "MyKey.spc" pvk2pfx -pvk "MyKey.pvk" -pi KeyPassword -spc "MyKey.spc" -pfx "MyKey.pfx" -f Once you have the files, embed the .cer in the 'public' past of your code, Install the .pfx in the server certificate store. Load the .cer with X509Certificate2 & find the private key in X509Store, e.g.

      _publicCert = New X509Certificate2()
      _publicCert.Import(My.Resources.PublicKeyCer)

      Dim certStore As X509Store = New X509Store()
      certStore.Open(OpenFlags.ReadOnly)

      For Each installObj As X509Certificate2 In certStore.Certificates.Find(X509FindType.FindByThumbprint, _publicCert.Thumbprint, False)

      Next

      Hope this helps, Rob

      "An eye for an eye only ends up making the whole world blind"

      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