コード例 #1
0
ファイル: Program.cs プロジェクト: benaadams/Leto
        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
ファイル: CrossingTheStreams.cs プロジェクト: benaadams/Leto
        public static void Setup()
        {
            _factory     = new PipeFactory();
            _certificate = new X509Certificate2(certPath, certPassword);
            var certs    = new Leto.Tls13.CertificateList();
            var provider = new Leto.Tls13.Certificates.OpenSsl11.CertificateProvider();

            certs.AddCertificate(provider.LoadPfx12(certPath, certPassword));
            _listener = new Leto.Tls13.SecurePipeListener(_factory, certs, null);
        }