public static void ConfigureEndpoints(this KestrelServerOptions options) { var logger = options.ApplicationServices.GetRequiredService <ILoggerFactory>() .CreateLogger <Program>(); var config = options.ApplicationServices.GetRequiredService <IConfiguration>(); var noHttps = config.GetValue <bool>("nohttps"); if (noHttps) { options.ConfigureEndPoint(config, "http", Constants.DefaultHttpPort, Constants.DefaultHttpBind, logger, listenOptions => { listenOptions.UseConnectionLogging(); } ); } else { var httpsConf = config.GetSection("https"); if (httpsConf is null || !httpsConf.Exists() || httpsConf["cert"] is null) { throw new ConfigException("You must specify either --nohttps option or --https.cert "); } var cert = httpsConf.GetOrDefault("cert", Constants.DefaultCertFile); var certPass = httpsConf.GetOrDefault("certpass", string.Empty); logger.LogDebug($"Using https certificate: {cert}"); options.ConfigureEndPoint(config, "https", Constants.DefaultHttpsPort, Constants.DefaultHttpsBind, logger, listenOptions => { listenOptions.UseConnectionLogging(); listenOptions.UseHttps(new X509Certificate2(cert, certPass)); }); } # region p2p