Generating a certificate for AuthenticateAsServer
<p>I am trying to fix <a href="http://code.google.com/p/flowlib/" rel="nofollow">FlowLib</a> which seems to have been abandoned in 2009.</p>

<p>One of the class, TcpConnections.cs (FlowLib.Connections.TcpConnection) is giving me problems. It is trying to setup a SslStream, but the AuthenticateAsServer method doesn't seem to accept any certificate.</p>

<p>Part of the code : </p>

<pre><code>secStream = new SslStream(client.GetStream(),false,
    new RemoteCertificateValidationCallback(OnRemoteCertificateValidation),
    new LocalCertificateSelectionCallback(OnLocalCertificateSelection));

 SslProtocols protocol = SslProtocols.Default;

 X509Certificate cert = new X509Certificate2(@"cert.pfx");
 secStream.AuthenticateAsServer(cert, false, protocol, false);
</code></pre>

<p>I have tried multiple ways to create a certificate but for all certificate it give the following exception : </p>

<pre><code>NotSupportedException : The server mode SSL must use a certificate with the associated private key.
</code></pre>

<p>The code included in the earlier snippet is my latest attempt to get a working certificate 
(taken from another SO answer), earlier it simply created a new certificate using :</p>

<pre><code> secStream.AuthenticateAsServer(new X509Certificate(), true, protocol, true);
</code></pre>

<p>And that code is from the release version, so I am guessing somewhere between 2009 and now the way AuthenticateAsServer worked has changed.</p>

<p>Can someone help me get this to work?</p>

<p>PS : The complete code is available at <a href="http://code.google.com/p/flowlib/downloads/detail?name=FlowLib20090103.zip&amp;can=2&amp;q=" rel="nofollow">here</a> So you can try it out yourself.</p>
