Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static class Server
- {
- static void Main()
- {
- TcpListener L = new TcpListener(IPAddress.Parse("127.1.2.3"), 4300);
- L.Start();
- TcpClient C = L.AcceptTcpClient();
- X509Certificate Cert = new X509Certificate("public.pfx", "Password");
- SslServerStream S = new SslServerStream
- (C.GetStream(), Cert, false, true,
- Mono.Security.Protocol.Tls.SecurityProtocolType.Ssl3);
- byte[] Buff = new byte[C.Available];
- S.Read(Buff);
- Console.WriteLine("C: " + Encoding.UTF8.GetString(Buff));
- string Reply = "LoooL";
- S.Write(Encoding.UTF8.GetBytes(Reply));
- Console.WriteLine("S: " + Reply);
- S.Close();
- C.Close();
- L.Stop();
- Console.ReadKey(true);
- }
- }
- static class Client
- {
- static void Main()
- {
- TcpClient C = new TcpClient("127.1.2.3", 4300);
- SslClientStream S = new SslClientStream
- (C.GetStream(), "ServerNameFromCertFile", true, SecurityProtocolType.Ssl3);
- string Messsage = "LoL";
- S.Write(Encoding.UTF8.GetBytes(Messsage));
- Console.WriteLine("C: " + Messsage);
- byte[] Buff = new byte[C.Available];
- S.Read(Buff);
- Console.WriteLine("S: " + Encoding.UTF8.GetString(Buff));
- S.Close();
- C.Close();
- Console.ReadKey(true);
- }
- }
Add Comment
Please, Sign In to add comment