zEitEr
Super Moderator
HOW TO CREATE INDIVIDUAL Diffie-Hellman (DH) keys FOR EVERY DOMAIN
Logjam Attack discussion http://forum.directadmin.com/showthread.php?t=51449
As a temp solution you may use this guide for NGINX+APACHE, NGINX:
1. Create an executable file
	
	
	
		
2. Put the following content into it
	
	
	
		
run the script /root/create_ssl_dhparam_all.sh
That will take time to create all the keys.
3. Update nginx templates
	
	
	
		
4. Add the lines
	
	
	
		
right after ssl_certificate_key to the both templates.
Save. Here we add a PHP check whether or not DH key exists.
5. Update nginx.conf
	
	
	
		
				
			UNLESS YOU KNOW WHAT YOU DO PLEASE DO NOT FOLLOW THIS HOW-TO
THE HOW-TO IS INCOMPLETE AS OF YET! IT DOES NOT CREATE KEYS FOR NEWLY ADDED DOMAINS
WHICH MIGHT BE ADDED AFTER YOU APPLIED THIS SOLUTION! YOU NEED USE POST SCRIPTS!
FOLLOW POST #3 FOR AN EASY WAY TO SOLVE AN ISSUE WITH LOGJAM ATTACK!
THE HOW-TO IS INCOMPLETE AS OF YET! IT DOES NOT CREATE KEYS FOR NEWLY ADDED DOMAINS
WHICH MIGHT BE ADDED AFTER YOU APPLIED THIS SOLUTION! YOU NEED USE POST SCRIPTS!
FOLLOW POST #3 FOR AN EASY WAY TO SOLVE AN ISSUE WITH LOGJAM ATTACK!
Logjam Attack discussion http://forum.directadmin.com/showthread.php?t=51449
As a temp solution you may use this guide for NGINX+APACHE, NGINX:
1. Create an executable file
		Code:
	
	touch /root/create_ssl_dhparam_all.sh
chmod 700 /root/create_ssl_dhparam_all.sh2. Put the following content into it
		Code:
	
	#!/bin/bash##
## Diffie-Hellman (DH) key creator for Directadmin, version 0.3
## by Alex S Grebenschikov (www.plugins-da.net)
##
#----------------------------------------------------------------------
# Created at: Thu May 21 14:25:00 NOVT 2015
# Last modified: Thu May 21 14:25:00 NOVT 2015
#----------------------------------------------------------------------
# Configure section:
#----------------------------------------------------------------------
#
# main()
OPENSSL_CMD=`which openssl`
for user in `ls -1 /usr/local/directadmin/data/users`;
do
    echo "[`date`] + Started with user ${user}";
    for domain in `cat /usr/local/directadmin/data/users/${user}/domains.list`;
    do
    {
        echo "[`date`] + + Started with domain ${domain} of user ${user}";
        ssl=`grep ^ssl= /usr/local/directadmin/data/users/${user}/domains/${domain}.conf | cut -d\= -f2`
        creator=`grep ^creator= /usr/local/directadmin/data/users/${user}/user.conf | cut -d\= -f2`
        suspended=`grep ^suspended= /usr/local/directadmin/data/users/${user}/domains/${domain}.conf | cut -d\= -f2`
        echo "[`date`] + + User's ${user} creator ${creator}";
        echo "[`date`] + + Domain ${domain} is suspended ${suspended}";
        if [ "${ssl}" == "OFF" ];
        then
        {
            echo "[`date`] + + - SSL support for domain ${domain} is disabled [OFF]";
        }
        else
        {
            echo "[`date`] + + + SSL support for domain ${domain} is enabled [ON]";
            dhf="/usr/local/directadmin/data/users/${user}/domains/${domain}.dh_pem";
            sdhf="/usr/local/directadmin/data/users/${creator}/domains/${domain}.dh_pem";
            if [ ! -f "${dhf}" ];
            then
            {
                echo "[`date`] + + + + File ${dhf} does not exist! Generating it..."
                ${OPENSSL_CMD} dhparam -out ${dhf} 2048;
                ln -s ${dhf} ${sdhf};
            }
            else
            {
                if [ "${suspended}" == "yes" ];
                then
                    if [ ! -f "${sdhf}" ];
                    then
                        echo "[`date`] + + + + Creating symlink ${sdhf}!";
                        ln -s ${dhf} ${sdhf};
                    else
                        echo "[`date`] + + + - Files ${dhf} and ${sdhf} exist! Skipping it...";
                    fi;
                else
                    echo "[`date`] + + + - File ${dhf} exists! Skipping it...";
                fi;
            }
            fi;
        }
        fi;
        echo "[`date`] + - Finished with domain ${domain} of user ${user}";
    }
    done;
    echo "[`date`] - Finished with user ${user}";
done;
exit 0;run the script /root/create_ssl_dhparam_all.sh
That will take time to create all the keys.
3. Update nginx templates
		Code:
	
	mkdir /usr/local/directadmin/data/templates/custom
cd /usr/local/directadmin/data/templates/custom
cp ../nginx_server_secure.conf .
cp ../nginx_server_secure_sub.conf .4. Add the lines
		Code:
	
	|$/usr/local/bin/php
<?php
    $dh_key="/usr/local/directadmin/data/users/|USER|/domains/|DOMAIN|.dh_pem";
    if (is_file($dh_key))
    {
        echo "ssl_dhparam $dh_key;";
    }
?>
DONE|right after ssl_certificate_key to the both templates.
Save. Here we add a PHP check whether or not DH key exists.
5. Update nginx.conf
		Code:
	
	cd /usr/local/directadmin/custombuild/
./build rewrite_confs
			
				Last edited: 
			
		
	
								
								
									
	
								
							
							 
 
		

 
 
		 Luckily the long time took only a few minutes
 Luckily the long time took only a few minutes 