Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7761591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:10:30+00:00 2026-06-01T14:10:30+00:00

I’m using the SSLStream example from msdn here . The client code seems to

  • 0

I’m using the SSLStream example from msdn here. The client code “seems” to work fine, as I can connect to google and it at least gets past authentication, but the server doesn’t.

From the comments from the msdn page, I used the procedure on this page to generate my own private key, but it just doesn’t work. I get an exception of System.NotSupportedException: The server mode SSL must use a certificate with the associated private key. So I’m pretty sure whatever I’m doing is wrong.

So my question is simple: how do I get/generate keys that will work for my own little example program from msdn? It can be self-signed, whatever, but I’m too new to SSL to even know what exactly I need. All I want to do is to run the example as-given, except for specifying my own certificates for my local server. And it’d be great to know what I’d have to install on my 2nd machine if I just want to communicate between the two of them too (so it’s not a 100% localhost example).

Personally I see this as a flaw in the example document. It should say “to run this, you need to do A, B, C, etc,” but it doesn’t.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:10:32+00:00Added an answer on June 1, 2026 at 2:10 pm

    You can get the example to work even with self-signed certificates. I’ve extracted the commands from the makecert tutorial that you’re using with minor modifications:

    makecert -sv RootCATest.pvk -r -n "CN=FakeServerName" RootCATest.cer
    makecert -ic RootCATest.cer -iv RootCATest.pvk -n "CN=FakeServerName" -sv  TempCert.pvk -pe -sky exchange TempCert.cer
    cert2spc TempCert.cer TempCert.spc
    pvkimprt -pfx TempCert.spc TempCert.pvk
    

    makecert and cert2psc can be found in your Microsoft SDKs\Window\v7.0A\Bin folder.
    The pvkImport.exe installer can be downloaded here (Provided by @Jospeph and VirusTotal verified). This used to be downloadable from the Microsoft Site, but they have since taken it down. Alternatively, @Dweeberly pointed us to a new Microsoft-provided replacement, pvk2pfx.

    For this next step make sure that you select to EXPORT the private key when the dialog from pvkimprt comes up:

    pvkimprt -pfx TempCert.spc TempCert.pvk
    

    enter image description here

    pvkimprt will prompt you for a password when you elect to include the private key. You will need to provide this password later when you import the generated .pfx file into the personal store of your server machine

    enter image description here

    Next, import RootCATest.cer into your Computer store’s Trusted Root Certification Authorities (on both the server and client). Notice that the certificate is issued to FakeServerName. This must match the server name that the SslTcpClient expects: sslStream.AuthenticateAsClient(serverName), where serverName is the value of the second argument passed to SslTcpClient.exe.

    When your client connects, the server presents a certificate that tells the client “I’m FakeServerName”. The client will accept this claim if the client machine trusts the CA that issued the certificate, which is achieved by importing RootCATest.cer into the client’s Trusted Root Certification Authorities.

    Finally, you need to import the private key that the server is going to use into the server machine’s Personal store. This step is important because it addresses The server mode SSL must use a certificate with the associated private key.. This is achieved by importing the .pfx file that you generated earlier. Make sure that you change the file type filter to “all files” so that you can see the .pfx file that you generated:

    enter image description here

    The sample code provided by MSDN uses port 443 (which is the standard ssl port). Since I created console applications, I changed the port used by the sample classes to 8080:

    SslTcpServer:

    TcpListener listener = new TcpListener(IPAddress.Any, 8080);
    

    SslTcpClient:

    TcpClient client = new TcpClient(machineName, 8080);
    

    Here’s the output:

    enter image description here

    you would launch your server like this:

    SslTcpServer.exe TempCert.cer 
    

    from the client, you would connect like this:

    SslTcpClient.exe <ip to your server> FakeServerName
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm making a simple page using Google Maps API 3. My first. One marker
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.