示例#1
0
        public static void Main(string[] args)
        {
            try
            {
                var host = new WebHostBuilder()
                           .UseKestrel(options =>
                {
                    options.UseHttps(@"..\..\certificates\localhost_ssl.pfx", "pass@word1");
                    options.NoDelay = true;

                    //I use this to get rid of SSL errors, feel free to remove it.
                    IConnectionFilter prevFilter = options.ConnectionFilter ?? new NoOpConnectionFilter();
                    options.ConnectionFilter     = new IgnoreSslErrorsConnectionFilter(prevFilter);
                }
                                       )
                           .UseUrls("https://localhost:5000")
                           .UseContentRoot(Directory.GetCurrentDirectory());

                host.UseStartup <Startup>();

                var webHost = host.Build();

                webHost.Run();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Console.ReadKey();
            }
        }
 public ProtocolSwitchConnectionFilter(IConnectionFilter previous)
 {
     _previous = previous;
     if (_previous == null)
     {
         throw new ArgumentNullException();
     }
 }
示例#3
0
 public AuthenticationConnectionFilter(IConnectionFilter previous)
 {
     _previous = previous;
     if (_previous == null)
     {
         throw new ArgumentNullException();
     }
 }
示例#4
0
		public TestConnectionFilter(IConnectionFilter previous)
		{
			if (previous == null)
			{
				throw new ArgumentNullException(nameof(previous));
			}

			_previous = previous;
		}
示例#5
0
        public TestConnectionFilter(IConnectionFilter previous)
        {
            if (previous == null)
            {
                throw new ArgumentNullException(nameof(previous));
            }

            _previous = previous;
        }
        public IgnoreSslErrorsConnectionFilter(IConnectionFilter previousFilter)
        {
            if (previousFilter == null)
            {
                throw new ArgumentNullException(nameof(previousFilter));
            }

            _previousFilter = previousFilter;
        }
示例#7
0
        /// <summary>
        /// Creates a new instance of an object.
        /// </summary>
        /// <param name="previous">Previous connection filter to apply.</param>
        public TlsFilter(IConnectionFilter previous = null)
        {
            if (previous == null)
            {
                previous = new NoOpConnectionFilter();
            }

            this.Options  = Service.Providers.Resolve <CertificateProvider>();
            this.Previous = previous;
        }
        public HttpsConnectionFilter(X509Certificate2 cert, IConnectionFilter previous)
        {
            if (cert == null)
            {
                throw new ArgumentNullException(nameof(cert));
            }
            if (previous == null)
            {
                throw new ArgumentNullException(nameof(previous));
            }

            _cert     = cert;
            _previous = previous;
        }
        public LoggingConnectionFilter(ILogger logger, IConnectionFilter previous)
        {
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (previous == null)
            {
                throw new ArgumentNullException(nameof(previous));
            }

            _logger = logger;
            _previous = previous;
        }
        public LoggingConnectionFilter(ILogger logger, IConnectionFilter previous)
        {
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (previous == null)
            {
                throw new ArgumentNullException(nameof(previous));
            }

            _logger   = logger;
            _previous = previous;
        }
        public HttpsConnectionFilter(X509Certificate2 cert, IConnectionFilter previous)
        {
            if (cert == null)
            {
                throw new ArgumentNullException(nameof(cert));
            }
            if (previous == null)
            {
                throw new ArgumentNullException(nameof(previous));
            }

            _cert = cert;
            _previous = previous;
        }
示例#12
0
        public HttpsConnectionFilter(HttpsConnectionFilterOptions options, IConnectionFilter previous)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (previous == null)
            {
                throw new ArgumentNullException(nameof(previous));
            }
            if (options.ServerCertificate == null)
            {
                throw new ArgumentException("The server certificate parameter is required.");
            }

            _options  = options;
            _previous = previous;
        }
        public HttpsConnectionFilter(HttpsConnectionFilterOptions options, IConnectionFilter previous)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (previous == null)
            {
                throw new ArgumentNullException(nameof(previous));
            }
            if (options.ServerCertificate == null)
            {
                throw new ArgumentException("The server certificate parameter is required.");
            }

            _options = options;
            _previous = previous;
        }
示例#14
0
        public LetoConnectionFilter(LetoConnectionFilterOptions options, IConnectionFilter previous, ILoggerFactory loggerFactory)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (previous == null)
            {
                throw new ArgumentNullException(nameof(previous));
            }
            _factory         = new PipelineFactory();
            _certificateList = new CertificateList();
            var prov = new Tls13.Certificates.OpenSsl11.CertificateProvider();

            _certificateList.AddCertificate(prov.LoadPfx12(options.PfxPath, options.PfxPassword));
            _listener      = new SecurePipelineListener(_factory, _certificateList, loggerFactory);
            _previous      = previous;
            _loggerFactory = loggerFactory;
        }
示例#15
0
 public AuthenticationConnectionFilter(IConnectionFilter previous) =>
        private static IConnectionFilter GetConnectionFilter(IConfigurationRoot config, IConnectionFilter prevFilter)
        {
            var connectionFilterValue = config["connectionFilter"];

            if (string.IsNullOrEmpty(connectionFilterValue))
            {
                return(null);
            }
            else
            {
                var connectionFilterType = Type.GetType(connectionFilterValue, throwOnError: true);
                return((IConnectionFilter)Activator.CreateInstance(connectionFilterType, prevFilter ?? new NoOpConnectionFilter()));
            }
        }
 public PassthroughConnectionFilter(IConnectionFilter previous)
 {
     _previous = previous;
 }
示例#18
0
 public LetoConnectionFilter(LetoConnectionFilterOptions options, IConnectionFilter previous)
     : this(options, previous, loggerFactory : null)
 {
 }
 public TestServiceContext(IConnectionFilter filter)
     : this()
 {
     ServerOptions.ConnectionFilter = filter;
 }