By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,679 Members | 1,063 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,679 IT Pros & Developers. It's quick & easy.

SSLStream

P: n/a
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.Se curity.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,


May 4 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"Dubravko Sever" <Du******************@foi.hrwrote in message
news:f1**********@news1.carnet.hr...
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.Se curity.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.

May 4 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.