public override void Aquire(ScheduledRenewal renewal, IOptionsService optionsService, IInputService inputService, RunLevel runLevel)
 {
     inputService.Show("Full instructions", "https://github.com/Lone-Coder/letsencrypt-win-simple/wiki/Install-Script");
     do
     {
         renewal.Script = optionsService.TryGetOption(optionsService.Options.Script, inputService, "Enter the path to the script that you want to run after renewal");
     }while (!renewal.Script.ValidFile(_log));
     inputService.Show("{0}", "Hostname");
     inputService.Show("{1}", ".pfx password");
     inputService.Show("{2}", ".pfx path");
     inputService.Show("{3}", "Certificate store name");
     inputService.Show("{4}", "Certificate friendly name");
     inputService.Show("{5}", "Certificate thumbprint");
     inputService.Show("{6}", "Central SSL store path");
     renewal.ScriptParameters = optionsService.TryGetOption(optionsService.Options.ScriptParameters, inputService, "Enter the parameter format string for the script, e.g. \"--hostname {0}\"");
 }
Exemplo n.º 2
0
        public override void Aquire(ScheduledRenewal renewal, IOptionsService optionsService, IInputService inputService, RunLevel runLevel)
        {
            if (renewal.Binding.IIS != true || runLevel < RunLevel.Advanced || !inputService.PromptYesNo("Use different site for installation?"))
            {
                return;
            }
            var chosen = inputService.ChooseFromList("Choose site to create new bindings",
                                                     _iisClient.WebSites,
                                                     x => new Choice <long>(x.Id)
            {
                Description = x.Name, Command = x.Id.ToString()
            },
                                                     false);

            renewal.Binding.InstallationSiteId = chosen;
        }
Exemplo n.º 3
0
 public SelfHosting(ScheduledRenewal renewal, Target target, string identifier, ILogService log, IInputService input, ProxyService proxy) :
     base(log, input, proxy, renewal, target, identifier)
 {
     try
     {
         var prefix = $"http://+:{target.ValidationPort ?? 80}/.well-known/acme-challenge/";
         _files    = new Dictionary <string, string>();
         _listener = new HttpListener();
         _listener.Prefixes.Add(prefix);
         _listener.Start();
         _listeningTask = Task.Run(RecieveRequests);
     }
     catch
     {
         _log.Error("Unable to activate HttpListener, this may be due to non-Microsoft webserver using port 80");
         throw;
     }
 }
        private ScheduledRenewal Load(string renewal, string path)
        {
            var result = JsonConvert.DeserializeObject <ScheduledRenewal>(renewal);

            if (result == null || result.Binding == null)
            {
                _log.Error("Unable to deserialize renewal {renewal}", renewal);
                return(null);
            }

            if (result.History == null)
            {
                result.History = new List <RenewResult>();
                var historyFile = ScheduledRenewal.HistoryFile(result.Binding, path);
                if (historyFile.Exists)
                {
                    try
                    {
                        result.History = JsonConvert.DeserializeObject <List <RenewResult> >(File.ReadAllText(historyFile.FullName));
                    }
                    catch
                    {
                        _log.Warning("Unable to read history file {path}", historyFile.Name);
                    }
                }
            }

            if (result.Binding.AlternativeNames == null)
            {
                result.Binding.AlternativeNames = new List <string>();
            }

            if (result.Binding.HostIsDns == null)
            {
                result.Binding.HostIsDns = !result.San;
            }

            if (result.Binding.IIS == null)
            {
                result.Binding.IIS = !(result.Binding.PluginName == ScriptClient.PluginName);
            }
            return(result);
        }
Exemplo n.º 5
0
        public override void Aquire(ScheduledRenewal renewal, IOptionsService optionsService, IInputService inputService)
        {
            var ask = true;

            if (renewal.Binding.IIS == true)
            {
                ask = inputService.PromptYesNo("Use different site for installation?");
            }
            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;
            }
        }
