.TH STUNNEL 8 "10 June 1999"
.SH NAME
stunnel \- universal SSL tunnel
.SH SYNOPSIS
.B stunnel
[-T] [-p pemfile] [-v level] [-a directory]
[-t timeout] [-u username] [-n protocol]
[-d [ip:]port [-f]] [ -l program | -r [ip:]port | -L program [-- args] ]
.PP
.B stunnel
{-c} [-p pemfile] [-v level] [-a directory]
[-t timeout] [-u username] [-n protocol]
-r [ip:]port [ -d [ip:]port [-f] | -l program | -L program [-- args] ]
.SH DESCRIPTION
The \fBstunnel\fR program is designed to work as \fISSL\fR encryption wrapper 
between remote clients and local (\fIinetd\fR-startable) or remote
servers. The concept is that having non-SSL aware daemons running on
your system you can easily set them up to communicate with clients over
secure SSL channels.
.PP
.B stunnel
can be used to add SSL functionality to commonly used \fIinetd\fR
daemons like POP-2, POP-3, and IMAP servers, to standalone daemons like
NNTP, SMTP and HTTP, and in tunneling PPP over network sockets without
changes to the source code.
.PP
This product includes cryptographic software written by
Eric Young (eay@cryptsoft.com)
.SH OPTIONS
.B -c
client mode (remote service uses SSL)
.RS
default: server mode
.RE
.PP
.B -T
transparent proxy mode (on hosts that support it)
.PP
.B -p pemfile
certificate (*.pem) file name
.RS
default: @ssldir@/certs/stunnel.pem for server mode,
none for client mode
.RE
.PP
.B -v level
verify peer certificate
.RS
level 1 - verify peer certificate if present
level 2 - verify peer certificate
level 3 - verify peer with locally installed certificate
default: no verify
.RE
.PP
.B -a directory
client certificate directory for -v 3 option
.RS
default: @ssldir@/certs/trusted
.RE
.PP
.B -t timeout
session cache timeout
.RS
default: 300 s.
.RE
.PP
.B -u user
Use IDENT (RFC 1413) username checking
.PP
.B -n proto
Negotiate SSL with specified protocol
.RS
currenty supported: smtp
.RE
.PP
.B -d [ip:]port
daemon mode (ip defaults to INADDR_ANY)
.RS
default: inetd mode
.RE
.PP
.B -f
foreground mode (don't fork, log to stderr)
.RS
default: background in daemon mode
.RE
.PP
.B -l program [-- args]
.RS
execute local inetd-type program
.RE
.PP
.B -L program [-- args]
.RS
open local pty and execute program
.RE
.PP
.B -s username
.RS
setuid() to username in daemon mode
.RE
.PP
.B -g groupname
.RS
setgid() to groupname in daemon mode. Clears all other groups.
.RE
.PP
.B -r [ip:]port
connect to remote service
.RS
(ip defaults to INADDR_LOOPBACK)
.RE

.SH EXAMPLES
In order to provide SSL encapsulation to your local \fIimapd\fR service, use
.sp
.RS
.nf
stunnel -d 993 -l /usr/sbin/imapd -- imapd
.fi
.RE
.PP
If you want to provide tunneling to your \fIpppd\fR daemon on port 2020,
use something like
.sp
.RS
.nf
stunnel -d 2020 -L /usr/sbin/pppd -- pppd local
.fi
.RE

.SH CERTIFICATES
Each SSL enabled daemon needs to present a valid X.509 certificate
to the peer. It also needs a private key to decrypt the incoming
data. The easiest way to obtain a certificate and a key is to 
generate them with the free \fIopenssl\fR package. You can find more
information on certificates generation on pages listed below.
.PP
Two things are important when generating certificate-key pairs for
\fBstunnel\fR. The private key cannot be encrypted, because the server
has no way to obtain the password from the user. To produce an
unencrypted key add the \fI-nodes\fR option when running the \fIreq\fR
command from the \fIopenssl\fR kit.
.PP
The order of contents of the \fI.pem\fR file is also important.
It should contain the unencrypted private key first, then a signed certificate
(not certificate request).
There should be also empty lines after certificate and private key.
Plaintext certificate information appended on the top of generated certificate
should be discarded. So the file should look like this:
.sp
.nf
-----BEGIN RSA PRIVATE KEY-----
[encoded key]
-----END RSA PRIVATE KEY-----
[empty line]
-----BEGIN CERTIFICATE-----
[encoded certificate]
-----END CERTIFICATE-----
[empty line]
.fi
.sp
.SH LIMITATIONS
\fIstunnel\fR cannot be used for the FTP daemon because of the nature
of the FTP protocol which utilizes multiple ports for data transfers.
There are available SSL enabled versions of FTP and telnet daemons, however.
.SH SEE ALSO
.BR tcpd (8),
.BR inetd (8)
.PP
.BI http://mike.daewoo.com.pl/computer/stunnel
Stunnel homepage
.PP
.BI http://www.openssl.org
OpenSSL project website
.SH AUTHORS
Michal Trojnara <Michal.Trojnara@centertel.pl>
.PP
Adam Hernik <adas@infocentrum.com>
.PP
Pawel Krawczyk <kravietz@ceti.com.pl>
.PP
PTY support by Dirk O. Siebnich <dok@vossnet.de>
