Exemplo n.º 1
0
        public static int Main(string[] args)
        {
            Log.PreInitialize();
            FixCosturaPath();

            Options options;

            if (!TryParseOptions(args, out options))
            {
                return(-1);
            }

            AcmeClientService       acmeClient              = new AcmeClientService(options);
            FirewallService         firewallService         = new FirewallService();
            IisService              iisService              = new IisService(options, firewallService);
            AcmeCertificateService  acmeCertificateService  = new AcmeCertificateService(options, acmeClient, iisService);
            RenewalService          renewalService          = new RenewalService(options);
            CertificateStoreService certificateStoreService = new CertificateStoreService(options, iisService);

            Program program = new Program(options, acmeClient, iisService, acmeCertificateService, renewalService, certificateStoreService, firewallService);

            program.Execute();

            return(0);
        }
Exemplo n.º 2
0
 private Program(Options options, AcmeClientService acmeClient, IisService iisService, AcmeCertificateService acmeCertificateService,
                 RenewalService renewalService, CertificateStoreService certificateStoreService, FirewallService firewallService)
 {
     _options                 = options;
     _acmeClient              = acmeClient;
     _iisService              = iisService;
     _acmeCertificateService  = acmeCertificateService;
     _renewalService          = renewalService;
     _certificateStoreService = certificateStoreService;
     _firewallService         = firewallService;
 }
Exemplo n.º 3
0
        private static void Main(string[] args)
        {
            RegisterServices();
            _log           = Container.Resolve <ILogService>();
            OptionsService = new OptionsService(_log, args);
            _options       = OptionsService.Options;
            if (_options == null)
            {
                return;
            }

            Plugins = new PluginService();
            ParseCentralSslStore();
            CreateConfigPath();

            // Basic services
            _settings = new Settings(_clientName, _configPath, _options.BaseUri);
            _input    = new InputService(_options, _log, _settings.HostsPerPage());

            // .NET Framework check
            if (!IsNET45)
            {
                _log.Error(".NET Framework 4.5 or higher is required for this app");
                return;
            }

            // Show version information
            _input.ShowBanner();

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

            do
            {
                try {
                    // Configure AcmeClient
                    var signer = new RS256Signer();
                    signer.Init();
                    _client = new AcmeClient(new Uri(_options.BaseUri), new AcmeServerDirectory(), signer);
                    ConfigureAcmeClient(_client);
                    _certificateService      = new CertificateService(_options, _log, _client, _configPath);
                    _certificateStoreService = new CertificateStoreService(_options, _log);
                    _centralSslService       = new CentralSslService(_options, _log, _certificateService);
                    _renewalService          = new RenewalService(_options, _log, _settings, _input, _clientName, _configPath);

                    if (_options.Renew)
                    {
                        CheckRenewals();
                        CloseDefault();
                    }
                    else if (!string.IsNullOrEmpty(_options.Plugin))
                    {
                        CreateNewCertificateUnattended();
                        CloseDefault();
                    }
                    else
                    {
                        MainMenu();
                    }
                }
                catch (Exception e)
                {
                    HandleException(e);
                    Environment.ExitCode = e.HResult;
                }
                if (!_options.CloseOnFinish)
                {
                    _options.Plugin       = null;
                    _options.Renew        = false;
                    _options.ForceRenewal = false;
                    Environment.ExitCode  = 0;
                }
            } while (!_options.CloseOnFinish);
        }