SSLStream

D

Dubravko Sever

Hi,

I have problem with SSLStream. I'm using it with p12 certificate and it
works well when I running my code as console application (manully called).
But problem starts when I tryint run it as windows service (localsystem) and
a got exception: "The server mode SSL must use a certificate with the
associated private key".
If anyone has ideas, please ..


Here is my code :
private void ProcessClient(TcpClient m_clinet) {

SslStream stream = new SslStream(m_clinet.GetStream(), false);

try

{


stream.AuthenticateAsServer(new
X509Certificate("hostcert.p12",""),false,System.Security.Authentication.SslProtocols.Tls
,true );


try {

UnicodeEncoding encoder = new UnicodeEncoding();

// GPGEncrypt encrype = new GPGEncrypt(log);

byte[] buffer = encoder.GetBytes("Some text");

stream.Write(buffer);

stream.Close();

m_clinet.Close();


}

catch (Exception eror){log.WriteLineLog(eror.Message); }


}

catch (AuthenticationException exc) { log.WriteLineLog(exc.Message); }


}



Thanks,
 
D

Dubravko Sever

Dubravko Sever said:
Hi,

I have problem with SSLStream. I'm using it with p12 certificate and it
works well when I running my code as console application (manully
called).
But problem starts when I tryint run it as windows service (localsystem)
and a got exception: "The server mode SSL must use a certificate with the
associated private key".
If anyone has ideas, please ..


Here is my code :
private void ProcessClient(TcpClient m_clinet) {

SslStream stream = new SslStream(m_clinet.GetStream(), false);

try

{


stream.AuthenticateAsServer(new
X509Certificate("hostcert.p12",""),false,System.Security.Authentication.SslProtocols.Tls
,true );


try {

UnicodeEncoding encoder = new UnicodeEncoding();

// GPGEncrypt encrype = new GPGEncrypt(log);

byte[] buffer = encoder.GetBytes("Some text");

stream.Write(buffer);

stream.Close();

m_clinet.Close();


}

catch (Exception eror){log.WriteLineLog(eror.Message); }


}

catch (AuthenticationException exc) { log.WriteLineLog(exc.Message); }


}



Thanks,
Solved,
Problem was with windows service account.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

C# Socket Problem 1

Top