Exemple #1
0
        internal void ListManagedCertificates()
        {
            var managedCertificates = _certifyClient.GetManagedCertificates(new ManagedCertificateFilter()).Result;

            foreach (var site in managedCertificates)
            {
                Console.ForegroundColor = ConsoleColor.White;

                Console.WriteLine($"{site.Name},{site.DateExpiry}");
            }
        }
Exemple #2
0
        /// <summary>
        /// Load initial settings including preferences, list of managed sites, primary contact
        /// </summary>
        /// <returns></returns>
        public async virtual Task LoadSettingsAsync()
        {
            this.Preferences = await CertifyClient.GetPreferences();

            List <ManagedCertificate> list = await CertifyClient.GetManagedCertificates(new Models.ManagedCertificateFilter());

            foreach (var i in list)
            {
                i.IsChanged = false;
            }

            ManagedCertificates = new System.Collections.ObjectModel.ObservableCollection <Models.ManagedCertificate>(list);

            PrimaryContactEmail = await CertifyClient.GetPrimaryContact();

            await RefreshChallengeAPIList();

            await RefreshStoredCredentialsList();
        }
Exemple #3
0
        internal void ListManagedCertificates(string[] args)
        {
            var managedCertificates = _certifyClient.GetManagedCertificates(new ManagedCertificateFilter()).Result;

            // check for path argument and if present output json file
            var jsonArgIndex = Array.IndexOf(args, "--json");

            if (jsonArgIndex != -1)
            {
                // if we have a file argument, go ahead an export the list
                if (args.Length > (jsonArgIndex + 1))
                {
                    var pathArg = args[jsonArgIndex + 1];

                    try
                    {
                        var jsonOutput = JsonConvert.SerializeObject(managedCertificates, Formatting.Indented);

                        System.IO.File.WriteAllText(pathArg, jsonOutput);
                    }
                    catch (Exception)
                    {
                        Console.WriteLine($"Failed to write output to file. Check folder exists and permissions allow write. " + pathArg);
                    }
                }
                else
                {
                    Console.WriteLine($"Output file path argument is required for json output.");
                }
            }
            else
            {
                // output list to console
                foreach (var site in managedCertificates)
                {
                    Console.ForegroundColor = ConsoleColor.White;

                    Console.WriteLine($"{site.Name},{site.DateExpiry}");
                }
            }
        }
Exemple #4
0
        public async Task <List <ActionStep> > PerformDeployment(string managedCertificateId, string taskId = null, bool isPreview = false)
        {
            var managedCertificates = await _client.GetManagedCertificates(new ManagedCertificateFilter { Id = managedCertificateId });

            if (managedCertificates.Count == 1)
            {
                var managedCert = managedCertificates.Single();

                if (!string.IsNullOrEmpty(taskId))
                {
                    // identify specific task
                    var task = managedCert.PostRequestTasks.FirstOrDefault(t => t.Id.ToLowerInvariant().Trim() == taskId.ToLowerInvariant().Trim());

                    if (task != null)
                    {
                        return(await _client.PerformDeployment(managedCert.Id, task.Id, isPreviewOnly : false));
                    }
                    else
                    {
                        // no match, nothing to do
                        return(new List <ActionStep> {
                        });
                    }
                }
                else
                {
                    // perform all deployment tasks
                    return(await _client.PerformDeployment(managedCert.Id, null, isPreviewOnly : false));
                }
            }
            else
            {
                // no matches
                return(new List <ActionStep> {
                    new ActionStep {
                        HasError = true, Description = "Managed Certificate not found for given Id. Deployment failed."
                    }
                });
            }
        }
        /// <summary>
        /// Load initial settings including preferences, list of managed sites, primary contact
        /// </summary>
        /// <returns></returns>
        public async virtual Task LoadSettingsAsync()
        {
            this.Preferences = await CertifyClient.GetPreferences();

            List <ManagedCertificate> list = await CertifyClient.GetManagedCertificates(new Models.ManagedCertificateFilter());

            foreach (var i in list)
            {
                i.IsChanged = false;

                if (HasDeprecatedChallengeTypes == false && i.RequestConfig.Challenges.Any(c => c.ChallengeType == SupportedChallengeTypes.CHALLENGE_TYPE_SNI))
                {
                    HasDeprecatedChallengeTypes = true;
                }
            }

            ManagedCertificates = new System.Collections.ObjectModel.ObservableCollection <Models.ManagedCertificate>(list);

            PrimaryContactEmail = await CertifyClient.GetPrimaryContact();

            await RefreshChallengeAPIList();

            await RefreshStoredCredentialsList();
        }