Reputation: 13
I am trying to listen for a secured TCP connection on a port. I was going through the server code example on microsoft docs. I am pasting here for quick reference:
static void ProcessClient (TcpClient client)
{
// A client has connected. Create the
// SslStream using the client's network stream.
SslStream sslStream = new SslStream(
client.GetStream(), false);
// Authenticate the server but don't require the client to authenticate.
try
{
sslStream.AuthenticateAsServer(serverCertificate, clientCertificateRequired: false, checkCertificateRevocation: true);
// Display the properties and settings for the authenticated stream.
DisplaySecurityLevel(sslStream);
DisplaySecurityServices(sslStream);
DisplayCertificateInformation(sslStream);
DisplayStreamProperties(sslStream);
My doubt is why server is authenticating itself? Or am I missing something here.
Upvotes: 0
Views: 472
Reputation: 33098
Perhaps you're missing the "As". That call tells the SslStream that it should prepare for the TLS handshake (where authentication happens), and that it is taking the server role in the handshake.
So it's really "start the authentication phase, as the server".
Upvotes: 0