Guest User

Untitled

a guest
Jun 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. static class Server
  2. {
  3. static void Main()
  4. {
  5. TcpListener L = new TcpListener(IPAddress.Parse("127.1.2.3"), 4300);
  6. L.Start();
  7. TcpClient C = L.AcceptTcpClient();
  8. X509Certificate Cert = new X509Certificate("public.pfx", "Password");
  9. SslServerStream S = new SslServerStream
  10. (C.GetStream(), Cert, false, true,
  11. Mono.Security.Protocol.Tls.SecurityProtocolType.Ssl3);
  12. byte[] Buff = new byte[C.Available];
  13. S.Read(Buff);
  14. Console.WriteLine("C: " + Encoding.UTF8.GetString(Buff));
  15. string Reply = "LoooL";
  16. S.Write(Encoding.UTF8.GetBytes(Reply));
  17. Console.WriteLine("S: " + Reply);
  18. S.Close();
  19. C.Close();
  20. L.Stop();
  21. Console.ReadKey(true);
  22. }
  23. }
  24.  
  25. static class Client
  26. {
  27. static void Main()
  28. {
  29. TcpClient C = new TcpClient("127.1.2.3", 4300);
  30. SslClientStream S = new SslClientStream
  31. (C.GetStream(), "ServerNameFromCertFile", true, SecurityProtocolType.Ssl3);
  32. string Messsage = "LoL";
  33. S.Write(Encoding.UTF8.GetBytes(Messsage));
  34. Console.WriteLine("C: " + Messsage);
  35. byte[] Buff = new byte[C.Available];
  36. S.Read(Buff);
  37. Console.WriteLine("S: " + Encoding.UTF8.GetString(Buff));
  38. S.Close();
  39. C.Close();
  40. Console.ReadKey(true);
  41. }
  42. }
Add Comment
Please, Sign In to add comment