# Generated by Chef

##
## SSL settings
##

# SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>
<%= DovecotCookbook::Conf.attribute(@conf, 'ssl', 'yes') %>

# PEM encoded X.509 SSL/TLS certificate and private key. They're opened before
# dropping root privileges, so keep the key file unreadable by anyone but
# root. Included doc/mkcert.sh can be used to easily generate self-signed
# certificate, just make sure to update the domains in dovecot-openssl.cnf
<% case node['platform_family']
    when 'rhel', 'fedora', 'suse'
      ssl_cert = '</etc/pki/dovecot/certs/dovecot.pem'
      ssl_key = '</etc/pki/dovecot/certs/dovecot.pem'
      ca_pem = '</etc/pki/dovecot/certs/ca.pem'
    # when 'debian'
    else
      ssl_cert = '</etc/ssl/certs/dovecot.pem'
      ssl_key = '</etc/ssl/private/dovecot.pem'
      ca_pem = '</etc/ssl/certs/ca.pem'
    end
-%>
<%= DovecotCookbook::Conf.attribute(@conf, 'ssl_cert', ssl_cert) %>
<%= DovecotCookbook::Conf.attribute(@conf, 'ssl_key', ssl_key) %>

# If key file is password protected, give the password here. Alternatively
# give it when starting dovecot with -p parameter. Since this file is often
# world-readable, you may want to place this setting instead to a different
# root owned 0600 file by using ssl_key_password = <path.
<%= DovecotCookbook::Conf.attribute(@conf, 'ssl_key_password') %>

# PEM encoded trusted certificate authority. Set this only if you intend to use
# ssl_verify_client_cert=yes. The file should contain the CA certificate(s)
# followed by the matching CRL(s). (e.g. ssl_ca = <%= ca_pem %>)
<%= DovecotCookbook::Conf.attribute(@conf, 'ssl_ca') %>

# Require that CRL check succeeds for client certificates.
<%= DovecotCookbook::Conf.attribute(@conf, 'ssl_require_crl', true) %>

# Directory and/or file for trusted SSL CA certificates. These are used only
# when Dovecot needs to act as an SSL client (e.g. imapc backend). The
# directory is usually /etc/ssl/certs in Debian-based systems and the file is
# /etc/pki/tls/cert.pem in RedHat-based systems.
<%= DovecotCookbook::Conf.attribute(@conf, 'ssl_client_ca_dir') %>
<%= DovecotCookbook::Conf.attribute(@conf, 'ssl_client_ca_file') %>

# Request client to send a certificate. If you also want to require it, set
# auth_ssl_require_client_cert=yes in auth section.
<%= DovecotCookbook::Conf.attribute(@conf, 'ssl_verify_client_cert', false) %>

# Which field from certificate to use for username. commonName and
# x500UniqueIdentifier are the usual choices. You'll also need to set
# auth_ssl_username_from_cert=yes.
<%= DovecotCookbook::Conf.attribute(@conf, 'ssl_cert_username_field', 'commonName') %>

# How often to regenerate the SSL parameters file. Generation is quite CPU
# intensive operation. The value is in hours, 0 disables regeneration
# entirely.
<%= DovecotCookbook::Conf.attribute(@conf, 'ssl_parameters_regenerate', 168) %>

# DH parameters length to use.
<%= DovecotCookbook::Conf.attribute(@conf, 'ssl_dh_parameters_length', 1024) %>

# SSL protocols to use
<%= DovecotCookbook::Conf.attribute(@conf, 'ssl_protocols', '!SSLv2') %>

# SSL ciphers to use
<%= DovecotCookbook::Conf.attribute(@conf, 'ssl_cipher_list', 'ALL:!LOW:!SSLv2:!EXP:!aNULL') %>

# Prefer the server's order of ciphers over client's.
<%= DovecotCookbook::Conf.attribute(@conf, 'ssl_prefer_server_ciphers', false) %>

# SSL crypto device to use, for valid values run "openssl engine"
<%= DovecotCookbook::Conf.attribute(@conf, 'ssl_crypto_device') %>

# SSL extra options. Currently supported options are:
#   no_compression - Disable compression.
<%= DovecotCookbook::Conf.attribute(@conf, 'ssl_options') %>
