-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")
+if node[:exim][:certificate_names]
+ include_recipe "apache"
+
+ apache_site node[:exim][:certificate_names].first do
+ template "apache.erb"
+ variables :aliases => node[:exim][:certificate_names].drop(1)
+ end
+
+ ssl_certificate node[:exim][:certificate_names].first do
+ domains node[:exim][:certificate_names]
+ notifies :restart, "service[exim4]"
+ end
+else
+ openssl_x509_certificate "/etc/ssl/certs/exim.pem" do
+ key_file "/etc/ssl/private/exim.key"
+ owner "root"
+ group "ssl-cert"
+ mode 0o640
+ org "OpenStreetMap"
+ email "postmaster@openstreetmap.org"
+ common_name node[:fqdn]
+ expire 3650
+ notifies :restart, "service[exim4]"