Skip to content

Commit

Permalink
Small bug fixes
Browse files Browse the repository at this point in the history
- Fix root domain record (trailing period is now correctly removed)
- Initialize DNSimple client outside of loop for multiple subdomains script (was prev. throwing an error when clearing out the TXT records)
  • Loading branch information
alexpeattie committed Jan 9, 2017
1 parent c69b53d commit 65ae541
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion client.rb
Expand Up @@ -103,7 +103,7 @@ def upload(local_path, remote_path)
end

if preferred_challenge == 'dns-01'
record_name = '_acme-challenge.' + domain.sub(root_domain, '').chomp('.')
record_name = ('_acme-challenge.' + domain.sub(root_domain, '')).chomp('.')
challenge, challenge_response = dns_challenge, [dns_challenge['token'], thumbprint].join('.')
record_contents = base64_le(hash_algo.digest challenge_response)

Expand Down
5 changes: 3 additions & 2 deletions multiple_subdomains.rb
Expand Up @@ -80,6 +80,8 @@ def upload(local_path, remote_path)
})
end

dnsimple = Dnsimple::Client.new(username: ENV['DNSIMPLE_USERNAME'], api_token: ENV['DNSIMPLE_TOKEN'])

domains.each do |domain|
auth = signed_request(endpoints['new-authz'], {
resource: 'new-authz',
Expand All @@ -105,11 +107,10 @@ def upload(local_path, remote_path)
end

if preferred_challenge == 'dns-01'
record_name = "_acme-challenge." + domain.sub(root_domain, '').chomp('.')
record_name = ('_acme-challenge.' + domain.sub(root_domain, '')).chomp('.')
challenge, challenge_response = dns_challenge, [dns_challenge['token'], thumbprint].join('.')
record_contents = base64_le(hash_algo.digest challenge_response)

dnsimple = Dnsimple::Client.new(username: ENV['DNSIMPLE_USERNAME'], api_token: ENV['DNSIMPLE_TOKEN'])
challenge_record = dnsimple.domains.create_record(root_domain, record_type: 'TXT', name: record_name, content: record_contents, ttl: 60)

loop do
Expand Down

0 comments on commit 65ae541

Please sign in to comment.