Пример #1
0
        public static void Main(string[] args)
        {
            var logFactory = new LoggerFactory();

            logFactory.AddConsole(LogLevel.Trace);

            using (var factory = new PipeFactory())
                using (var list = new CertificateList())
                {
                    var thumb = "48026c976caaf7f3a72d38c17d16ce69d04a6053".ToUpper();
                    //var provider = new Leto.Tls13.Certificates.Windows.CertificateProvider();
                    //list.AddCertificate(provider.LoadCertificate(new X509Certificate2(_rsaCertPath, _certificatePassword)));
                    //list.AddCertificate(provider.LoadCertificateFromStore(thumb,true));
                    var provider = new Leto.Tls13.Certificates.OpenSsl11.CertificateProvider();
                    list.AddCertificate(provider.LoadPfx12(_ecdsaCertPath, _certificatePassword));
                    using (var serverContext = new SecurePipeListener(factory, list, logFactory))
                        using (var socketClient = new System.IO.Pipelines.Networking.Sockets.SocketListener(factory))
                        {
                            var ip         = IPAddress.Loopback;
                            int port       = 443;
                            var ipEndPoint = new IPEndPoint(ip, port);
                            socketClient.OnConnection(s =>
                            {
                                Console.WriteLine("Connected");
                                var sp = serverContext.CreateSecurePipeline(s);
                                Console.WriteLine("Secure Connection Created");
                                return(ServerLoop.HandleConnection(sp, logFactory));
                            });
                            socketClient.Start(ipEndPoint);
                            Console.ReadLine();
                        }
                }
        }
Пример #2
0
 public static void Main(string[] args)
 {
     using (var factory = new PipelineFactory())
         using (var list = new CertificateList())
         {
             var thumb    = "48026c976caaf7f3a72d38c17d16ce69d04a6053".ToUpper();
             var provider = new Leto.Tls13.Certificates.Windows.CertificateProvider();
             list.AddCertificate(provider.LoadCertificateFromStore(thumb, true));
             using (var serverContext = new SecurePipelineListener(factory, list))
                 using (var socketClient = new System.IO.Pipelines.Networking.Sockets.SocketListener(factory))
                 {
                     var ip         = IPAddress.Any;
                     int port       = 443;
                     var ipEndPoint = new IPEndPoint(ip, port);
                     socketClient.OnConnection(async s =>
                     {
                         Console.WriteLine("Connected");
                         var sp = serverContext.CreateSecurePipeline(s);
                         Console.WriteLine("Secure Connection Created");
                         await ServerLoop.HandleConnection(sp);
                     });
                     socketClient.Start(ipEndPoint);
                     Console.ReadLine();
                 }
         }
 }