public override void Aquire(ScheduledRenewal renewal, IOptionsService optionsService, IInputService inputService, RunLevel runLevel) { var ask = true; if (renewal.Binding.IIS == true) { if (runLevel == RunLevel.Advanced) { ask = inputService.PromptYesNo("Use different site for installation?"); } else { ask = false; } } if (ask) { var chosen = inputService.ChooseFromList("Choose site to create new bindings", _iisClient.RunningWebsites(), x => new Choice <long>(x.Id) { Description = x.Name, Command = x.Id.ToString() }, false); renewal.Binding.InstallationSiteId = chosen; } }
public override void Aquire(Target target, IOptionsService optionsService, IInputService inputService, RunLevel runLevel) { if (inputService.PromptYesNo("Use different site for validation?")) { target.ValidationSiteId = inputService.ChooseFromList("Validation site, must receive requests for all hosts on port 80", _iisClient.RunningWebsites(), x => new Choice <long>(x.Id) { Command = x.Id.ToString(), Description = x.Name }, true); } }
private List <Target> GetBindings(bool hideHttps, bool logInvalidSites) { if (_iisClient.ServerManager == null) { _log.Warning("IIS not found. Skipping scan."); return(new List <Target>()); } // Get all bindings matched together with their respective sites _log.Debug("Scanning IIS site bindings for hosts"); var siteBindings = _iisClient.RunningWebsites(). SelectMany(site => site.Bindings, (site, binding) => new { site, binding }). Where(sb => !string.IsNullOrWhiteSpace(sb.binding.Host)). Where(sb => !sb.binding.Host.StartsWith("*")); // Option: hide http bindings when there are already https equivalents var hidden = siteBindings.Take(0); if (hideHttps) { hidden = siteBindings. Where(sb => sb.binding.Protocol == "https" || sb.site.Bindings.Any(other => other.Protocol == "https" && string.Equals(sb.binding.Host, other.Host, StringComparison.InvariantCultureIgnoreCase))); } var targets = siteBindings. Select(sb => new { idn = _iisClient.IdnMapping.GetAscii(sb.binding.Host.ToLower()), sb.site, sb.binding, hidden = hidden.Contains(sb) }). Select(sbi => new Target { TargetSiteId = sbi.site.Id, Host = sbi.idn, HostIsDns = true, Hidden = sbi.hidden, IIS = true, WebRootPath = sbi.site.WebRoot() }). DistinctBy(t => t.Host). OrderBy(t => t.Host). ToList(); if (targets.Count() == 0 && logInvalidSites) { _log.Warning("No IIS bindings with host names were found. A host name is required to verify domain ownership."); } return(targets); }
public override void Aquire(Target target, IOptionsService optionsService, IInputService inputService, RunLevel runLevel) { // Choose alternative site for validation if (target.IIS == true && _iisClient.Version.Major > 0) { if (inputService.PromptYesNo("Use different site for validation?")) { var site = inputService.ChooseFromList("Validation site, must receive requests for all hosts on port 80", _iisClient.RunningWebsites(), x => new Choice <Site>(x) { Command = x.Id.ToString(), Description = x.Name }, true); if (site != null) { target.ValidationSiteId = site.Id; target.WebRootPath = site.WebRoot(); } } } base.Aquire(target, optionsService, inputService, runLevel); }
internal List <Target> GetSites(bool hideHttps, bool logInvalidSites) { if (_iisClient.ServerManager == null) { _log.Warning("IIS not found. Skipping scan."); return(new List <Target>()); } // Get all bindings matched together with their respective sites _log.Debug("Scanning IIS sites"); var sites = _iisClient.RunningWebsites(); // Option: hide http bindings when there are already https equivalents var hidden = sites.Take(0); if (hideHttps) { hidden = sites.Where(site => site.Bindings. All(binding => binding.Protocol == "https" || site.Bindings.Any(other => other.Protocol == "https" && string.Equals(other.Host, binding.Host, StringComparison.InvariantCultureIgnoreCase)))); } var targets = sites. Select(site => new Target { TargetSiteId = site.Id, Host = site.Name, HostIsDns = false, Hidden = hidden.Contains(site), WebRootPath = site.WebRoot(), IIS = true, AlternativeNames = GetHosts(site) }). Where(target => { if (target.AlternativeNames.Count > SettingsService.maxNames) { if (logInvalidSites) { _log.Information("{site} has too many hosts for a single certificate. Let's Encrypt has a maximum of {maxNames}.", target.Host, SettingsService.maxNames); } return(false); } else if (target.AlternativeNames.Count == 0) { if (logInvalidSites) { _log.Information("No valid hosts found for {site}.", target.Host); } return(false); } return(true); }). OrderBy(target => target.Host). ToList(); if (targets.Count() == 0 && logInvalidSites) { _log.Warning("No applicable IIS sites were found."); } return(targets); }