SslStream.BeginAuthenticateAsServer gives exception
- From: "zing" <zingzangboom@xxxxxxxxxxx>
- Date: 31 Aug 2006 05:28:46 -0700
Does anyone know why I get an exception when I calll
SslStream.EndAuthenticateAsServer ?
When I use (the synchronous) AuthenticateAsServer, everything works
fine. When I use BeginAuthenticateAsServer instead, calling
EndAuthenticateAsServer gives an IOException stating "Authentication
failed because the remote party has closed the transport stream."
The inner stream of the SslStream is my own TcpStream capable of
asynchronous tcp transport. The TcpStream itself has been tested
thoroughly and works correctly. I don't close or disconnect anything
myself, so it must be the SslStream that closes the stream, assuming
the error message is correct.
A bit of code:
secureStream = new SslStream (tcpStream, true,
this.ClientAuthenticationCallback);
#if ASYNC_SERVER_AUTHENTICATION
// todo: find out why the asynchronous version won't work.
secureStream.BeginAuthenticateAsServer (this.serverCertificate, true,
System.Security.Authentication.SslProtocols.Tls, true,
this.AuthenticateAsServerCallback, secureStream);
#else
secureStream.AuthenticateAsServer (this.serverCertificate, true,
System.Security.Authentication.SslProtocols.Tls, true);
#endif
private bool ClientAuthenticationCallback (object inSender,
X509Certificate inClientCertificate, X509Chain inChain, SslPolicyErrors
inSslPolicyErrors)
{
if (inSslPolicyErrors == SslPolicyErrors.None)
{
return true;
}
else
{
return false;
}
}
private void AuthenticateAsServerCallback (IAsyncResult inResult)
{
SslStream secureStream = (SslStream) inResult.AsyncState;
try
{
secureStream.EndAuthenticateAsServer (inResult);
}
catch (Exception exception)
{
// ... this is where I get the exception
}
}
.
- Prev by Date: caspol -addpset
- Next by Date: Re: ASP.NET Cookie Handling
- Previous by thread: caspol -addpset
- Next by thread: How do we become a trusted publisher so ClickOnce works smoothly?
- Index(es):
Relevant Pages
|