Exemplo n.º 1
0
        /// <summary>
        /// Prepare to add a new DNS record
        /// </summary>
        /// <param name="context"></param>
        /// <param name="challenge"></param>
        /// <returns></returns>
        public override async Task PrepareChallenge(ValidationContext context, Dns01ChallengeValidationDetails challenge)
        {
            // Check for substitute domains
            var authority = await _dnsClient.GetAuthority(
                challenge.DnsRecordName,
                followCnames : _settings.Validation.AllowDnsSubstitution);

            var success = false;

            while (!success)
            {
                _log.Debug("[{identifier}] Attempting to create DNS record under {authority}...", context.Identifier, authority.Domain);
                var record = new DnsValidationRecord(context, authority, challenge.DnsRecordValue);
                success = await CreateRecord(record);

                if (!success)
                {
                    _log.Debug("[{identifier}] Failed to create record under {authority}", context.Identifier, authority.Domain);
                    if (authority.From == null)
                    {
                        throw new Exception($"[{context.Identifier}] Unable to prepare for challenge answer");
                    }
                    else
                    {
                        authority = authority.From;
                    }
                }
                else
                {
                    _log.Debug("[{identifier}] Record successfully created", context.Identifier, authority.Domain);
                    _recordsCreated.Add(record);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Prepare to add a new DNS record
        /// </summary>
        /// <param name="context"></param>
        /// <param name="challenge"></param>
        /// <returns></returns>
        public override async Task PrepareChallenge(ValidationContext context, Dns01ChallengeValidationDetails challenge)
        {
            // Check for substitute domains
            var authority = await _dnsClient.GetAuthority(
                challenge.DnsRecordName,
                followCnames : _settings.Validation.AllowDnsSubstitution);

            var success = false;

            while (!success)
            {
                var record = new DnsValidationRecord(context, authority, challenge.DnsRecordValue);
                success = await CreateRecord(record);

                if (!success)
                {
                    if (authority.From == null)
                    {
                        throw new Exception("Unable to prepare for challenge answer");
                    }
                    else
                    {
                        authority = authority.From;
                    }
                }
                else
                {
                    _recordsCreated.Add(record);
                }
            }
        }