Exemplo n.º 6
0
        public override void Default(ScheduledRenewal renewal, IOptionsService optionsService)
        {
            var siteId = optionsService.TryGetLong(nameof(optionsService.Options.FtpSiteId), optionsService.Options.FtpSiteId);

            if (siteId == null)
            {
                siteId = optionsService.TryGetLong(nameof(optionsService.Options.InstallationSiteId), optionsService.Options.InstallationSiteId);
            }
            if (siteId == null)
            {
                siteId = optionsService.TryGetLong(nameof(optionsService.Options.SiteId), optionsService.Options.SiteId);
            }
            if (siteId != null)
            {
                var site = _iisClient.GetFtpSite(siteId.Value); // Throws exception when not found
                renewal.Binding.InstallationSiteId = site.Id;
            }
            else
            {
                throw new Exception($"Missing parameter --{nameof(optionsService.Options.FtpSiteId).ToLower()}");
            }
        }
Exemplo n.º 7
0
 public override bool CanInstall(ScheduledRenewal renewal) => _iisClient.HasFtpSites;
Exemplo n.º 8
0
 public IIS(ScheduledRenewal renewal, Target target, IISClient iisClient, ILogService log, IInputService input, ProxyService proxy, string identifier) :
     base(renewal, target, iisClient, log, input, proxy, identifier)
 {
     _iisClient.PrepareSite(target);
 }
 public ScriptInstaller(ScheduledRenewal renewal, ILogService logService) : base(logService)
 {
     _renewal = renewal;
 }
Exemplo n.º 10
0
 public WebDav(ScheduledRenewal renewal, Target target, ILogService log, IInputService input, IOptionsService options, ProxyService proxy, string identifier) :
     base(log, input, proxy, renewal, target, identifier)
 {
     _webdavClient = new WebDavClient(target.HttpWebDavOptions, log);
 }
 public BaseHttpValidation(ILogService log, IInputService input, ProxyService proxy, ScheduledRenewal renewal, Target target, string identifier) :
     base(log, identifier)
 {
     _input   = input;
     _proxy   = proxy;
     _renewal = renewal;
     _target  = target;
 }
Exemplo n.º 12
0
 public override bool CanInstall(ScheduledRenewal renewal) => _iisClient.Version.Major > 0;
Exemplo n.º 13
0
 public override void RemoveCertificate(ScheduledRenewal renewal, CertificateInfo certificate)
 {
     _storePlugin.Delete(certificate);
     RemoveFromIIS(certificate);
 }
Exemplo n.º 14
0
 public virtual void Default(ScheduledRenewal renewal, IOptionsService optionsService)
 {
 }
Exemplo n.º 15
0
 /// <summary>
 /// Make certificate accessible for the world
 /// </summary>
 /// <param name="renewal"></param>
 /// <param name="certificateInfo"></param>
 public abstract void InstallCertificate(ScheduledRenewal renewal, CertificateInfo certificateInfo);
Exemplo n.º 16
0
 public virtual bool CanInstall(ScheduledRenewal renewal) => true;
Exemplo n.º 17
0
 public virtual void Aquire(ScheduledRenewal renewal, IOptionsService optionsService, IInputService inputService, RunLevel runLevel)
 {
 }
Exemplo n.º 18
0
 public UnattendedResolver(ScheduledRenewal renewal, ILogService log, PluginService pluginService)
 {
     _renewal = renewal;
     _log     = log;
     _plugins = pluginService;
 }
Exemplo n.º 19
0
 public IISFtpInstaller(ScheduledRenewal renewal, IISClient iisClient)
 {
     _iisClient = iisClient;
     _renewal   = renewal;
 }
Exemplo n.º 20
0
 /// <summary>
 /// Determine location and name of the history file
 /// </summary>
 /// <param name="target"></param>
 /// <param name="configPath"></param>
 /// <returns></returns>
 private FileInfo HistoryFile(ScheduledRenewal renewal, string configPath)
 {
     return(new FileInfo(Path.Combine(configPath, $"{renewal.Binding.Host}.history.json")));
 }
