#!/bin/sh ## ## gencert.sh -- Create self-signed test certificate ## Christian Zoffoli ## Version 0.2 - 20010501 ## ## ### external tools openssl="/usr/bin/openssl" ### some optional terminal sequences case $TERM in xterm|xterm*|vt220|vt220*) T_MD=`echo dummy | awk '{ printf("%c%c%c%c", 27, 91, 49, 109); }'` T_ME=`echo dummy | awk '{ printf("%c%c%c", 27, 91, 109); }'` ;; vt100|vt100*) T_MD=`echo dummy | awk '{ printf("%c%c%c%c%c%c", 27, 91, 49, 109, 0, 0); }'` T_ME=`echo dummy | awk '{ printf("%c%c%c%c%c", 27, 91, 109, 0, 0); }'` ;; default) T_MD='' T_ME='' ;; esac # find some random files # (do not use /dev/random here, because this device # doesn't work as expected on all platforms) randfiles='' for file in /var/log/messages /var/adm/messages \ /kernel /vmunix /vmlinuz \ /etc/hosts /etc/resolv.conf; do if [ -f $file ]; then if [ ".$randfiles" = . ]; then randfiles="$file" else randfiles="${randfiles}:$file" fi fi done echo "" echo "${T_MD}" echo "----------------------------------------------------------------------" echo "Create self-signed test certificate" echo "" echo "Christian Zoffoli " echo "Version 0.2 - 20010501" echo "" echo "" echo "______________________________________________________________________${T_ME}" echo "" echo "" if [ ! -e ./ldap.pem ];then echo "Will create ldap.pem in `pwd`" else echo "ldap.pem already exist, dying" exit fi mkdir -p /tmp/tmpssl-$$ pushd /tmp/tmpssl-$$ > /dev/null echo "" echo "" echo "${T_MD}Generating Certificate " echo "______________________________________________________________________${T_ME}" echo "" COMMONNAME=`hostname` if [ ! -n "$COMMONNAME" ] then COMMONNAME="www.openldap.org" fi #. /etc/sysconfig/i18n if [ -n "$COUNTRY" ] then COUNTRY=`echo $LANG | sed -e "s/.*_//;s/@.*//;s/\..*//;s/_.*//" |tr a-z A-Z` else COUNTRY="US" fi cat >.cfg <&2 exit 1 fi popd >/dev/null rm -f /tmp/tmpssl-$$/*.csr rm -f /tmp/tmpssl-$$/ca.* chmod 400 /tmp/tmpssl-$$/* echo "Certificate creation done!" cp /tmp/tmpssl-$$/ldap.* . chown ldap:ldap ldap.* rm -rf /tmp/tmpssl-$$