From 490c76468437e853cde8c58899dc87ca440074a8 Mon Sep 17 00:00:00 2001 From: Christoph Galuschka Date: Aug 10 2013 09:19:05 +0000 Subject: first version of postfix using STARTTLS test --- diff --git a/tests/p_postfix/50_postfix_tls.sh b/tests/p_postfix/50_postfix_tls.sh new file mode 100755 index 0000000..8e2add3 --- /dev/null +++ b/tests/p_postfix/50_postfix_tls.sh @@ -0,0 +1,174 @@ +y#!/bin/sh +# Author: Christoph Galuschka + +t_Log "Running $0 - Postfix plain SASL test." +t_Log "Installing prerequisits" + +t_InstallPackage openssl + +#creating backups of changed files +cp -a /etc/postfix/main.cf /etc/postfix/main.cf_testing +if [ $centos_ver = 5 ] + then + cp -a /etc/dovecot.conf /etc/dovecot.conf_testing +else + cp -a /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf_testing +fi + +#creating certificates +TESTDIR='/var/tmp/openssl-test' +mkdir $TESTDIR +t_Log "creating private key" +if [ $centos_ver = 6 ] + then + openssl genpkey -algorithm rsa -out $TESTDIR/server.key.secure -pkeyopt rsa_keygen_bits:2048 > /dev/null 2>&1 +else + openssl genrsa -passout pass:centos -des3 -rand file1:file2:file3:file4:file5 -out $TESTDIR/server.key.secure 2048 > /dev/null 2>&1 +fi +if [ $? == 1 ] + then t_Log "Creation of private key failed." + ret_val=1 + exit +fi + +#create default answer file +cat > $TESTDIR/openssl_answers< /dev/null 2>&1 +else + openssl rsa -passin pass:centos -in $TESTDIR/server.key.secure -out $TESTDIR/server.key > /dev/null 2>&1 +fi +if [ $? == 1 ] + then t_Log "Creation of server key failed." + ret_val=1 + exit +fi + +openssl req -batch -config $TESTDIR/openssl_answers -new -key $TESTDIR/server.key -out $TESTDIR/server.csr > /dev/null 2>&1 +if [ $? == 1 ] + then t_Log "Creation of CSR failed." + ret_val=1 + exit +fi + +t_Log "creating server certificate" +openssl x509 -req -days 3600 -in $TESTDIR/server.csr -signkey $TESTDIR/server.key -out $TESTDIR/server.crt > /dev/null 2>&1 +if [ $? == 1 ] + then t_Log "Creation of CRT failed." + ret_val=1 + exit +fi + +#copy files to destinations +cp -a $TESTDIR/server.crt /etc/pki/tls/certs/ +cp -a $TESTDIR/server.key /etc/pki/tls/private/ + +#adding parameters to postfix +cat >> /etc/postfix/main.cf < /etc/dovecot.conf <> /etc/dovecot/dovecot.conf <