Пример #1
0
        /// <summary>
        /// Parse unique DNS identifiers that the certificate should be
        /// created for, taking into account the list of exclusions,
        /// support for IDNs and the limits of Let's Encrypt
        /// </summary>
        /// <param name="unicode"></param>
        /// <returns></returns>
        public List <string> GetHosts(bool unicode, bool allowZero = false)
        {
            var hosts = new List <string>();

            if (HostIsDns == true)
            {
                hosts.Add(Host);
            }
            if (AlternativeNames != null && AlternativeNames.Any())
            {
                hosts.AddRange(AlternativeNames);
            }
            var exclude  = GetExcludedHosts();
            var filtered = hosts.
                           Where(x => !string.IsNullOrWhiteSpace(x)).
                           Distinct().
                           Except(exclude);

            if (unicode)
            {
                var idn = new IdnMapping();
                filtered = filtered.Select(x => idn.GetUnicode(x));
            }

            if (filtered.Count() == 0)
            {
                if (!allowZero)
                {
                    throw new Exception("No DNS identifiers found.");
                }
            }
            else if (filtered.Count() > Constants.maxNames)
            {
                throw new Exception($"Too many hosts for a single certificate. Let's Encrypt has a maximum of {Constants.maxNames}.");
            }
            return(filtered.ToList());
        }
Пример #2
0
 public string GetDescription()
 {
     return(string.Format("Set user with values - Name:{0}; Enabled: {1}; LocalLogonEnabled: {2}; HasAlternativeNames: {3}", Name, Enabled, LocalLogonEnabled, AlternativeNames.Any()));
 }