Skip to content

Commit

Permalink
route53: Support multiple RR for the single name
Browse files Browse the repository at this point in the history
ACME server may need multiple authorizations for the single name. In
dns-01 challenge type, the expected workflow is to create multiple TXT
records.

Closes #31
  • Loading branch information
sorah committed May 19, 2018
1 parent 5845dba commit 25bde4f
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions lib/acmesmith/challenge_responders/route53.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ def request_changing_rrset(zone_and_batches, comment: nil)
puts " * #{zone_id}:"
change_batch.fetch(:changes).each do |b|
rrset = b.fetch(:resource_record_set)
puts " - #{b.fetch(:action)}: #{rrset.fetch(:name)} #{rrset.fetch(:ttl)} #{rrset.fetch(:type)} #{rrset.dig(:resource_records, 0, :value)}"
rrset.fetch(:resource_records).each do |rr|
puts " - #{b.fetch(:action)}: #{rrset.fetch(:name)} #{rrset.fetch(:ttl)} #{rrset.fetch(:type)} #{rr.fetch(:value)}"
end
end
print " ... "

Expand Down Expand Up @@ -98,14 +100,29 @@ def wait_for_sync(change_ids)
end

def change_batch_for_challenges(domain_and_challenges, comment: nil, action: 'UPSERT')
{
comment: "ACME challenge response #{comment}",
changes: domain_and_challenges.map do |d,c|
changes = domain_and_challenges
.map do |d, c|
rrset_for_challenge(d, c)
end
.group_by do |_|
# Reduce changes by name. ACME server may require multiple challenge responses for the same identifier
_.fetch(:name)
end
.map do |name, cs|
cs.inject { |result, change|
result.merge(resource_records: result.fetch(:resource_records, []) + change.fetch(:resource_records))
}
end
.map do |change|
{
action: action,
resource_record_set: rrset_for_challenge(d,c),
resource_record_set: change,
}
end,
end

{
comment: "ACME challenge response #{comment}",
changes: changes,
}
end

Expand Down

0 comments on commit 25bde4f

Please sign in to comment.