def authorize_for_domain(domain, options={})
      authorization = client.authorize(domain: domain)

      # Default challenge is via HTTP
      # but the developer can also use
      # a DNS TXT record to authorize.
      if options[:challenge] == :dns
        challenge = authorization.dns01

        unless options[:skip_puts]
          puts "===================================================================="
          puts "Record:"
          puts
          puts " - Name: #{challenge.record_name}.#{domain}"
          puts " - Type: #{challenge.record_type}"
          puts " - Value: #{challenge.record_content}"
          puts
          puts "Create the record; Wait a minute (or two); Request for verification!"
          puts "===================================================================="
        end

        # With this option the dns verification is
        # done automatically. LeSSL waits until a
        # valid record on your DNS servers was found
        # and requests a verification.
        #
        # CAUTION! This is a blocking the thread!
        if options[:automatic_verification]
          dns = begin
            if ns = options[:custom_nameservers]
              LeSSL::DNS.new(ns)
            else
              LeSSL::DNS.new
            end
          end

          puts
          puts 'Wait until the TXT record was set...'

          # Wait with verification until the
          # challenge record is valid.
          while dns.challenge_record_invalid?(domain, challenge.record_content)
            puts 'DNS record not valid' if options[:verbose]

            sleep(2) # Wait 2 seconds
          end

          puts 'Valid TXT record found. Continue with verification...'

          return request_verification(challenge)
        else
          return challenge
        end
      else
        challenge = authorization.http01

        file_name = Rails.root.join('public', challenge.filename)
        dir = File.dirname(Rails.root.join('public', challenge.filename))

        FileUtils.mkdir_p(dir)

        File.write(file_name, challenge.file_content)
        
        return challenge.verify_status
      end
    end
def authorize_for_domain(domain, options={})
      authorization = client.authorize(domain: domain)

      # Default challenge is via HTTP
      # but the developer can also use
      # a DNS TXT record to authorize.
      if options[:challenge] == :dns
        challenge = authorization.dns01

        unless options[:skip_puts]
          puts "===================================================================="
          puts "Record:"
          puts
          puts " - Name: #{challenge.record_name}.#{domain}"
          puts " - Type: #{challenge.record_type}"
          puts " - Value: #{challenge.record_content}"
          puts
          puts "Create the record; Wait a minute (or two); Request for verification!"
          puts "===================================================================="
        end

        # With this option the dns verification is
        # done automatically. LeSSL waits until a
        # valid record on your DNS servers was found
        # and requests a verification.
        #
        # CAUTION! This is a blocking the thread!
        if options[:automatic_verification]
          dns = begin
            if ns = options[:custom_nameservers]
              LeSSL::DNS.new(ns)
            else
              LeSSL::DNS.new
            end
          end

          puts
          puts 'Wait until the TXT record was set...'

          # Wait with verification until the
          # challenge record is valid.
          while dns.challenge_record_invalid?(domain, challenge.record_content)
            puts 'DNS record not valid' if options[:verbose]

            sleep(2) # Wait 2 seconds
          end

          puts 'Valid TXT record found. Continue with verification...'

          return request_verification(challenge)
        else
          return challenge
        end
      else
        challenge = authorization.http01

        file_name = Rails.root.join('public', challenge.filename)
        dir = File.dirname(Rails.root.join('public', challenge.filename))

        FileUtils.mkdir_p(dir)

        File.write(file_name, challenge.file_content)
        
        return challenge.verify_status
      end
    end
Authorize the client
 for a domain name.

 Challenge options:
  - HTTP (default and recommended)
  - DNS