Ejemplo n.º 1
0
        private void Execute()
        {
            Log.Initialize(_options);

            // no valid cert installed, no valid cert on disk => Authorize a new certificate
            // no valid cert installed, valid cert on disk => install current certificate
            // valid cert installed, less then 60 days old => no action
            // valid cert installed, more then 60 days old => Authorize a new certificate

            CertificateStatus status = _acmeCertificateService.IsCurrentCertificateValid();

            try
            {
                //--renew is more important than --installonly
                if ((!_options.InstallOnly || _options.Renew) && status != CertificateStatus.OK)
                {
                    _acmeClient.Initialize();
                    _acmeCertificateService.RetrieveNewCertificate();
                }
            }
            catch (Exception e)
            {
                Log.Error(e.ToString());
            }
            finally
            {
                if (!_options.DoNotBlockHttp)
                {
                    _firewallService.BlockHttpPort();
                }
            }

            _certificateStoreService.InstallCertificate(status);

            if (!_options.Renew)
            {
                _renewalService.ScheduleRenewTask();
            }
        }