Exemplo n.º 21
0
 public BaseTlsValidation(ILogService logService, ScheduledRenewal renewal, string identifier) :
     base(logService, identifier)
 {
     _renewal = renewal;
 }
Exemplo n.º 22
0
 public override void InstallCertificate(ScheduledRenewal renewal, CertificateInfo certificate)
 {
     _storePlugin.Save(certificate);
     AddToIIS(certificate);
 }
Exemplo n.º 23
0
 /// <summary>
 /// Cleanup after validation
 /// </summary>
 /// <param name="renewal"></param>
 /// <param name="certificateInfo"></param>
 public abstract void RemoveCertificate(ScheduledRenewal renewal, CertificateInfo certificateInfo);
Exemplo n.º 24
0
 bool IInstallationPluginFactory.CanInstall(ScheduledRenewal renewal) => true;
Exemplo n.º 25
0
 public FileSystem(ScheduledRenewal renewal, Target target, IISClient iisClient, ILogService log, IInputService input, ProxyService proxy, string identifier) :
     base(log, input, proxy, renewal, target, identifier)
 {
     _iisClient = iisClient;
 }
Exemplo n.º 26
0
 void IInstallationPluginFactory.Aquire(ScheduledRenewal renewal, IOptionsService optionsService, IInputService inputService, RunLevel runLevel)
 {
 }
Exemplo n.º 27
0
 internal void Cancel(ScheduledRenewal renewal)
 {
     Renewals = Renewals.Except(new[] { renewal });
     _log.Warning("Renewal {target} cancelled", renewal);
 }
Exemplo n.º 28
0
 void IInstallationPluginFactory.Default(ScheduledRenewal renewal, IOptionsService optionsService)
 {
 }
Exemplo n.º 29
0
 public Ftp(ScheduledRenewal renewal, Target target, ILogService log, IInputService input, ProxyService proxy, string identifier) :
     base(log, input, proxy, renewal, target, identifier)
 {
     _ftpClient = new FtpClient(target.HttpFtpOptions, log);
 }
Exemplo n.º 30
0
        private ScheduledRenewal Load(string renewal, string path)
        {
            var result = JsonConvert.DeserializeObject <ScheduledRenewal>(renewal);

            if (result == null || result.Binding == null)
            {
                _log.Error("Unable to deserialize renewal {renewal}", renewal);
                return(null);
            }

            if (result.History == null)
            {
                result.History = new List <RenewResult>();
                var historyFile = ScheduledRenewal.HistoryFile(result.Binding, path);
                if (historyFile.Exists)
                {
                    try
                    {
                        result.History = JsonConvert.DeserializeObject <List <RenewResult> >(File.ReadAllText(historyFile.FullName));
                    }
                    catch
                    {
                        _log.Warning("Unable to read history file {path}", historyFile.Name);
                    }
                }
            }

            if (result.Binding.AlternativeNames == null)
            {
                result.Binding.AlternativeNames = new List <string>();
            }

            if (result.Binding.HostIsDns == null)
            {
                result.Binding.HostIsDns = !result.San;
            }

            if (result.Binding.IIS == null)
            {
                result.Binding.IIS = !(result.Binding.PluginName == ScriptClient.PluginName);
            }

            try
            {
                ITargetPlugin target = result.Binding.GetTargetPlugin();
                if (target != null)
                {
                    result.Binding = target.Refresh(Program.OptionsService, result.Binding);
                    if (result.Binding == null)
                    {
                        // No match, return nothing, effectively cancelling the renewal
                        _log.Error("Cancelling renewal");
                        return(null);
                    }
                }
                else
                {
                    _log.Error("TargetPlugin not found {PluginName} {TargetPluginName}", result.Binding.PluginName, result.Binding.TargetPluginName);
                    return(null);
                }
            }
            catch (Exception ex)
            {
                _log.Warning("Error refreshing renewal for {host} - {@ex}", result.Binding.Host, ex);
            }

            return(result);
        }