Tidying
This commit is contained in:
parent
986e04bd20
commit
6ef3b25862
|
@ -131,105 +131,105 @@ aDWQRvTrh5+SQAlDi0gcbNeImgAu1e44K8kZDab8Am5HlVjkR1Z36aqeMFDidlaU
|
||||||
'
|
'
|
||||||
|
|
||||||
function show_help {
|
function show_help {
|
||||||
echo ''
|
echo ''
|
||||||
echo $"${PROJECT_NAME}-dhparam -h [hostname] -l [length in bits] --recalc [yes|no] --fast [yes|no]"
|
echo $"${PROJECT_NAME}-dhparam -h [hostname] -l [length in bits] --recalc [yes|no] --fast [yes|no]"
|
||||||
echo ''
|
echo ''
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function calc_dh {
|
function calc_dh {
|
||||||
if [[ $FAST == 'yes' ]]; then
|
if [[ $FAST == 'yes' ]]; then
|
||||||
DHGROUP=$(( ( RANDOM % 4 ) + 14 ))
|
DHGROUP=$(( ( RANDOM % 4 ) + 14 ))
|
||||||
if [[ ${DHGROUP} == 14 ]]; then
|
if [[ ${DHGROUP} == 14 ]]; then
|
||||||
echo "$BETTERCRYPTO_GROUP14" > ${1}
|
echo "$BETTERCRYPTO_GROUP14" > ${1}
|
||||||
else
|
else
|
||||||
if [[ ${DHGROUP} == 15 ]]; then
|
if [[ ${DHGROUP} == 15 ]]; then
|
||||||
echo "$BETTERCRYPTO_GROUP15" > ${1}
|
echo "$BETTERCRYPTO_GROUP15" > ${1}
|
||||||
else
|
else
|
||||||
if [[ ${DHGROUP} == 16 ]]; then
|
if [[ ${DHGROUP} == 16 ]]; then
|
||||||
echo "$BETTERCRYPTO_GROUP16" > ${1}
|
echo "$BETTERCRYPTO_GROUP16" > ${1}
|
||||||
else
|
else
|
||||||
if [[ ${DHGROUP} == 17 ]]; then
|
if [[ ${DHGROUP} == 17 ]]; then
|
||||||
echo "$BETTERCRYPTO_GROUP17" > ${1}
|
echo "$BETTERCRYPTO_GROUP17" > ${1}
|
||||||
else
|
else
|
||||||
|
|
||||||
echo "$BETTERCRYPTO_GROUP18" > ${1}
|
echo "$BETTERCRYPTO_GROUP18" > ${1}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
openssl dhparam -check -text $KEYLENGTH -out ${1}
|
openssl dhparam -check -text $KEYLENGTH -out ${1}
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
exit 3674
|
exit 3674
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
chmod 640 ${1}
|
chmod 640 ${1}
|
||||||
}
|
}
|
||||||
|
|
||||||
function regenerate_dh_keys {
|
function regenerate_dh_keys {
|
||||||
for file in /etc/ssl/mycerts/*
|
for file in /etc/ssl/mycerts/*
|
||||||
do
|
do
|
||||||
if [[ -f $file ]]; then
|
if [[ -f $file ]]; then
|
||||||
filename=/etc/ssl/certs/$(echo $file | awk -F '/etc/ssl/mycerts/' '{print $2}' | awk -F '.crt' '{print $1}').dhparam
|
filename=/etc/ssl/certs/$(echo $file | awk -F '/etc/ssl/mycerts/' '{print $2}' | awk -F '.crt' '{print $1}').dhparam
|
||||||
if [ -f $filename ]; then
|
if [ -f $filename ]; then
|
||||||
calc_dh $filename
|
calc_dh $filename
|
||||||
echo $"Recalculated DH params for $filename"
|
echo $"Recalculated DH params for $filename"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
while [[ $# > 1 ]]
|
while [[ $# > 1 ]]
|
||||||
do
|
do
|
||||||
key="$1"
|
key="$1"
|
||||||
|
|
||||||
case $key in
|
case $key in
|
||||||
--help)
|
--help)
|
||||||
show_help
|
show_help
|
||||||
;;
|
;;
|
||||||
-h|--hostname)
|
-h|--hostname)
|
||||||
shift
|
shift
|
||||||
HOSTNAME="$1"
|
HOSTNAME="$1"
|
||||||
;;
|
;;
|
||||||
-l|--dhkey)
|
-l|--dhkey)
|
||||||
shift
|
shift
|
||||||
KEYLENGTH=${1}
|
KEYLENGTH=${1}
|
||||||
;;
|
;;
|
||||||
--recalc)
|
--recalc)
|
||||||
shift
|
shift
|
||||||
RECALCULATE=${1}
|
RECALCULATE=${1}
|
||||||
;;
|
;;
|
||||||
--fast)
|
--fast)
|
||||||
shift
|
shift
|
||||||
if [[ ${1} == $"yes" || ${1} == $"y" ]]; then
|
if [[ ${1} == $"yes" || ${1} == $"y" ]]; then
|
||||||
FAST='yes'
|
FAST='yes'
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
# unknown option
|
# unknown option
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ $RECALCULATE == "yes" || $RECALCULATE == "y" ]]; then
|
if [[ $RECALCULATE == "yes" || $RECALCULATE == "y" ]]; then
|
||||||
regenerate_dh_keys
|
regenerate_dh_keys
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! $HOSTNAME ]; then
|
if [ ! $HOSTNAME ]; then
|
||||||
echo $'No hostname specified'
|
echo $'No hostname specified'
|
||||||
exit 5728
|
exit 5728
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! which openssl > /dev/null ;then
|
if ! which openssl > /dev/null ;then
|
||||||
echo $"$0: openssl is not installed, exiting" 1>&2
|
echo $"$0: openssl is not installed, exiting" 1>&2
|
||||||
exit 5689
|
exit 5689
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d /etc/ssl/mycerts ]; then
|
if [ ! -d /etc/ssl/mycerts ]; then
|
||||||
mkdir -p /etc/ssl/mycerts
|
mkdir -p /etc/ssl/mycerts
|
||||||
fi
|
fi
|
||||||
|
|
||||||
calc_dh /etc/ssl/certs/$HOSTNAME.dhparam
|
calc_dh /etc/ssl/certs/$HOSTNAME.dhparam
|
||||||
|
|
Loading…
Reference in New Issue