To generate a self signed certificate, execute the following commands:

cd /usr/share/ssl/certs
openssl req -new -x509 -nodes -days 365 -out stunnel.pem -keyout stunnel.pem
ln -s stunnel.pem `openssl x509 -noout -hash < stunnel.pem`.0
chmod 644 stunnel.pem

If you need to delete the certificate later on, do

rm -f /usr/share/ssl/certs/`openssl x509 -noout -hash < /usr/share/ssl/certs/stunnel.pem`.0
rm -f /usr/share/ssl/certs/stunnel.pem

