#PRE-REQs: OpenSSL

cd /usr/src
tar zxvf stunnel-3.1.4.tar.gz
cd stunnel-3.14
./configure
make 
make install

#1. EDIT THE STUNNEL.CNF FILE PROVIDED
vi stunnel.cnf

#2. MAKE YOUR OWN STUNNEL CERTIFICATE SO THAT Outlook Express v5.5 SP2 and higher won't give errors.
/usr/local/ssl/bin/openssl req -new -x509 -days 3650 -nodes -out stunnel.pem -keyout stunnel.pem -config stunnel.cnf

#3 VISUALLY CONFIRM CERTIFICATE
/usr/local/ssl/bin/openssl x509 -subject -dates -fingerprint -noout -in stunnel.pem

#4 ALL CLIENTS USING WINDOWS SHOULD DOWNLOAD THIS CERTIFICATE (i.e. go to a web link and click on it).  
#  THEN CLICK OPEN AND THE CERTIFICATE MANAGER WILL RUN.  ACCEPT ALL DEFAULTS AND CLICK YES TO INSTALL.  
#  NO MORE ERRORS FROM OUTLOOK!

#5 FIX SECURITY ON PEM AND COPY TO PROPER LOCATION
chmod 600 stunnel.pem
cp /usr/src/stunnel-3.14/stunnel.pem /usr/local/ssl/certs


cp stunneld /etc/rc.d/init.d/


cd /etc/rc.d/rc3.d; ln -s ../init.d/stunneld S81stunneld
cd /etc/rc.d/rc0.d; ln -s ../init.d/stunneld K29stunneld

cp restartstunnel /etc/cron.hourly
