This page depreciated

This FAQ for stunnel is no longer being updated. Please go to the FAQ section on www.stunnel.org instead.






Using certificates with stunnel.

A full description of how certificates work is beyond the scope of this FAQ. Instead we'll explain how they work with stunnel itself.


Quick certificate overview.

Every stunnel server has a private key. This is contained in the pem file which stunnel uses to initialize it's identity. (PEM stands for 'privacy enhanced mail' which is now much more liberally used as a key format)

This private key is put in /usr/local/ssl/certs/stunnel.pem by default, however you should check the output of stunnel -h to verify. You can use a non-default keyfile if you wish by supplying the '-p' argument to stunnel.

An SSL server should also present a certificate. Stunnel generates self-signed certificates by default during the installation. It is possible to have your key signed by a third party (certificate authority) instead if you wish.


What's a certificate?

When an SSL client connects to an SSL server, the server presents a certificate, essentially an electronic piece of proof that machine is who it claims to be. This certificate is signed by a 'Certificate Authority' (hereafter a CA) -- usually a trusted third party like Verisign. A client will accept this certificate only if It is also possible for an SSL client to present a certificate, called a client certificate or peer certificate, although the methods for generating them are all the same.


Do I need a valid certificate?

Stunnel does need a pem file, regardless whether or not the data is used. You can simply use the one that comes with the distribution if you don't actually need to present this key.

If you are only using stunnel in client mode (ie it connects to an SSL server, it does not act as an SSL server) then you most likely do not need to present a valid certificate at all, and can skip this chapter entirely. Just use the pem that that comes with the distribution. It is most likely not asked for by the remote end, nor verified.

If you use stunnel in client mode and the remote SSL server does require client/peer certificates, then you do need one, and should read the instructions below.


Genererating the stunnel private key (pem).

The stunnel source comes with an stunnel.pem file. You can use this file if you wish. However it is not suggested. Everyone on the net has access to this pem file, thus everyone has access to this private data. The security of your SSL connection requires that no one else has access to this private data.

Let me repeat:


It is a bad idea to use the stunnel.pem file shipped with stunnel except for testing.

After testing out stunnel, you should generate your own key.

To do so, simply do a

	make cert

This will run the following commands:


Problems with a self-signed certificate.

Anyone can make a self-signed certificate. It is a totally valid SSL certificate. However most SSL clients (e.g. Netscape, IE) wish to verify the identity of the organization that signed the certificate. These SSL clients often have a hard-coded list of organizations (Certificate Authorities) that sign keys after doing background checks, etc.

Since the key and certificate you just generated are not in the hard-coded list that your SSL client uses, you will get either an error or warning message when attempting to connect to your stunnel daemon.


Do I need to have a Certificate Authority sign my key?

If you wish to interact with 3rd party clients (Netscape, IE, etc) that have hard coded lists of acceptable Certificate Authorities, and you do not want annoying dialog boxes popping up for the user on the first (or all) connections, then yes, you will have to have your key signed by a valid Certificate Authority.

If you have control of both the SSL client and the SSL server (say you are tunneling PPP from one location to another with stunnel at both ends) then you can either

neither of which requires getting your keys signed by a CA.


How can I have my key signed by a CA?

Create your private key manually as follows:
openssl req -new -days 365 -nodes \
	        -config stunnel.cnf -out certreq.pem -keyout stunnel.pem

This creates your RSA private key in stunnel.pem and your Certificate Request in certreq.pem. You must send this Certificate Request to the CA you wish to use, including whatever other information they may need.

After processing your information (and check) they will send you back a certificate which is of the form

-----BEGIN CERTIFICATE-----
certificate data here
-----END CERTIFICATE-----
Append this certificate to your stunnel.pem and you're good to go.


Can I set up my own CA instead?

Absolutely. Note that doing so is beyond the scope of this document, however.

Feel free to send the stunnel FAQ maintainer pointers to good web pages and they will be included here.

The important thing you must do is make sure that your CA certificate is available to the remote machine. If the remote machine is running stunnel, then that means including this CA certificate in one of the possible trusted certificate locations available. Details of this are below.


How does stunnel check certificates?

Stunnel has 3 methods for checking certificates, which are controlled by the '-v' option:


Where do I put all these certificates?

You can put trusted certificates in files and directories as follows (note that defaults can often be overridden by command line flags):



Useful web pages (not stunnel specific)


| Previous Section | | Table of contents | | Next Chapter |