Example #1
0
        public static void ScheduleRenewal(Target target)
        {
            if (!Options.NoTaskScheduler)
            {
                EnsureTaskScheduler();
            }

            var renewals = _settings.LoadRenewals();

            foreach (var existing in from r in renewals.ToArray() where r.Binding.Host == target.Host select r)
            {
                Log.Information("Removing existing scheduled renewal {existing}", existing);
                renewals.Remove(existing);
            }

            var result = new ScheduledRenewal()
            {
                Binding          = target,
                CentralSsl       = Options.CentralSslStore,
                San              = Options.San.ToString(),
                Date             = DateTime.UtcNow.AddDays(RenewalPeriod),
                KeepExisting     = Options.KeepExisting.ToString(),
                Script           = Options.Script,
                ScriptParameters = Options.ScriptParameters,
                Warmup           = Options.Warmup,
                AzureOptions     = AzureOptions.From(Options)
            };

            renewals.Add(result);
            _settings.SaveRenewals(renewals);

            Log.Information("Renewal Scheduled {result}", result);
        }
        public static void ScheduleRenewal(Target target)
        {
            EnsureTaskScheduler();

            var renewals = _settings.LoadRenewals();

            foreach (var existing in from r in renewals.ToArray() where r.Binding.Host == target.Host select r)
            {
                Console.WriteLine($" Removing existing scheduled renewal {existing}");
                Log.Information("Removing existing scheduled renewal {existing}", existing);
                renewals.Remove(existing);
            }

            var result = new ScheduledRenewal()
            {
                Binding      = target,
                CentralSsl   = Options.CentralSslStore,
                San          = Options.San.ToString(),
                Date         = DateTime.UtcNow.AddDays(RenewalPeriod),
                KeepExisting = Options.KeepExisting.ToString()
            };

            renewals.Add(result);
            _settings.SaveRenewals(renewals);

            Console.WriteLine($" Renewal Scheduled {result}");
            Log.Information("Renewal Scheduled {result}", result);
        }
 public static void GetRenewals()
 {
     try
     {
         var _settings = new Settings(Program.ClientName, Program.Options.BaseUri);
         var renewals  = _settings.LoadRenewals();
         Console.WriteLine();
         Console.WriteLine("Renewals:");
         var i = 0;
         foreach (var renewal in renewals.OrderBy(o => o.Binding.Host))
         {
             i++;
             var txt = ("  " + renewal.Binding.Host + (!String.IsNullOrEmpty(renewal.San) && renewal.San.ToLowerInvariant() == "true" ? " (SAN) " : " ")).PadRight(40);
             Console.WriteLine(txt + "Renewal date: " + renewal.Date.ToShortDateString());
             if (renewal.Binding.AlternativeNames != null && renewal.Binding.AlternativeNames.Any())
             {
                 foreach (var item in renewal.Binding.AlternativeNames)
                 {
                     Console.WriteLine("    - " + item);
                 }
             }
         }
         Console.WriteLine();
         Console.WriteLine("  " + i + " renewals in total");
     }
     catch (Exception ex)
     {
         Log.Error("Error encountered while loading renewals. Error: {@ex}", ex);
         throw new Exception(ex.Message);
     }
 }
Example #4
0
        public static void GetRenewals()
        {
            try
            {
                var _settings = new Settings(ClientName, Program.Options.BaseUri);
                var renewals  = _settings.LoadRenewals();
                Console.WriteLine();
                Console.WriteLine("Renewals:");
                var i = 0;
                foreach (var renewal in renewals.OrderBy(o => o.Binding.Host))
                {
                    i++;
                    var txt = ("  " + i + ": " + renewal.Binding.Host + (!String.IsNullOrEmpty(renewal.San) && renewal.San.ToLowerInvariant() == "true" ? " (SAN) " : " ")).PadRight(40);
                    Console.WriteLine(txt + "Renewal date: " + renewal.Date.ToShortDateString());
                    if (renewal.Binding.AlternativeNames != null && renewal.Binding.AlternativeNames.Any())
                    {
                        foreach (var item in renewal.Binding.AlternativeNames)
                        {
                            Console.WriteLine("    - " + item);
                        }
                    }
                }

                Console.WriteLine();
                Console.WriteLine("  Enter Id of Renewal to delete");
                var    selectedRenewal = Console.ReadLine();
                int    x;
                string selectedRenewalName = "";
                if (int.TryParse(selectedRenewal, out x))
                {
                    var renewalList = new List <ScheduledRenewal>();
                    var j           = 0;
                    foreach (var renewal in renewals.OrderBy(o => o.Binding.Host))
                    {
                        j++;
                        if (j != x)
                        {
                            renewalList.Add(renewal);
                        }
                        else
                        {
                            selectedRenewalName = renewal.Binding.Host + (!String.IsNullOrEmpty(renewal.San) && renewal.San.ToLowerInvariant() == "true" ? " (SAN) " : " ");
                        }
                    }

                    Console.WriteLine();
                    Console.WriteLine("  Are you sure you wan't to delete renewal: " + selectedRenewalName + "?");
                    if (Program.PromptYesNo())
                    {
                        _settings.SaveRenewals(renewalList);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("Error encountered while loading renewals. Error: {@ex}", ex);
                throw new Exception(ex.Message);
            }
        }
        const float renewalPeriod = 60; // can't easily make this a command line option since it would have to be saved

        public static void ScheduleRenewal(Target target)
        {
            EnsureTaskScheduler();

            var renewals = settings.LoadRenewals();

            foreach (var existing in from r in renewals.ToArray() where r.Binding.Host == target.Host select r)
            {
                Console.WriteLine($" Removing existing scheduled renewal {existing}");
                renewals.Remove(existing);
            }

            var result = new ScheduledRenewal()
            {
                Binding = target, Date = DateTime.UtcNow.AddDays(renewalPeriod)
            };

            renewals.Add(result);
            settings.SaveRenewals(renewals);

            Console.WriteLine($" Renewal Scheduled {result}");
        }