fix_nginx_dh()
{
echo "---> Fix SSL configuration for nginx web server..."
nginx_pool_d="/etc/nginx/plesk.conf.d"
vhost_cfg_default_d="$psa_d/admin/conf/templates/default"
vhost_cfg_custom_d="$psa_d/admin/conf/templates/custom"
ssl_cfg_list="
/etc/nginx/plesk.conf.d/webmail.conf
/etc/nginx/plesk.conf.d/server.conf
$psa_d/admin/conf/templates/default/nginxWebmailPartial.php
$psa_d/admin/conf/templates/default/domain/nginxDomainVirtualHost.php
$psa_d/admin/conf/templates/default/server/nginxVhosts.php
"
custom_cfg_list="
$vhost_cfg_custom_d/nginxWebmailPartial.php
$vhost_cfg_custom_d/domain/nginxDomainVirtualHost.php
$vhost_cfg_custom_d/server/nginxVhosts.php
"
flag=0
for dst_list in $custom_cfg_list; do
if [ -f $dst_list ]; then
do_backup $dst_list
fi
done
for cfg in $ssl_cfg_list; do
[ -f "$cfg" ] || continue
dst_cfg="$cfg"
if [ -n "`echo $cfg | grep $vhost_cfg_default_d`" ]; then
dst_cfg="`echo $cfg | sed -e \"s|$vhost_cfg_default_d|$vhost_cfg_custom_d|\"`"
mkdir -p ${dst_cfg%/*}
cp $cfg $dst_cfg
else
do_backup $dst_cfg
fi
exists="`cat $dst_cfg | grep 'ssl_dhparam'`"
if [ -n "$exists" ]; then
sed -i -e "s|^\([[:space:]]*\)\(ssl_dhparam.*\)$|\1ssl_dhparam ${dh_certfile};|" $dst_cfg
else
sed -i -e "s|^\([[:space:]]*\)\(ssl_protocols.*\)$|\1\2\n\1ssl_dhparam ${dh_certfile};|" $dst_cfg
fi
flag=1
done
[ $flag -eq 0 ] || $psa_d/admin/bin/httpdmng --reconfigure-all
case $os_name in
Debian*|Ubuntu*) service_cmd="/etc/init.d/nginx restart" ;;
*) service_cmd="service nginx restart" ;;
esac
service_restart "$service_cmd" "1"
}
fix_postfix_dh()
{
echo "---> Fix SSL configuration for postfix mail server..."
[ -f "/etc/postfix/main.cf" ] || return 0
do_backup /etc/postfix/main.cf
postconf smtpd_tls_mandatory_exclude_ciphers="aNULL, eNULL, EXPORT, DES, RC4, MD5, PSK, aECDH, EDH-DSS-DES-CBC3-SHA, EDH-RSA-DES-CDC3-SHA, KRB5-DE5, CBC3-SHA"
postconf smtpd_tls_dh1024_param_file="$dh_certfile"
case $os_name in
Debian*|Ubuntu*) service_restart "/etc/init.d/postfix restart" "1" ;;
*) service_restart "service postfix restart" "1" ;;
esac
}
fix_courier_dh()
{
echo "---> Fix SSL accessible protocols for courier-imap mail server"
cfg_list="/etc/courier-imap/imapd-ssl /etc/courier-imap/pop3d-ssl"
get_courier_version
flag=0
for cfg in $cfg_list; do
[ -f "$cfg" ] || continue
if [ "$courier_major_version" -ge 4 -a "$courier_minor_version" -ge 15 ]; then
do_backup $cfg
set_value "TLS_DHPARAMS" "${dh_certfile}" "=" "" $cfg
flag=1
fi
done
[ -f "/usr/sbin/mkdhparams" ] ||return 0
do_backup /usr/sbin/mkdhparams
sed -i s,BITS=768,BITS=2048,g /usr/sbin/mkdhparams
sed -i /"chmod 600"/d /usr/sbin/mkdhparams
case $os_name in
Debian*|Ubuntu*)
service_restart "/etc/init.d/courier-imaps restart" "$flag"
service_restart "/etc/init.d/courier-pop3s restart" "$flag"
service_restart "/etc/init.d/courier-imapd restart" "$flag"
;;
*)
service_restart "service courier-imaps restart" "$flag"
service_restart "service courier-pop3s restart" "$flag"
service_restart "service courier-imapd restart" "$flag"
;;
esac
}
fix_dovecot_dh()
{
which dovecot 1>/dev/null 2>&1 || return
echo "---> Fix SSL accessible protocols for dovecot mail server"
get_dovecot_version
#cfg_list="/etc/dovecot/conf.d/10-plesk-security.conf /etc/dovecot/conf.d/11-plesk-security-pci.conf"
cfg_list="/etc/dovecot/conf.d/10-plesk-security.conf"
flag=0
for cfg in $cfg_list; do
[ -f "$cfg" ] || continue
do_backup $cfg
flag=1
set_value "ssl_cipher_list" "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA" "=" " " $cfg
if [ "$dovecot_major_version" -ge "22" ]; then
if [ "$dovecot_minor_version" -ge "6" ]; then
set_value "ssl_prefer_server_ciphers" "yes" "=" " " $cfg
fi
if [ "$dovecot_minor_version" -ge "7" ]; then
set_value "ssl_dh_parameters_length" "2048" "=" " " $cfg
fi
fi
done
case $os_name in
Debian*|Ubuntu*) service_cmd="/etc/init.d/dovecot restart" ;;
*) service_cmd="service dovecot restart" ;;
esac
service_restart "$service_cmd" "$flag"
}
# Add new parameter in config file for proftp if openssl >= 1.0.1
get_openssl_version
if [ "$openssl_major_version" -ge 1 -a "$openssl_minor_version" -ge 0 -a "$openssl_revision_version" -ge 1 ]; then
fix_proftpd_dh()
{
echo "---> Fix SSLv3(DH) for FTP service"
cfg="/etc/proftpd.d/60-nosslv3.conf"
ciphers="ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA"
if [ -f "$cfg" ]; then
do_backup $cfg
fi
if [ ! -f "$cfg" ]; then
echo "<Global>" > $cfg
echo "<IfModule mod_tls.c>" >> $cfg
echo "TLSProtocol TLSv1 TLSv1.1 TLSv1.2" >> $cfg
echo "TLSCipherSuite $ciphers" >> $cfg
echo "TLSDHParamFile ${dh_certfile}" >> $cfg
echo "</IfModule>" >> $cfg
echo "</Global>" >> $cfg
return
fi
if grep -q "^[[:space:]]*TLSCipherSuite" $cfg; then
sed -i -e "s|^\([[:space:]]*\)\(TLSCipherSuite.*\)$|\1TLSCipherSuite ${ciphers}|" $cfg
else
sed -i -e "s|^\([[:space:]]*\)\(TLSProtocol.*\)$|\1\2\n\1TLSCipherSuite ${ciphers}|" $cfg
fi
if ! grep -q "^[[:space:]]*TLSDHParamFile" $cfg; then
sed -i -e "s|^\([[:space:]]*\)\(TLSProtocol.*\)$|\1\2\n\1TLSDHParamFile ${dh_certfile}|" $cfg
fi
}
fi