I have web application and need to Authenticate server by certificate
this code get error "An attempt was made to access a socket in a way forbidden by its access permissions" how can resolve problem
X509Certificate2 CER = new X509Certificate2(Server.MapPath("MyServer.cer"), "password");// Has to be a private X509cert with key
TcpListener listener = new TcpListener(IPAddress.Any, 44300);
listener.Start();
TcpClient client = listener.AcceptTcpClient();
Console.WriteLine("client accepted");
try
{
SslStream stream = new SslStream(client.GetStream());
stream.AuthenticateAsServer(CER, false, SslProtocols.Tls12, false);
Console.WriteLine("server authenticated");
stream.Close();
Console.Read();
}
catch (AuthenticationException err)
{
Console.WriteLine("Exception: {0}", err.Message);
Console.WriteLine("Authentication failed - closing the connection.");
return;
}