예제 #1
0
파일: Program.cs 프로젝트: timnboys/certify
        private static int Main(string[] args)
        {
            var p = new CertifyCLI();

            p.ShowVersion();

            if (!p.IsServiceAvailable().Result)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                System.Console.WriteLine("Certify SSL Manager service not started.");
                Console.ForegroundColor = ConsoleColor.White;
                return(-1);
            }

            Task.Run(async() =>
            {
                await p.LoadPreferences();
            });

            if (args.Length == 0)
            {
                p.ShowHelp();
                p.ShowACMEInfo();
            }
            else
            {
                p.ShowACMEInfo();

                if (args.Contains("renew", StringComparer.InvariantCultureIgnoreCase))
                {
                    // perform auto renew all
                    var renewalTask = p.PerformAutoRenew();
                    renewalTask.ConfigureAwait(true);
                    renewalTask.Wait();
                }

                if (args.Contains("list", StringComparer.InvariantCultureIgnoreCase))
                {
                    //list managed sites and status
                    p.ListManagedSites();
                }

                if (args.Contains("certdiag", StringComparer.InvariantCultureIgnoreCase))
                {
                    p.RunCertDiagnostics();
                }

                if (args.Contains("importcsv", StringComparer.InvariantCultureIgnoreCase))
                {
                    var importTask = p.ImportCSV(args);
                    importTask.ConfigureAwait(true);
                    importTask.Wait();
                }
            }

#if DEBUG
            Console.ReadKey();
#endif
            return(0);
        }
예제 #2
0
        const int MAX_CHALLENGE_SERVER_RUNTIME = 1000 * 60 * 30;  // Allow up to 30 mins of run time for the challenge server (normall run time is

        private static int Main(string[] args)
        {
            var p = new CertifyCLI();

            if (args.Length == 0)
            {
                p.ShowHelp();
                p.ShowACMEInfo();
            }
            else
            {
                if (args.Contains("storeserverconfig", StringComparer.InvariantCultureIgnoreCase))
                {
                    SharedUtils.ServiceConfigManager.StoreCurrentAppServiceConfig();
                    return(0);
                }

                if (args.Contains("httpchallenge", StringComparer.InvariantCultureIgnoreCase))
                {
                    return(StartHttpChallengeServer(args));
                }

                p.ShowVersion();

                if (!p.IsServiceAvailable().Result)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    System.Console.WriteLine("Certify SSL Manager service not started.");
                    Console.ForegroundColor = ConsoleColor.White;
                    return(-1);
                }

                Task.Run(async() =>
                {
                    await p.LoadPreferences();
                });

                p.ShowACMEInfo();

                if (args.Contains("renew", StringComparer.InvariantCultureIgnoreCase))
                {
                    // perform auto renew all
                    var renewalTask = p.PerformAutoRenew();
                    renewalTask.ConfigureAwait(true);
                    renewalTask.Wait();
                }

                if (args.Contains("list", StringComparer.InvariantCultureIgnoreCase))
                {
                    //list managed sites and status
                    p.ListManagedCertificates();
                }

                if (args.Contains("diag", StringComparer.InvariantCultureIgnoreCase))
                {
                    var autoFix         = false;
                    var forceAutoDeploy = false;

                    if (args.Contains("autofix"))
                    {
                        autoFix = true;
                    }

                    if (args.Contains("forceautodeploy"))
                    {
                        forceAutoDeploy = true;
                    }

                    p.RunCertDiagnostics(autoFix, forceAutoDeploy);
                }

                if (args.Contains("importcsv", StringComparer.InvariantCultureIgnoreCase))
                {
                    var importTask = p.ImportCSV(args);
                    importTask.ConfigureAwait(true);
                    importTask.Wait();
                }
            }
#if DEBUG
            System.Console.WriteLine("CLI: Completed (DEBUG)");
            Console.ReadKey();
#endif
            return(0);
        }
예제 #3
0
파일: Program.cs 프로젝트: shywel/certify
        const int MAX_CHALLENGE_SERVER_RUNTIME = 1000 * 60 * 30;  // Allow up to 30 mins of run time for the challenge server (normall run time is

        private static async Task <int> Main(string[] args)
        {
            var defaultFontColour = Console.ForegroundColor;

            var p = new CertifyCLI();

            if (args.Length == 0)
            {
                p.ShowHelp();
                p.ShowACMEInfo();
            }
            else
            {
                var command = "";

                if (args.Any())
                {
                    command = args[0].ToLower().Trim();
                }

                if (command == "storeserverconfig")
                {
                    SharedUtils.ServiceConfigManager.StoreCurrentAppServiceConfig();
                    return(0);
                }

                if (command == "httpchallenge")
                {
                    return(await StartHttpChallengeServer(args));
                }

                p.ShowVersion();

                if (!p.IsServiceAvailable().Result)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    System.Console.WriteLine("Certify SSL Manager service not started.");
                    Console.ForegroundColor = defaultFontColour;
                    return(-1);
                }

                await p.LoadPreferences();

                p.ShowACMEInfo();

                if (command == "renew")
                {
                    // perform auto renew all
                    await p.PerformAutoRenew(args);
                }

                if (command == "deploy")
                {
                    string managedCertId = null;
                    string taskId        = null;

                    if (args.Length >= 3)
                    {
                        // got command, cert and task name
                        managedCertId = args[1].Trim();
                        taskId        = args[2].Trim();
                    }
                    else if (args.Length == 2)
                    {
                        // got command and cert id, run all deployment tasks
                        managedCertId = args[1].Trim();
                    }
                    else
                    {
                        // incomplete args
                        Console.ForegroundColor = ConsoleColor.Red;
                        System.Console.WriteLine("Deploy: Missing arguments for Managed Certificate Name and Task Name");
                        Console.ForegroundColor = defaultFontColour;

                        p.ShowHelp();
                    }

                    if (managedCertId != null)
                    {
                        var result = await p.PerformDeployment(managedCertId, taskId);
                    }
                }

                if (command == "list")
                {
                    // list managed sites and status
                    p.ListManagedCertificates();
                }

                if (command == "diag")
                {
                    var autoFix         = false;
                    var forceAutoDeploy = false;

                    if (args.Contains("autofix"))
                    {
                        autoFix = true;
                    }

                    if (args.Contains("forceautodeploy"))
                    {
                        forceAutoDeploy = true;
                    }

                    await p.RunCertDiagnostics(autoFix, forceAutoDeploy);
                }

                if (command == "importcsv")
                {
                    await p.ImportCSV(args);
                }
            }
#if DEBUG
            System.Console.WriteLine("CLI: Completed (DEBUG)");
            Console.ReadKey();
#endif
            return(0);
        }