| 1 |
# http://www.stunnel.org/faq/certs.html |
| 2 |
|
| 3 |
# execute this as root! |
| 4 |
|
| 5 |
# Redhat+CentOS : yum install gcc make openssl-devel |
| 6 |
# |
| 7 |
# Debian+Ubuntu : apt-get install gcc make libssl-dev |
| 8 |
|
| 9 |
# check for fexsend |
| 10 |
openssl s_client -help 2>&1 |grep 'use TLS' |
| 11 |
|
| 12 |
mkdir -p /opt/src |
| 13 |
cd /opt/src/ |
| 14 |
|
| 15 |
STUNNEL=stunnel-5.53 |
| 16 |
wget https://ftp.nluug.nl/pub/networking/stunnel/archive/5.x/$STUNNEL.tar.gz |
| 17 |
tar xvf $STUNNEL.tar.gz |
| 18 |
cd $STUNNEL |
| 19 |
./configure --disable-fips --disable-libwrap --prefix=/opt/$STUNNEL |
| 20 |
make |
| 21 |
make install |
| 22 |
|
| 23 |
mkdir /home/fex/etc |
| 24 |
cd /home/fex/etc/ |
| 25 |
|
| 26 |
# create self-signed certificate |
| 27 |
# see http://www.infodrom.org/Debian/tips/stunnel.html |
| 28 |
openssl req -new -x509 -days 9999 -nodes -out stunnel.pem -keyout stunnel.pem |
| 29 |
dd if=/dev/urandom count=2 | openssl dhparam -rand - 1024 >> stunnel.pem |
| 30 |
openssl x509 -text -in stunnel.pem |
| 31 |
chmod 600 stunnel.pem |
| 32 |
|
| 33 |
cat <<EOD>stunnel.conf |
| 34 |
debug = warning |
| 35 |
output = /home/fex/spool/stunnel.log |
| 36 |
cert = /home/fex/etc/stunnel.pem |
| 37 |
;sslVersion = all |
| 38 |
sslVersionMin = TLSv1.2 |
| 39 |
fips = no |
| 40 |
TIMEOUTclose = 1 |
| 41 |
exec = /usr/bin/perl |
| 42 |
execargs = perl -T /home/fex/bin/fexsrv stunnel |
| 43 |
EOD |
| 44 |
|
| 45 |
## https://www.stunnel.org/pipermail/stunnel-users/2013-October/004414.html |
| 46 |
#case $(lsb_release -a 2>/dev/null) in |
| 47 |
# *CentOS*) echo 'fips = no' >>stunnel.conf;; |
| 48 |
#esac |
| 49 |
|
| 50 |
chown -R fex . |
| 51 |
|
| 52 |
cat <<EOD>/etc/xinetd.d/fexs |
| 53 |
# default: on |
| 54 |
# description: fex web server with SSL |
| 55 |
# note: only possible on port 443! |
| 56 |
service fexs |
| 57 |
{ |
| 58 |
socket_type = stream |
| 59 |
wait = no |
| 60 |
type = unlisted |
| 61 |
protocol = tcp |
| 62 |
port = 443 |
| 63 |
cps = 10 2 |
| 64 |
user = fex |
| 65 |
groups = yes |
| 66 |
server = /opt/$STUNNEL/bin/stunnel |
| 67 |
server_args = /home/fex/etc/stunnel.conf |
| 68 |
nice = 0 |
| 69 |
disable = no |
| 70 |
} |
| 71 |
EOD |
| 72 |
|
| 73 |
/etc/init.d/xinetd restart |
| 74 |
echo 'To enforce https, add to fex.ph:' |
| 75 |
echo '$force_https = 1;' |
| 76 |
|
| 77 |
# Hint: on some systems stunnel works not well with xinetd |
| 78 |
# you can also run stunnel without xinetd, in server daemon mode |