diff --git a/lib/local_acme.rb b/lib/local_acme.rb index f4fe7a7..ddc7473 100644 --- a/lib/local_acme.rb +++ b/lib/local_acme.rb @@ -179,19 +179,21 @@ def search_gdns(domain) end def get_challenge_fqdn(domain) - is_wildcard = domain.index '*' - domain = get_domain_root(domain) unless is_wildcard.nil? + domain = domain.sub /^\*\./, '' "_acme-challenge.#{domain.sub(/\.$/, '')}" end def get_domain_root(domain) domain = domain.sub /^\*\./, '' - packet = @res.query("#{domain}", Net::DNS::ANY) + packet = @res.query("#{domain}", Net::DNS::SOA) if !packet.authority.first.nil? && packet.authority.first != '' - return packet.authority.first.name + packet.authority.first.name + elsif !packet.answer.first.nil? && !packet.answer.first.type.nil? && packet.answer.first.type.upcase.eql?("CNAME") + packet = @res.query("#{domain}", Net::DNS::CNAME) + packet.authority.first.name if !packet.authority.first.nil? && !packet.authority.first.name.empty? + else + raise "SOA AUTHORITY NOT FOUND (challenge_txt_fqdn #{domain})" end - - raise "SOA AUTHORITY NOT FOUND (challenge_txt_fqdn #{domain})" end def add_domain_with_records(domain)