sslstream and certificates

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



This is a question about partly .net sslStreams and partly about the
certificates it uses.
I can't seem to find a more specific group.. and since i am coding in c# :-)

I try creating a sslStream from a regular networkstream as folows

Socket clientSocket = serverSocket.EndAccept(result);
clientSocket.Blocking = true;
Stream clientStream = new NetworkStream(clientSocket);
SslStream sslStream = new SslStream(clientStream);
X509Certificate cert =
X509Certificate.CreateFromCertFile(@"c:\mycertificate.crt");
sslStream.AuthenticateAsServer(cert);

The call to AuthenticateAsServer fails with "The server mode SSL must use a
certificate with the associated private key"

What exactly should i put into that message? It needs another kind of
certificate with the private key embedded?
I do have a keyfile on the side with one of my certificates, but I can not
specify it anywhere.
Another certificate , I am testing with, is from rapidSSL a CA so I assume
it should be "right".

Has someone else tried setting up a sslStream as server?

What I am working on is a http server for a program that needs to provide a
web interface. I would very much like to have it running though SSL. Note
that this is ofcourse not an asp application but regular winforms.


.



Relevant Pages

  • Re: regarding retrival of server certificate
    ... I think it might be better if you just try one of the samples for SslStream ... Joe Kaplan-MS MVP Directory Services Programming ... get a server certificate for validation and authentication. ...
    (microsoft.public.dotnet.security)
  • sslstream and certificates
    ... I try creating a sslStream from a regular networkstream as folows ... Socket clientSocket = serverSocket.EndAccept; ... certificate with the associated private key" ...
    (microsoft.public.dotnet.security)
  • Re: sslstream and certificates
    ... > The call to AuthenticateAsServer fails with "The server mode SSL must ... > use a certificate with the associated private key" ... > Has someone else tried setting up a sslStream as server? ...
    (microsoft.public.dotnet.security)
  • Re: Can SslStream be set to ignore invalid certificates?
    ... the certificate validation callback allows you to do your own checking. ... is much more SSL functionality in .NET 2.0, such as the SslStream, I ... If authentication succeeds, everything in the ... In IE, for instance, if you run across an "invalid" certificate, you ...
    (microsoft.public.dotnet.security)
  • Unable to connect client to server using sslstream
    ... I am trying to connect client to server using sslstream. ... created certificate using makecert.exe and using the same.The example i ...
    (microsoft.public.dotnet.framework)