From 900be9a12bfe74cfb4c96e00b892d350a18eb635 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 17 Oct 2013 18:46:34 +0100 Subject: [PATCH] Use self signed certificates for exim --- cookbooks/exim/metadata.rb | 1 - cookbooks/exim/recipes/default.rb | 14 +++++++++++--- cookbooks/exim/templates/default/exim4.conf.erb | 4 ++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/cookbooks/exim/metadata.rb b/cookbooks/exim/metadata.rb index 861ce0931..72a7a113f 100644 --- a/cookbooks/exim/metadata.rb +++ b/cookbooks/exim/metadata.rb @@ -5,7 +5,6 @@ description "Installs and configures exim" long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) version "1.0.0" depends "networking" -depends "ssl" attribute "exim", :display_name => "Exim", diff --git a/cookbooks/exim/recipes/default.rb b/cookbooks/exim/recipes/default.rb index b5b15080c..25ff1c1b8 100644 --- a/cookbooks/exim/recipes/default.rb +++ b/cookbooks/exim/recipes/default.rb @@ -18,9 +18,9 @@ # include_recipe "networking" -include_recipe "ssl" package "exim4" +package "openssl" if File.exist?("/var/run/clamav/clamd.ctl") package "exim4-daemon-heavy" @@ -32,11 +32,19 @@ group "ssl-cert" do append true end +execute "/etc/ssl/certs/exim.pem" do + command "openssl req -x509 -newkey rsa:2048 -keyout /etc/ssl/private/exim.key -out /etc/ssl/certs/exim.pem -days 3650 -nodes -subj='/O=OpenStreetMap/CN=#{node[:name]}'" + user "root" + group "ssl-cert" + not_if do + File.exists?("/etc/ssl/certs/exim.pem") && File.exists?("/etc/ssl/private/exim.key") + end +end + service "exim4" do action [ :enable, :start ] supports :status => true, :restart => true, :reload => true - subscribes :restart, resources(:cookbook_file => "/etc/ssl/certs/openstreetmap.pem") - subscribes :restart, resources(:file => "/etc/ssl/private/openstreetmap.key") + subscribes :restart, "execute[/etc/ssl/certs/exim.pem]" end relay_to_domains = node[:exim][:relay_to_domains] diff --git a/cookbooks/exim/templates/default/exim4.conf.erb b/cookbooks/exim/templates/default/exim4.conf.erb index c1a842c5b..81639bce4 100644 --- a/cookbooks/exim/templates/default/exim4.conf.erb +++ b/cookbooks/exim/templates/default/exim4.conf.erb @@ -152,8 +152,8 @@ tls_advertise_hosts = <; !127.0.0.1 ; !::1 # need the first setting, or in separate files, in which case you need both # options. -tls_certificate = /etc/ssl/certs/openstreetmap.pem -tls_privatekey = /etc/ssl/private/openstreetmap.key +tls_certificate = /etc/ssl/certs/exim.pem +tls_privatekey = /etc/ssl/private/exim.key # In order to support roaming users who wish to send email from anywhere, # you may want to make Exim listen on other ports as well as port 25, in -- 2.39.5