]> git.openstreetmap.org Git - chef.git/commitdiff
Add support for DKIM signing of outgoing mail
authorTom Hughes <tom@compton.nu>
Sun, 1 Mar 2020 15:55:40 +0000 (15:55 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 1 Mar 2020 16:14:17 +0000 (16:14 +0000)
cookbooks/exim/recipes/default.rb
cookbooks/exim/templates/default/dkim-selectors.erb [new file with mode: 0644]
cookbooks/exim/templates/default/exim4.conf.erb
roles/mail.rb

index e0fd75de3e84ce9f4f48a38894222aa87d183274..6af07c8e1114de61398c7ad5b56bf014d0495f08 100644 (file)
@@ -115,6 +115,32 @@ file "/etc/exim4/blocked-senders" do
   mode 0o644
 end
 
+if node[:exim][:dkim_selectors]
+  keys = data_bag_item("exim", "dkim")
+
+  template "/etc/exim4/dkim-selectors" do
+    owner "root"
+    source "dkim-selectors.erb"
+    group "Debian-exim"
+    mode 0o644
+  end
+
+  directory "/etc/exim4/dkim-keys" do
+    owner "root"
+    group "Debian-exim"
+    mode 0o755
+  end
+
+  node[:exim][:dkim_selectors].each do |domain, selector|
+    file "/etc/exim4/dkim-keys/#{domain}" do
+      content keys[domain].join("\n")
+      owner "root"
+      group "Debian-exim"
+      mode 0o640
+    end
+  end
+end
+
 template "/etc/exim4/exim4.conf" do
   source "exim4.conf.erb"
   owner "root"
diff --git a/cookbooks/exim/templates/default/dkim-selectors.erb b/cookbooks/exim/templates/default/dkim-selectors.erb
new file mode 100644 (file)
index 0000000..13078fa
--- /dev/null
@@ -0,0 +1,3 @@
+<% node[:exim][:dkim_selectors].each do |domain, selector| -%>
+<%= domain %>: <%= selector %>
+<% end -%>
index df725a8ae6a88312544c7e1291744a6443dc1629..ab832999d6d977aca5700efd6e7104380dd62121 100644 (file)
@@ -678,7 +678,7 @@ smarthost:
 dnslookup:
   driver = dnslookup
   domains = ! +local_domains
-  transport = remote_smtp
+  transport = signed_smtp
   same_domain_copy_routing = yes
   ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
   no_more
@@ -706,6 +706,19 @@ remote_smtp:
   tls_require_ciphers = <%= node[:ssl][:gnutls_ciphers] %>:%LATEST_RECORD_VERSION
 
 
+# This transport is used for delivering DKIM signed messages over SMTP connections.
+
+signed_smtp:
+  driver = smtp
+  dkim_domain = ${lc:${domain:$h_from:}}
+  dkim_selector = ${lookup{$dkim_domain}lsearch{/etc/exim4/dkim-selectors}{$value}}
+  dkim_private_key = /etc/exim4/dkim-keys/${dkim_domain}
+  dkim_identity = ${lc:${address:$h_from:}}
+  # dkim_timestamps = 1209600
+  multi_domain = false
+  tls_require_ciphers = <%= node[:ssl][:gnutls_ciphers] %>:%LATEST_RECORD_VERSION
+
+
 # This transport is used for handling pipe deliveries generated by alias or
 # .forward files. If the pipe generates any standard output, it is returned
 # to the sender of the message as a delivery error. Set return_fail_output
index 516c2b89e5184bc1e3acb712edeba73ea050b138..99fcf1a08fbc90d224f125c05a5e531eee90c529 100644 (file)
@@ -46,6 +46,9 @@ default_attributes(
         :host => "ridley.ucl.openstreetmap.org"
       }
     },
+    :dkim_selectors => {
+      "openstreetmap.org" => "20200301"
+    },
     :aliases => {
       "abuse" => "root",
       "postmaster" => "root",