add semicolon to DKIM record data (#825)

* add semicolon to dkim record data

Addresses https://github.com/atech/postal/issues/812

As the semicolon at the end of a DKIM record is optional, some DNS software removes it.
The above change sanitizes the DKIM record before it gets checked

* fixed method typo

fixed a typo caused by my US spelling checker

* typo fix v2

a proper fix for the typo
This commit is contained in:
Morne Lotze
2019-06-11 10:41:39 +01:00
committed by Charlie Smurthwaite
parent 0fb323af3f
commit 7ca7b43fda
+5 -1
View File
@@ -69,6 +69,10 @@ class Domain
# DKIM
#
def sanitised_dkim_record
return records.first.strip.ends_with?(';') ? records.first.strip : "#{records.first.strip};"
end
def check_dkim_record
domain = "#{dkim_record_name}.#{name}"
result = resolver.getresources(domain, Resolv::DNS::Resource::IN::TXT)
@@ -80,7 +84,7 @@ class Domain
if records.size > 1
self.dkim_status = 'Invalid'
self.dkim_error = "There are #{records.size} records for at #{domain}. There should only be one."
elsif records.first.strip != self.dkim_record
elsif sanitised_dkim_record != self.dkim_record
self.dkim_status = 'Invalid'
self.dkim_error = "The DKIM record at #{domain} does not match the record we have provided. Please check it has been copied correctly."
else