public void CreateNewHttpReservations(HttpSysHostingOptions originalOptions, HttpSysHostingOptions newOptions, List <Action> rollbackActions) { string httpOld = originalOptions.BuildHttpUrlPrefix(); string httpsOld = originalOptions.BuildHttpsUrlPrefix(); string httpNew = newOptions.BuildHttpUrlPrefix(); string httpsNew = newOptions.BuildHttpsUrlPrefix(); UrlAcl existingHttpOld = this.GetUrlReservation(httpOld); if (existingHttpOld != null) { UrlAcl.Delete(existingHttpOld.Prefix); rollbackActions.Add(() => UrlAcl.Create(existingHttpOld.Prefix, existingHttpOld.Sddl)); } UrlAcl existingHttpsOld = this.GetUrlReservation(httpsOld); if (existingHttpsOld != null) { UrlAcl.Delete(existingHttpsOld.Prefix); rollbackActions.Add(() => UrlAcl.Create(existingHttpsOld.Prefix, existingHttpsOld.Sddl)); } UrlAcl existingHttpNew = this.GetUrlReservation(httpNew); if (existingHttpNew != null) { UrlAcl.Delete(existingHttpNew.Prefix); rollbackActions.Add(() => UrlAcl.Create(existingHttpNew.Prefix, existingHttpNew.Sddl)); } UrlAcl existingHttpsNew = this.GetUrlReservation(httpsNew); if (existingHttpsNew != null) { UrlAcl.Delete(existingHttpsNew.Prefix); rollbackActions.Add(() => UrlAcl.Create(existingHttpsNew.Prefix, existingHttpsNew.Sddl)); } this.CreateUrlReservation(httpNew, this.windowsServiceProvider.ServiceSid); rollbackActions.Add(() => UrlAcl.Delete(httpNew)); this.registryProvider.HttpAcl = httpNew; rollbackActions.Add(() => this.registryProvider.HttpAcl = httpOld); this.CreateUrlReservation(httpsNew, this.windowsServiceProvider.ServiceSid); rollbackActions.Add(() => UrlAcl.Delete(httpsNew)); this.registryProvider.HttpsAcl = httpsNew; rollbackActions.Add(() => this.registryProvider.HttpsAcl = httpsOld); }
public static IWebHostBuilder UseHttpSys(this IWebHostBuilder builder, IConfiguration config) { if (config.GetValueOrDefault("hosting:environment", HostingEnvironment.HttpSys) == HostingEnvironment.HttpSys) { HttpSysHostingOptions p = new HttpSysHostingOptions(); config.Bind("Hosting:HttpSys", p); builder.UseHttpSys(options => { var mode = config.GetValueOrDefault("Authentication:Mode", AuthenticationMode.Iwa); if (mode == AuthenticationMode.Iwa) { options.Authentication.Schemes = config.GetValueOrDefault("Authentication:Iwa:AuthenticationSchemes", HttpSys.AuthenticationSchemes.Negotiate); options.Authentication.AllowAnonymous = false; options.ClientCertificateMethod = HttpSys.ClientCertificateMethod.NoCertificate; } else if (mode == AuthenticationMode.Certificate) { options.Authentication.AllowAnonymous = true; options.Authentication.Schemes = HttpSys.AuthenticationSchemes.None; options.ClientCertificateMethod = HttpSys.ClientCertificateMethod.AllowCertificate; } else { options.Authentication.AllowAnonymous = true; options.Authentication.Schemes = HttpSys.AuthenticationSchemes.None; options.ClientCertificateMethod = HttpSys.ClientCertificateMethod.NoCertificate; } options.AllowSynchronousIO = p.AllowSynchronousIO; options.EnableResponseCaching = p.EnableResponseCaching; options.Http503Verbosity = (HttpSys.Http503VerbosityLevel)p.Http503Verbosity; options.MaxAccepts = p.MaxAccepts; options.MaxConnections = p.MaxConnections; options.MaxRequestBodySize = p.MaxRequestBodySize; options.RequestQueueLimit = p.RequestQueueLimit; options.ThrowWriteExceptions = p.ThrowWriteExceptions; options.UrlPrefixes.Clear(); options.UrlPrefixes.Add(p.BuildHttpUrlPrefix()); options.UrlPrefixes.Add(p.BuildHttpsUrlPrefix()); }); } return(builder); }