Stunnel for HTTPS and SMTPS Notes - Oliver-Mustoe/Oliver-Mustoe-Tech-Journal GitHub Wiki

In this page I detail how I setup Stunnel for HTTPS and SMTP.

Notes

First I installed Stunnel with the command:

  • sudo yum -y install Stunnel (NOTE: the -y is so I don't have to enter "yes" or "y" later)

Then I moved into Stunnel's directory with the command:

  • cd /etc/stunnel

Then I created the file "stunnel .conf" with the command:

  • sudo nano stunnel.conf

After that I edited "stunnel.conf" with the following information for https:
-[https]
-accept = 443
-connect = 127.0.0.1:80
-cert = /etc/stunnel/stunnel.pem

And then added the following information for smpts:
-[smtps]
-accept = 587
-connect = 127.0.0.1:25
-cert = /etc/stunnel/stunnel.pem

So altogether it looks like this:
-[https]
-accept = 443
-connect = 127.0.0.1:80
-cert = /etc/stunnel/stunnel.pem
-[smtps]
-accept = 587
-connect = 127.0.0.1:25
-cert = /etc/stunnel/stunnel.pem

Then I generated a key with the command:

  • sudo openssl genrsa -out key.pem 2048

Then I created a certificate for https with the command:

  • sudo openssl req -new -x509 -key key.pem -out cert.pem -days 1095
    It will then ask a series of questions which you should give appropriate answers for (NOTE: For "Common Name" field enter the FQDN of the server and for the "Email Address" field leave it blank.)

I would then enter the above command again, changing "cert.pem" to "cert2.pem" and entering the appropriate information for that system like the "Common Name".

I then added this information to the file "stunnel.pem" with the command:

  • cat key.pem cert.pem cert2.pem >> /etc/stunnel/stunnel.pem

Finally I ran the Stunnel with the command:

  • sudp stunnel stunnel.conf