/// <summary> /// Creates a new proxy server instance. Really there should only ever be a single instance /// created at a time. /// </summary> /// <param name="configuration"> /// The proxy server configuration to use. /// </param> /// <exception cref="ArgumentException"> /// Will throw if any one of the callbacks in the supplied configuration are not defined. /// </exception> public ProxyServer(ProxyServerConfiguration configuration) { _configuration = configuration; if (_configuration == null || !_configuration.IsValid) { throw new ArgumentException("Configuration is null or invalid. Ensure that all callbacks are defined."); } _tlsConnAdapter = new TlsSniConnectionAdapter(CreateCertificateStore(configuration.AuthorityName ?? "CitadelCore")); _fwCallback = configuration.FirewallCheckCallback ?? throw new ArgumentException("The firewall callback MUST be defined.", nameof(configuration)); _replayResponseFactory = new ReplayResponseHandlerFactory(); _httpResponseFactory = new FilterResponseHandlerFactory(_configuration, _replayResponseFactory); // Hook the cert verification callback. ServicePointManager.ServerCertificateValidationCallback += CertificateVerificationHandler; }
public PublicServerStartup(IHostingEnvironment env, FilterResponseHandlerFactory handlerFactory) { _handlerFactory = handlerFactory; }