Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40)

Standard preamble:
========================================================================
..
..
.. Set up some character translations and predefined strings. \*(-- will
give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
double quote, and \*(R" will give a right double quote. \*(C+ will
give a nicer C++. Capital omega is used to do unbreakable dashes and
therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
nothing in troff, for use with C<>.
.tr \(*W- . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\}
Escape single quotes in literal strings from groff's Unicode transform.

If the F register is >0, we'll generate index entries on stderr for
titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
entries marked with X<> in POD. Of course, you'll have to process the
output yourself in some meaningful fashion.

Avoid warning from groff about undefined register 'F'.
.. .nr rF 0 . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF ========================================================================

Title "stunnel 8"
stunnel 8 "2021.05.30" "5.60" "stunnel TLS Proxy"
For nroff, turn off justification. Always turn off hyphenation; it makes
way too many mistakes in technical documents.
"NAME"
stunnel - TLS offloading and load-balancing proxy
"SYNOPSIS"
Header "SYNOPSIS"
"Unix:" 4
Item "Unix:" \fBstunnel [\s-1FILE\s0] | -fd N | -help | -version | -sockets | -options
"\s-1WIN32:\s0" 4
Item "WIN32:" \fBstunnel [ [ -install | -uninstall | -start | -stop | -reload | -reopen | -exit ] [-quiet] [\s-1FILE\s0] ] | -help | -version | -sockets | -options
"DESCRIPTION"
Header "DESCRIPTION" The stunnel program is designed to work as \s-1TLS\s0 encryption wrapper between remote clients and local (inetd-startable) or remote servers. The concept is that having non-TLS aware daemons running on your system you can easily set them up to communicate with clients over secure \s-1TLS\s0 channels.

\fBstunnel can be used to add \s-1TLS\s0 functionality to commonly used Inetd daemons like \s-1POP-2, POP-3,\s0 and \s-1IMAP\s0 servers, to standalone daemons like \s-1NNTP, SMTP\s0 and \s-1HTTP,\s0 and in tunneling \s-1PPP\s0 over network sockets without changes to the source code.

This product includes cryptographic software written by Eric Young (eay@cryptsoft.com)

"OPTIONS"
Header "OPTIONS"
"\s-1FILE\s0" 4
Item "FILE" Use specified configuration file
"-fd N (Unix only)" 4
Item "-fd N (Unix only)" Read the config file from specified file descriptor
"-help" 4
Item "-help" Print stunnel help menu
"-version" 4
Item "-version" Print stunnel version and compile time defaults
"-sockets" 4
Item "-sockets" Print default socket options
"-options" 4
Item "-options" Print supported \s-1TLS\s0 options
"-install (Windows \s-1NT\s0 and later only)" 4
Item "-install (Windows NT and later only)" Install \s-1NT\s0 Service
"-uninstall (Windows \s-1NT\s0 and later only)" 4
Item "-uninstall (Windows NT and later only)" Uninstall \s-1NT\s0 Service
"-start (Windows \s-1NT\s0 and later only)" 4
Item "-start (Windows NT and later only)" Start \s-1NT\s0 Service
"-stop (Windows \s-1NT\s0 and later only)" 4
Item "-stop (Windows NT and later only)" Stop \s-1NT\s0 Service
"-reload (Windows \s-1NT\s0 and later only)" 4
Item "-reload (Windows NT and later only)" Reload the configuration file of the running \s-1NT\s0 Service
"-reopen (Windows \s-1NT\s0 and later only)" 4
Item "-reopen (Windows NT and later only)" Reopen the log file of the running \s-1NT\s0 Service
"-exit (Win32 only)" 4
Item "-exit (Win32 only)" Exit an already started stunnel
"-quiet (Win32 only)" 4
Item "-quiet (Win32 only)" Don't display any message boxes
"CONFIGURATION FILE"
Header "CONFIGURATION FILE" Each line of the configuration file can be either:
"\(bu" 4
An empty line (ignored).
"\(bu" 4
A comment starting with ';' (ignored).
"\(bu" 4
An 'option_name = option_value' pair.
"\(bu" 4
'[service_name]' indicating a start of a service definition.

An address parameter of an option may be either:

"\(bu" 4
A port number.
"\(bu" 4
A colon-separated pair of \s-1IP\s0 address (either IPv4, IPv6, or domain name) and port number.
"\(bu" 4
A Unix socket path (Unix only).
"\s-1GLOBAL OPTIONS\s0"
Subsection "GLOBAL OPTIONS"
"chroot = \s-1DIRECTORY\s0 (Unix only)" 4
Item "chroot = DIRECTORY (Unix only)" directory to chroot stunnel process .Sp \fBchroot keeps stunnel in a chrooted jail. CApath, CRLpath, pid and exec are located inside the jail and the patches have to be relative to the directory specified with chroot. .Sp Several functions of the operating system also need their files to be located within the chroot jail, e.g.:

"\(bu" 4
Delayed resolver typically needs /etc/nsswitch.conf and /etc/resolv.conf.
"\(bu" 4
Local time in log files needs /etc/timezone.
"\(bu" 4
Some other functions may need devices, e.g. /dev/zero or /dev/null.

"compression = deflate | zlib" 4
Item "compression = deflate | zlib" select data compression algorithm .Sp default: no compression .Sp Deflate is the standard compression method as described in \s-1RFC 1951.\s0
"debug = [\s-1FACILITY.\s0]LEVEL" 4
Item "debug = [FACILITY.]LEVEL" debugging level .Sp Level is one of the syslog level names or numbers emerg (0), alert (1), crit (2), err (3), warning (4), notice (5), info (6), or debug (7). All logs for the specified level and all levels numerically less than it will be shown. Use debug = debug or \fIdebug = 7 for greatest debugging output. The default is notice (5). .Sp The syslog facility 'daemon' will be used unless a facility name is supplied. (Facilities are not supported on Win32.) .Sp Case is ignored for both facilities and levels.
"\s-1EGD\s0 = \s-1EGD_PATH\s0 (Unix only)" 4
Item "EGD = EGD_PATH (Unix only)" path to Entropy Gathering Daemon socket .Sp Entropy Gathering Daemon socket to use to feed the OpenSSL random number generator.
"engine = auto | \s-1ENGINE_ID\s0" 4
Item "engine = auto | ENGINE_ID" select hardware or software cryptographic engine .Sp default: software-only cryptography .Sp See Examples section for an engine configuration to use the certificate and the corresponding private key from a cryptographic device.
"engineCtrl = COMMAND[:PARAMETER]" 4
Item "engineCtrl = COMMAND[:PARAMETER]" control hardware engine
"engineDefault = \s-1TASK_LIST\s0" 4
Item "engineDefault = TASK_LIST" set OpenSSL tasks delegated to the current engine .Sp The parameter specifies a comma-separated list of task to be delegated to the current engine. .Sp The following tasks may be available, if supported by the engine: \s-1ALL, RSA, DSA, ECDH, ECDSA, DH, RAND, CIPHERS, DIGESTS, PKEY, PKEY_CRYPTO, PKEY_ASN1.\s0
"fips = yes | no" 4
Item "fips = yes | no" enable or disable \s-1FIPS 140-2\s0 mode. .Sp This option allows you to disable entering \s-1FIPS\s0 mode if stunnel was compiled with \s-1FIPS 140-2\s0 support. .Sp default: no (since version 5.00)
"foreground = yes | quiet | no (Unix only)" 4
Item "foreground = yes | quiet | no (Unix only)" foreground mode .Sp Stay in foreground (don't fork). .Sp With the yes parameter it also logs to stderr in addition to the destinations specified with syslog and output. .Sp default: background in daemon mode
"iconActive = \s-1ICON_FILE\s0 (\s-1GUI\s0 only)" 4
Item "iconActive = ICON_FILE (GUI only)" \s-1GUI\s0 icon to be displayed when there are established connections .Sp On Windows platform the parameter should be an .ico file containing a 16x16 pixel image.
"iconError = \s-1ICON_FILE\s0 (\s-1GUI\s0 only)" 4
Item "iconError = ICON_FILE (GUI only)" \s-1GUI\s0 icon to be displayed when no valid configuration is loaded .Sp On Windows platform the parameter should be an .ico file containing a 16x16 pixel image.
"iconIdle = \s-1ICON_FILE\s0 (\s-1GUI\s0 only)" 4
Item "iconIdle = ICON_FILE (GUI only)" \s-1GUI\s0 icon to be displayed when there are no established connections .Sp On Windows platform the parameter should be an .ico file containing a 16x16 pixel image.
"log = append | overwrite" 4
Item "log = append | overwrite" log file handling .Sp This option allows you to choose whether the log file (specified with the output option) is appended or overwritten when opened or re-opened. .Sp default: append
"output = \s-1FILE\s0" 4
Item "output = FILE" append log messages to a file .Sp /dev/stdout device can be used to send log messages to the standard output (for example to log them with daemontools splogger).
"pid = \s-1FILE\s0 (Unix only)" 4
Item "pid = FILE (Unix only)" pid file location .Sp If the argument is empty, then no pid file will be created. .Sp \fIpid path is relative to the chroot directory if specified.
"RNDbytes = \s-1BYTES\s0" 4
Item "RNDbytes = BYTES" bytes to read from random seed files
"RNDfile = \s-1FILE\s0" 4
Item "RNDfile = FILE" path to file with random seed data .Sp The OpenSSL library will use data from this file first to seed the random number generator.
"RNDoverwrite = yes | no" 4
Item "RNDoverwrite = yes | no" overwrite the random seed files with new random data .Sp default: yes
"service = \s-1SERVICE\s0 (Unix only)" 4
Item "service = SERVICE (Unix only)" stunnel service name .Sp The specified service name is used for syslog and as the inetd mode service name for \s-1TCP\s0 Wrappers. While this option can technically be specified in the service sections, it is only useful in global options. .Sp default: stunnel
"syslog = yes | no (Unix only)" 4
Item "syslog = yes | no (Unix only)" enable logging via syslog .Sp default: yes
"taskbar = yes | no (\s-1WIN32\s0 only)" 4
Item "taskbar = yes | no (WIN32 only)" enable the taskbar icon .Sp default: yes
"SERVICE-LEVEL \s-1OPTIONS\s0"
Subsection "SERVICE-LEVEL OPTIONS" Each configuration section begins with a service name in square brackets. The service name is used for libwrap (\s-1TCP\s0 Wrappers) access control and lets you distinguish stunnel services in your log files.

Note that if you wish to run stunnel in inetd mode (where it is provided a network socket by a server such as inetd, xinetd, or tcpserver) then you should read the section entitled \s-1INETD MODE\s0 below.

"accept = [\s-1HOST:\s0]PORT" 4
Item "accept = [HOST:]PORT" accept connections on specified address .Sp If no host specified, defaults to all IPv4 addresses for the local host. .Sp To listen on all IPv6 addresses use: .Sp .Vb 1 accept = :::PORT .Ve
"CApath = \s-1DIRECTORY\s0" 4
Item "CApath = DIRECTORY" Certificate Authority directory .Sp This is the directory in which stunnel will look for certificates when using the verifyChain or verifyPeer options. Note that the certificates in this directory should be named \s-1XXXXXXXX.0\s0 where \s-1XXXXXXXX\s0 is the hash value of the \s-1DER\s0 encoded subject of the cert. .Sp The hash algorithm has been changed in OpenSSL 1.0.0. It is required to c_rehash the directory on upgrade from OpenSSL 0.x.x to OpenSSL 1.x.x. .Sp \fICApath path is relative to the chroot directory if specified.
"CAfile = \s-1CA_FILE\s0" 4
Item "CAfile = CA_FILE" Certificate Authority file .Sp This file contains multiple \s-1CA\s0 certificates, to be used with the verifyChain and verifyPeer options.
"cert = \s-1CERT_FILE\s0" 4
Item "cert = CERT_FILE" certificate chain file name .Sp The parameter specifies the file containing certificates used by stunnel to authenticate itself against the remote client or server. The file should contain the whole certificate chain starting from the actual server/client certificate, and ending with the self-signed root \s-1CA\s0 certificate. The file must be either in \s-1PEM\s0 or P12 format. .Sp A certificate chain is required in server mode, and optional in client mode. .Sp This parameter is also used as the certificate identifier when a hardware engine is enabled.
"checkEmail = \s-1EMAIL\s0" 4
Item "checkEmail = EMAIL" email address of the peer certificate subject .Sp Multiple checkEmail options are allowed in a single service section. Certificates are accepted if no subject checks were specified, or the email address of the peer certificate matches any of the email addresses specified with checkEmail. .Sp This option requires OpenSSL 1.0.2 or later.
"checkHost = \s-1HOST\s0" 4
Item "checkHost = HOST" host of the peer certificate subject .Sp Multiple checkHost options are allowed in a single service section. Certificates are accepted if no subject checks were specified, or the host name of the peer certificate matches any of the hosts specified with checkHost. .Sp This option requires OpenSSL 1.0.2 or later.
"checkIP = \s-1IP\s0" 4
Item "checkIP = IP" \s-1IP\s0 address of the peer certificate subject .Sp Multiple checkIP options are allowed in a single service section. Certificates are accepted if no subject checks were specified, or the \s-1IP\s0 address of the peer certificate matches any of the \s-1IP\s0 addresses specified with \fIcheckIP. .Sp This option requires OpenSSL 1.0.2 or later.
"ciphers = \s-1CIPHER_LIST\s0" 4
Item "ciphers = CIPHER_LIST" select permitted \s-1TLS\s0 ciphers (TLSv1.2 and below) .Sp This option does not impact TLSv1.3 ciphersuites. .Sp A colon-delimited list of the ciphers to allow in the \s-1TLS\s0 connection, for example \s-1DES-CBC3-SHA:IDEA-CBC-MD5.\s0
"ciphersuites = \s-1CIPHERSUITES_LIST\s0" 4
Item "ciphersuites = CIPHERSUITES_LIST" select permitted TLSv1.3 ciphersuites .Sp A colon-delimited list of TLSv1.3 ciphersuites names in order of preference. .Sp This option requires OpenSSL 1.1.1 or later. .Sp default: \s-1TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256\s0
"client = yes | no" 4
Item "client = yes | no" client mode (remote service uses \s-1TLS\s0) .Sp default: no (server mode)
"config = COMMAND[:PARAMETER]" 4
Item "config = COMMAND[:PARAMETER]" \fBOpenSSL configuration command .Sp The OpenSSL configuration command is executed with the specified parameter. This allows any configuration commands to be invoked from the stunnel configuration file. Supported commands are described on the \fI\f(BISSL_CONF_cmd\|(3ssl) manual page. .Sp Several config lines can be used to specify multiple configuration commands. .Sp Use curves option instead of enabling config = Curves:list_curves to support elliptic curves. .Sp This option requires OpenSSL 1.0.2 or later.
"connect = [\s-1HOST:\s0]PORT" 4
Item "connect = [HOST:]PORT" connect to a remote address .Sp If no host is specified, the host defaults to localhost. .Sp Multiple connect options are allowed in a single service section. .Sp If host resolves to multiple addresses and/or if multiple connect options are specified, then the remote address is chosen using a round-robin algorithm.
"CRLpath = \s-1DIRECTORY\s0" 4
Item "CRLpath = DIRECTORY" Certificate Revocation Lists directory .Sp This is the directory in which stunnel will look for CRLs when using the \fIverifyChain and verifyPeer options. Note that the CRLs in this directory should be named \s-1XXXXXXXX\s0.r0 where \s-1XXXXXXXX\s0 is the hash value of the \s-1CRL.\s0 .Sp The hash algorithm has been changed in OpenSSL 1.0.0. It is required to c_rehash the directory on upgrade from OpenSSL 0.x.x to OpenSSL 1.x.x. .Sp \fICRLpath path is relative to the chroot directory if specified.
"CRLfile = \s-1CRL_FILE\s0" 4
Item "CRLfile = CRL_FILE" Certificate Revocation Lists file .Sp This file contains multiple CRLs, used with the verifyChain and \fIverifyPeer options.
"curves = list" 4
Item "curves = list" \s-1ECDH\s0 curves separated with ':' .Sp Only a single curve name is allowed for OpenSSL older than 1.1.1. .Sp To get a list of supported curves use: .Sp .Vb 1 openssl ecparam -list_curves .Ve .Sp default: .Sp .Vb 1 X25519:P-256:X448:P-521:P-384 (OpenSSL 1.1.1 or later) \& prime256v1 (OpenSSL older than 1.1.1) .Ve
"logId = \s-1TYPE\s0" 4
Item "logId = TYPE" connection identifier type .Sp This identifier allows you to distinguish log entries generated for each of the connections. .Sp Currently supported types:

"sequential" 4
Item "sequential" The numeric sequential identifier is only unique within a single instance of \fBstunnel, but very compact. It is most useful for manual log analysis.
"unique" 4
Item "unique" This alphanumeric identifier is globally unique, but longer than the sequential number. It is most useful for automated log analysis.
"thread" 4
Item "thread" The operating system thread identifier is neither unique (even within a single instance of stunnel) nor short. It is most useful for debugging software or configuration issues.
"process" 4
Item "process" The operating system process identifier (\s-1PID\s0) may be useful in the inetd mode.

.Sp default: sequential

"debug = \s-1LEVEL\s0" 4
Item "debug = LEVEL" debugging level .Sp Level is a one of the syslog level names or numbers emerg (0), alert (1), crit (2), err (3), warning (4), notice (5), info (6), or debug (7). All logs for the specified level and all levels numerically less than it will be shown. The default is notice (5). .Sp While the debug = debug or debug = 7 level generates the most verbose output, it is only intended to be used by stunnel developers. Please only use this value if you are a developer, or you intend to send your logs to our technical support. Otherwise, the generated logs will be confusing.
"delay = yes | no" 4
Item "delay = yes | no" delay \s-1DNS\s0 lookup for the connect option .Sp This option is useful for dynamic \s-1DNS,\s0 or when \s-1DNS\s0 is not available during \fBstunnel startup (road warrior \s-1VPN,\s0 dial-up configurations). .Sp Delayed resolver mode is automatically engaged when stunnel fails to resolve on startup any of the connect targets for a service. .Sp Delayed resolver inflicts failover = prio. .Sp default: no
"engineId = \s-1ENGINE_ID\s0" 4
Item "engineId = ENGINE_ID" select engine \s-1ID\s0 for the service
"engineNum = \s-1ENGINE_NUMBER\s0" 4
Item "engineNum = ENGINE_NUMBER" select engine number for the service .Sp The engines are numbered starting from 1.
"exec = \s-1EXECUTABLE_PATH\s0" 4
Item "exec = EXECUTABLE_PATH" execute a local inetd-type program .Sp \fIexec path is relative to the chroot directory if specified. .Sp The following environmental variables are set on Unix platforms: \s-1REMOTE_HOST, REMOTE_PORT, SSL_CLIENT_DN, SSL_CLIENT_I_DN.\s0 Item "execArgs = $0 $1 $2 ..." arguments for exec including the program name ($0) .Sp Quoting is currently not supported. Arguments are separated with an arbitrary amount of whitespace.
"failover = rr | prio" 4
Item "failover = rr | prio" Failover strategy for multiple \*(L"connect\*(R" targets.

"rr" 4
Item "rr" round robin - fair load distribution
"prio" 4
Item "prio" priority - use the order specified in config file

.Sp default: prio

"ident = \s-1USERNAME\s0" 4
Item "ident = USERNAME" use \s-1IDENT\s0 (\s-1RFC 1413\s0) username checking
"include = \s-1DIRECTORY\s0" 4
Item "include = DIRECTORY" include all configuration file parts located in \s-1DIRECTORY\s0 .Sp The files are included in the ascending alphabetical order of their names. The recommended filename convention is .Sp for global options: .Sp .Vb 1 00-global.conf .Ve .Sp for local service-level options: .Sp .Vb 1 01-service.conf \& 02-service.conf .Ve
"key = \s-1KEY_FILE\s0" 4
Item "key = KEY_FILE" private key for the certificate specified with cert option .Sp A private key is needed to authenticate the certificate owner. Since this file should be kept secret it should only be readable by its owner. On Unix systems you can use the following command: .Sp .Vb 1 chmod 600 keyfile .Ve .Sp This parameter is also used as the private key identifier when a hardware engine is enabled. .Sp default: the value of the cert option
"libwrap = yes | no" 4
Item "libwrap = yes | no" Enable or disable the use of /etc/hosts.allow and /etc/hosts.deny. .Sp default: no (since version 5.00)
"local = \s-1HOST\s0" 4
Item "local = HOST" By default, the \s-1IP\s0 address of the outgoing interface is used as the source for remote connections. Use this option to bind a static local \s-1IP\s0 address instead.
"\s-1OCSP\s0 = \s-1URL\s0" 4
Item "OCSP = URL" select \s-1OCSP\s0 responder for certificate verification
"OCSPaia = yes | no" 4
Item "OCSPaia = yes | no" validate certificates with their \s-1AIA OCSP\s0 responders .Sp This option enables stunnel to validate certificates with the list of \s-1OCSP\s0 responder URLs retrieved from their \s-1AIA\s0 (Authority Information Access) extension.
"OCSPflag = \s-1OCSP_FLAG\s0" 4
Item "OCSPflag = OCSP_FLAG" specify \s-1OCSP\s0 responder flag .Sp Several OCSPflag can be used to specify multiple flags. .Sp currently supported flags: \s-1NOCERTS, NOINTERN, NOSIGS, NOCHAIN, NOVERIFY, NOEXPLICIT, NOCASIGN, NODELEGATED, NOCHECKS, TRUSTOTHER, RESPID_KEY, NOTIME\s0
"OCSPnonce = yes | no" 4
Item "OCSPnonce = yes | no" send and verify the \s-1OCSP\s0 nonce extension .Sp This option protects the \s-1OCSP\s0 protocol against replay attacks. Due to its computational overhead, the nonce extension is usually only supported on internal (e.g. corporate) responders, and not on public \s-1OCSP\s0 responders.
"options = \s-1SSL_OPTIONS\s0" 4
Item "options = SSL_OPTIONS" \fBOpenSSL library options .Sp The parameter is the OpenSSL option name as described in the \fI\f(BISSL_CTX_set_options\|(3ssl) manual, but without \s-1SSL_OP_\s0 prefix. \fIstunnel -options lists the options found to be allowed in the current combination of stunnel and the OpenSSL library used to build it. .Sp Several option lines can be used to specify multiple options. An option name can be prepended with a dash (\*(L"-\*(R") to disable the option. .Sp For example, for compatibility with the erroneous Eudora \s-1TLS\s0 implementation, the following option can be used: .Sp .Vb 1 options = DONT_INSERT_EMPTY_FRAGMENTS .Ve .Sp default: .Sp .Vb 2 options = NO_SSLv2 options = NO_SSLv3 .Ve .Sp Use sslVersionMax or sslVersionMin option instead of disabling specific \s-1TLS\s0 protocol versions when compiled with OpenSSL 1.1.0 or later.
"protocol = \s-1PROTO\s0" 4
Item "protocol = PROTO" application protocol to negotiate \s-1TLS\s0 .Sp This option enables initial, protocol-specific negotiation of the \s-1TLS\s0 encryption. The protocol option should not be used with \s-1TLS\s0 encryption on a separate port. .Sp Currently supported protocols:

"cifs" 4
Item "cifs" Proprietary (undocummented) extension of \s-1CIFS\s0 protocol implemented in Samba. Support for this extension was dropped in Samba 3.0.0.
"connect" 4
Item "connect" Based on \s-1RFC 2817\s0 - Upgrading to \s-1TLS\s0 Within \s-1HTTP/1.1\s0, section 5.2 - Requesting a Tunnel with \s-1CONNECT\s0 .Sp This protocol is only supported in client mode.
"imap" 4
Item "imap" Based on \s-1RFC 2595\s0 - Using \s-1TLS\s0 with \s-1IMAP, POP3\s0 and \s-1ACAP\s0
"ldap" 4
Item "ldap" Based on \s-1RFC 2830\s0 - Lightweight Directory Access Protocol (v3): Extension for Transport Layer Security
"nntp" 4
Item "nntp" Based on \s-1RFC 4642\s0 - Using Transport Layer Security (\s-1TLS\s0) with Network News Transfer Protocol (\s-1NNTP\s0) .Sp This protocol is only supported in client mode.
"pgsql" 4
Item "pgsql" Based on \fIhttp://www.postgresql.org/docs/8.3/static/protocol-flow.html#AEN73982
"pop3" 4
Item "pop3" Based on \s-1RFC 2449\s0 - \s-1POP3\s0 Extension Mechanism
"proxy" 4
Item "proxy" Passing of the original client \s-1IP\s0 address with HAProxy \s-1PROXY\s0 protocol version 1 \fIhttps://www.haproxy.org/download/1.8/doc/proxy-protocol.txt
"smtp" 4
Item "smtp" Based on \s-1RFC 2487\s0 - \s-1SMTP\s0 Service Extension for Secure \s-1SMTP\s0 over \s-1TLS\s0
"socks" 4
Item "socks" \s-1SOCKS\s0 versions 4, 4a, and 5 are supported. The \s-1SOCKS\s0 protocol itself is encapsulated within \s-1TLS\s0 encryption layer to protect the final destination address. .Sp \fIhttp://www.openssh.com/txt/socks4.protocol .Sp \fIhttp://www.openssh.com/txt/socks4a.protocol .Sp The \s-1BIND\s0 command of the \s-1SOCKS\s0 protocol is not supported. The \s-1USERID\s0 parameter is ignored. .Sp See Examples section for sample configuration files for \s-1VPN\s0 based on \s-1SOCKS\s0 encryption.

"protocolAuthentication = \s-1AUTHENTICATION\s0" 4
Item "protocolAuthentication = AUTHENTICATION" authentication type for the protocol negotiations .Sp Currently, this option is only supported in the client-side 'connect' and 'smtp' protocols. .Sp Supported authentication types for the 'connect' protocol are 'basic' or 'ntlm'. The default 'connect' authentication type is 'basic'. .Sp Supported authentication types for the 'smtp' protocol are 'plain' or 'login'. The default 'smtp' authentication type is 'plain'.
"protocolDomain = \s-1DOMAIN\s0" 4
Item "protocolDomain = DOMAIN" domain for the protocol negotiations .Sp Currently, this option is only supported in the client-side 'connect' protocol.
"protocolHeader = \s-1HEADER\s0" 4
Item "protocolHeader = HEADER" header for the protocol negotiations .Sp Currently, this option is only supported in the client-side 'connect' protocol.
"protocolHost = \s-1ADDRESS\s0" 4
Item "protocolHost = ADDRESS" host address for the protocol negotiations .Sp For the 'connect' protocol negotiations, protocolHost specifies \s-1HOST:PORT\s0 of the final \s-1TLS\s0 server to be connected to by the proxy. The proxy server directly connected by stunnel must be specified with the connect option. .Sp For the 'smtp' protocol negotiations, protocolHost controls the client \s-1SMTP HELO/EHLO\s0 value.
"protocolPassword = \s-1PASSWORD\s0" 4
Item "protocolPassword = PASSWORD" password for the protocol negotiations .Sp Currently, this option is only supported in the client-side 'connect' and 'smtp' protocols.
"protocolUsername = \s-1USERNAME\s0" 4
Item "protocolUsername = USERNAME" username for the protocol negotiations .Sp Currently, this option is only supported in the client-side 'connect' and 'smtp' protocols.
"PSKidentity = \s-1IDENTITY\s0" 4
Item "PSKidentity = IDENTITY" \s-1PSK\s0 identity for the \s-1PSK\s0 client .Sp \fIPSKidentity can be used on stunnel clients to select the \s-1PSK\s0 identity used for authentication. This option is ignored in server sections. .Sp default: the first identity specified in the PSKsecrets file.
"PSKsecrets = \s-1FILE\s0" 4
Item "PSKsecrets = FILE" file with \s-1PSK\s0 identities and corresponding keys .Sp Each line of the file in the following format: .Sp .Vb 1 IDENTITY:KEY .Ve .Sp Hexadecimal keys are automatically converted to binary form. Keys are required to be at least 16 bytes long, which implies at least 32 characters for hexadecimal keys. The file should neither be world-readable nor world-writable.
"pty = yes | no (Unix only)" 4
Item "pty = yes | no (Unix only)" allocate a pseudoterminal for 'exec' option
"redirect = [\s-1HOST:\s0]PORT" 4
Item "redirect = [HOST:]PORT" redirect \s-1TLS\s0 client connections on certificate-based authentication failures .Sp This option only works in server mode. Some protocol negotiations are also incompatible with the redirect option.
"renegotiation = yes | no" 4
Item "renegotiation = yes | no" support \s-1TLS\s0 renegotiation .Sp Applications of the \s-1TLS\s0 renegotiation include some authentication scenarios, or re-keying long lasting connections. .Sp On the other hand this feature can facilitate a trivial CPU-exhaustion DoS attack: .Sp \fIhttp://vincent.bernat.im/en/blog/2011-ssl-dos-mitigation.html .Sp Please note that disabling \s-1TLS\s0 renegotiation does not fully mitigate this issue. .Sp default: yes (if supported by OpenSSL)
"reset = yes | no" 4
Item "reset = yes | no" attempt to use the \s-1TCP RST\s0 flag to indicate an error .Sp This option is not supported on some platforms. .Sp default: yes
"retry = yes | no" 4
Item "retry = yes | no" reconnect a connect+exec section after it was disconnected .Sp default: no
"securityLevel = \s-1LEVEL\s0" 4
Item "securityLevel = LEVEL" set the security level .Sp The meaning of each level is described below:

"level 0" 4
Item "level 0" Everything is permitted.
"level 1" 4
Item "level 1" The security level corresponds to a minimum of 80 bits of security. Any parameters offering below 80 bits of security are excluded. As a result \s-1RSA, DSA\s0 and \s-1DH\s0 keys shorter than 1024 bits and \s-1ECC\s0 keys shorter than 160 bits are prohibited. All export cipher suites are prohibited since they all offer less than 80 bits of security. \s-1SSL\s0 version 2 is prohibited. Any cipher suite using \s-1MD5\s0 for the \s-1MAC\s0 is also prohibited.
"level 2" 4
Item "level 2" Security level set to 112 bits of security. As a result \s-1RSA, DSA\s0 and \s-1DH\s0 keys shorter than 2048 bits and \s-1ECC\s0 keys shorter than 224 bits are prohibited. In addition to the level 1 exclusions any cipher suite using \s-1RC4\s0 is also prohibited. \s-1SSL\s0 version 3 is also not allowed. Compression is disabled.
"level 3" 4
Item "level 3" Security level set to 128 bits of security. As a result \s-1RSA, DSA\s0 and \s-1DH\s0 keys shorter than 3072 bits and \s-1ECC\s0 keys shorter than 256 bits are prohibited. In addition to the level 2 exclusions cipher suites not offering forward secrecy are prohibited. \s-1TLS\s0 versions below 1.1 are not permitted. Session tickets are disabled.
"level 4" 4
Item "level 4" Security level set to 192 bits of security. As a result \s-1RSA, DSA\s0 and \s-1DH\s0 keys shorter than 7680 bits and \s-1ECC\s0 keys shorter than 384 bits are prohibited. Cipher suites using \s-1SHA1\s0 for the \s-1MAC\s0 are prohibited. \s-1TLS\s0 versions below 1.2 are not permitted.
"level 5" 4
Item "level 5" Security level set to 256 bits of security. As a result \s-1RSA, DSA\s0 and \s-1DH\s0 keys shorter than 15360 bits and \s-1ECC\s0 keys shorter than 512 bits are prohibited.
"default: 2" 4
Item "default: 2"

.Sp The securityLevel option is only available when compiled with OpenSSL 1.1.0 and later.

"requireCert = yes | no" 4
Item "requireCert = yes | no" require a client certificate for verifyChain or verifyPeer .Sp With requireCert set to no, the stunnel server accepts client connections that did not present a certificate. .Sp Both verifyChain = yes and verifyPeer = yes imply requireCert = yes. .Sp default: no
"setgid = \s-1GROUP\s0 (Unix only)" 4
Item "setgid = GROUP (Unix only)" Unix group id .Sp As a global option: setgid() to the specified group in daemon mode and clear all other groups. .Sp As a service-level option: set the group of the Unix socket specified with \*(L"accept\*(R".
"setuid = \s-1USER\s0 (Unix only)" 4
Item "setuid = USER (Unix only)" Unix user id .Sp As a global option: setuid() to the specified user in daemon mode. .Sp As a service-level option: set the owner of the Unix socket specified with \*(L"accept\*(R".
"sessionCacheSize = \s-1NUM_ENTRIES\s0" 4
Item "sessionCacheSize = NUM_ENTRIES" session cache size .Sp \fIsessionCacheSize specifies the maximum number of the internal session cache entries. .Sp The value of 0 can be used for unlimited size. It is not recommended for production use due to the risk of a memory exhaustion DoS attack.
"sessionCacheTimeout = \s-1TIMEOUT\s0" 4
Item "sessionCacheTimeout = TIMEOUT" session cache timeout .Sp This is the number of seconds to keep cached \s-1TLS\s0 sessions.
"sessionResume = yes | no" 4
Item "sessionResume = yes | no" allow or disallow session resumption .Sp default: yes
"sessiond = \s-1HOST:PORT\s0" 4
Item "sessiond = HOST:PORT" address of sessiond \s-1TLS\s0 cache server
"sni = \s-1SERVICE_NAME:SERVER_NAME_PATTERN\s0 (server mode)" 4
Item "sni = SERVICE_NAME:SERVER_NAME_PATTERN (server mode)" Use the service as a slave service (a name-based virtual server) for Server Name Indication \s-1TLS\s0 extension (\s-1RFC 3546\s0). .Sp \fI\s-1SERVICE_NAME\s0 specifies the master service that accepts client connections with the accept option. \s-1SERVER_NAME_PATTERN\s0 specifies the host name to be redirected. The pattern may start with the '*' character, e.g. '*.example.com'. Multiple slave services are normally specified for a single master service. The sni option can also be specified more than once within a single slave service. .Sp This service, as well as the master service, may not be configured in client mode. .Sp The connect option of the slave service is ignored when the protocol option is specified, as protocol connects to the remote host before \s-1TLS\s0 handshake. .Sp Libwrap checks (Unix only) are performed twice: with the master service name after \s-1TCP\s0 connection is accepted, and with the slave service name during the \s-1TLS\s0 handshake. .Sp The sni option is only available when compiled with OpenSSL 1.0.0 and later.
"sni = \s-1SERVER_NAME\s0 (client mode)" 4
Item "sni = SERVER_NAME (client mode)" Use the parameter as the value of \s-1TLS\s0 Server Name Indication (\s-1RFC 3546\s0) extension. .Sp Empty \s-1SERVER_NAME\s0 disables sending the \s-1SNI\s0 extension. .Sp The sni option is only available when compiled with OpenSSL 1.0.0 and later.
"socket = a|l|r:OPTION=VALUE[:VALUE]" 4
Item "socket = a|l|r:OPTION=VALUE[:VALUE]" Set an option on the accept/local/remote socket .Sp The values for the linger option are l_onof:l_linger. The values for the time are tv_sec:tv_usec. .Sp Examples: .Sp .Vb 9 socket = l:SO_LINGER=1:60 set one minute timeout for closing local socket socket = r:SO_OOBINLINE=yes place out-of-band data directly into the receive data stream for remote sockets socket = a:SO_REUSEADDR=no disable address reuse (enabled by default) socket = a:SO_BINDTODEVICE=lo only accept connections on loopback interface .Ve
"sslVersion = \s-1SSL_VERSION\s0" 4
Item "sslVersion = SSL_VERSION" select the \s-1TLS\s0 protocol version .Sp Supported versions: all, SSLv2, SSLv3, TLSv1, TLSv1.1, TLSv1.2, TLSv1.3 .Sp Availability of specific protocols depends on the linked OpenSSL library. Older versions of OpenSSL do not support TLSv1.1, TLSv1.2 and TLSv1.3. Newer versions of OpenSSL do not support SSLv2. .Sp Obsolete SSLv2 and SSLv3 are currently disabled by default. .Sp Setting the option .Sp .Vb 1 sslVersion = SSL_VERSION .Ve .Sp is equivalent to options .Sp .Vb 2 sslVersionMax = SSL_VERSION sslVersionMin = SSL_VERSION .Ve .Sp when compiled with OpenSSL 1.1.0 and later.
"sslVersionMax = \s-1SSL_VERSION\s0" 4
Item "sslVersionMax = SSL_VERSION" maximum supported protocol versions .Sp Supported versions: all, SSLv3, TLSv1, TLSv1.1, TLSv1.2, TLSv1.3 .Sp \fIall enable protocol versions up to the highest version supported by the linked OpenSSL library. .Sp Availability of specific protocols depends on the linked OpenSSL library. .Sp The sslVersionMax option is only available when compiled with OpenSSL 1.1.0 and later. .Sp default: all
"sslVersionMin = \s-1SSL_VERSION\s0" 4
Item "sslVersionMin = SSL_VERSION" minimum supported protocol versions .Sp Supported versions: all, SSLv3, TLSv1, TLSv1.1, TLSv1.2, TLSv1.3 .Sp \fIall enable protocol versions down to the lowest version supported by the linked OpenSSL library. .Sp Availability of specific protocols depends on the linked OpenSSL library. .Sp The sslVersionMin option is only available when compiled with OpenSSL 1.1.0 and later. .Sp default: TLSv1
"stack = \s-1BYTES\s0 (except for \s-1FORK\s0 model)" 4
Item "stack = BYTES (except for FORK model)" \s-1CPU\s0 stack size of created threads .Sp Excessive thread stack size increases virtual memory usage. Insufficient thread stack size may cause application crashes. .Sp default: 65536 bytes (sufficient for all platforms we tested)
"ticketKeySecret = \s-1SECRET\s0" 4
Item "ticketKeySecret = SECRET" hexadecimal symmetric key used for session ticket confidentiality protection .Sp Session tickets defined in \s-1RFC 5077\s0 provide an enhanced session resumption capability, where the server-side caching is not required to maintain per session state. .Sp Combining ticketKeySecret and ticketMacSecret options allow to resume a negotiated session on other cluster nodes, or to resume a negotiated session after server restart. .Sp The key is required to be either 16 or 32 bytes long, which implies exactly 32 or 64 hexadecimal digits. Colons may optionally be used between two-character hexadecimal bytes. .Sp This option only works in server mode. .Sp The ticketKeySecret option is only available when compiled with \fBOpenSSL 1.0.0 and later. .Sp Disabling \s-1NO_TICKET\s0 option is required for the ticket support in OpenSSL older than 1.1.1, but note that this option is incompatible with the \fIredirect option.
"ticketMacSecret = \s-1SECRET\s0" 4
Item "ticketMacSecret = SECRET" hexadecimal symmetric key used for session ticket integrity protection .Sp The key is required to be either 16 or 32 bytes long, which implies exactly 32 or 64 hexadecimal digits. Colons may optionally be used between two-character hexadecimal bytes. .Sp This option only works in server mode. .Sp The ticketMacSecret option is only available when compiled with \fBOpenSSL 1.0.0 and later.
"TIMEOUTbusy = \s-1SECONDS\s0" 4
Item "TIMEOUTbusy = SECONDS" time to wait for expected data
"TIMEOUTclose = \s-1SECONDS\s0" 4
Item "TIMEOUTclose = SECONDS" time to wait for close_notify (set to 0 for buggy \s-1MSIE\s0)
"TIMEOUTconnect = \s-1SECONDS\s0" 4
Item "TIMEOUTconnect = SECONDS" time to wait to connect to a remote host
"TIMEOUTidle = \s-1SECONDS\s0" 4
Item "TIMEOUTidle = SECONDS" time to keep an idle connection
"transparent = none | source | destination | both (Unix only)" 4
Item "transparent = none | source | destination | both (Unix only)" enable transparent proxy support on selected platforms .Sp Supported values:

"none" 4
Item "none" Disable transparent proxy support. This is the default.
"source" 4
Item "source" Re-write the address to appear as if a wrapped daemon is connecting from the \s-1TLS\s0 client machine instead of the machine running stunnel. .Sp This option is currently available in:

"Remote mode (connect option) on Linux >=2.6.28" 4
Item "Remote mode (connect option) on Linux >=2.6.28" This configuration requires stunnel to be executed as root and without the setuid option. .Sp This configuration requires the following setup for iptables and routing (possibly in /etc/rc.local or equivalent file): .Sp .Vb 7 iptables -t mangle -N DIVERT iptables -t mangle -A PREROUTING -p tcp -m socket -j DIVERT iptables -t mangle -A DIVERT -j MARK --set-mark 1 iptables -t mangle -A DIVERT -j ACCEPT ip rule add fwmark 1 lookup 100 ip route add local 0.0.0.0/0 dev lo table 100 echo 0 >/proc/sys/net/ipv4/conf/lo/rp_filter .Ve .Sp \fBstunnel must also to be executed as root and without the setuid option.
"Remote mode (connect option) on Linux 2.2.x" 4
Item "Remote mode (connect option) on Linux 2.2.x" This configuration requires the kernel to be compiled with the transparent proxy option. Connected service must be installed on a separate host. Routing towards the clients has to go through the stunnel box. .Sp \fBstunnel must also to be executed as root and without the setuid option.
"Remote mode (connect option) on FreeBSD >=8.0" 4
Item "Remote mode (connect option) on FreeBSD >=8.0" This configuration requires additional firewall and routing setup. \fBstunnel must also to be executed as root and without the setuid option.
"Local mode (exec option)" 4
Item "Local mode (exec option)" This configuration works by pre-loading the libstunnel.so shared library. _RLD_LIST environment variable is used on Tru64, and \s-1LD_PRELOAD\s0 variable on other platforms.

"destination" 4
Item "destination" The original destination is used instead of the connect option. .Sp A service section for transparent destination may look like this: .Sp .Vb 4 [transparent] client = yes accept = <stunnel_port> transparent = destination .Ve .Sp This configuration requires iptables setup to work, possibly in /etc/rc.local or equivalent file. .Sp For a connect target installed on the same host: .Sp .Vb 3 /sbin/iptables -t nat -I OUTPUT -p tcp --dport <redirected_port> \e -m ! --uid-owner <stunnel_user_id> \e -j DNAT --to-destination <local_ip>:<stunnel_port> .Ve .Sp For a connect target installed on a remote host: .Sp .Vb 3 /sbin/iptables -I INPUT -i eth0 -p tcp --dport <stunnel_port> -j ACCEPT /sbin/iptables -t nat -I PREROUTING -p tcp --dport <redirected_port> \e -i eth0 -j DNAT --to-destination <local_ip>:<stunnel_port> .Ve .Sp The transparent destination option is currently only supported on Linux.
"both" 4
Item "both" Use both source and destination transparent proxy.

.Sp Two legacy options are also supported for backward compatibility:

"yes" 4
Item "yes" This option has been renamed to source.
"no" 4
Item "no" This option has been renamed to none.

"verify = \s-1LEVEL\s0" 4
Item "verify = LEVEL" verify the peer certificate .Sp This option is obsolete and should be replaced with the verifyChain and verifyPeer options.

"level 0" 4
Item "level 0" Request and ignore the peer certificate.
"level 1" 4
Item "level 1" Verify the peer certificate if present.
"level 2" 4
Item "level 2" Verify the peer certificate.
"level 3" 4
Item "level 3" Verify the peer against a locally installed certificate.
"level 4" 4
Item "level 4" Ignore the chain and only verify the peer certificate.
"default" 4
Item "default" No verify.

"verifyChain = yes | no" 4
Item "verifyChain = yes | no" verify the peer certificate chain starting from the root \s-1CA\s0 .Sp For server certificate verification it is essential to also require a specific certificate with checkHost or checkIP. .Sp The self-signed root \s-1CA\s0 certificate needs to be stored either in the file specified with CAfile, or in the directory specified with CApath. .Sp default: no
"verifyPeer = yes | no" 4
Item "verifyPeer = yes | no" verify the peer certificate .Sp The peer certificate needs to be stored either in the file specified with CAfile, or in the directory specified with CApath. .Sp default: no
"RETURN VALUE"
Header "RETURN VALUE" \fBstunnel returns zero on success, non-zero on error.
"SIGNALS"
Header "SIGNALS" The following signals can be used to control stunnel in Unix environment:
"\s-1SIGHUP\s0" 4
Item "SIGHUP" Force a reload of the configuration file. .Sp Some global options will not be reloaded:

"\(bu" 4
chroot
"\(bu" 4
foreground
"\(bu" 4
pid
"\(bu" 4
setgid
"\(bu" 4
setuid

.Sp The use of the 'setuid' option will also prevent stunnel from binding to privileged (<1024) ports during configuration reloading. .Sp When the 'chroot' option is used, stunnel will look for all its files (including the configuration file, certificates, the log file and the pid file) within the chroot jail.

"\s-1SIGUSR1\s0" 4
Item "SIGUSR1" Close and reopen the stunnel log file. This function can be used for log rotation.
"\s-1SIGUSR2\s0" 4
Item "SIGUSR2" Log the list of active connections.
"\s-1SIGTERM, SIGQUIT, SIGINT\s0" 4
Item "SIGTERM, SIGQUIT, SIGINT" Shut stunnel down.

The result of sending any other signals to the server is undefined.

"EXAMPLES"
Header "EXAMPLES" In order to provide \s-1TLS\s0 encapsulation to your local imapd service, use:

.Vb 4 [imapd] accept = 993 exec = /usr/sbin/imapd execArgs = imapd .Ve

or in remote mode:

.Vb 3 [imapd] accept = 993 connect = 143 .Ve

In order to let your local e-mail client connect to a TLS-enabled imapd service on another server, configure the e-mail client to connect to localhost on port 119 and use:

.Vb 4 [imap] client = yes accept = 143 connect = servername:993 .Ve

If you want to provide tunneling to your pppd daemon on port 2020, use something like:

.Vb 5 [vpn] accept = 2020 exec = /usr/sbin/pppd execArgs = pppd local pty = yes .Ve

If you want to use stunnel in inetd mode to launch your imapd process, you'd use this stunnel.conf. Note there must be no [service_name] section.

.Vb 2 exec = /usr/sbin/imapd execArgs = imapd .Ve

To setup \s-1SOCKS VPN\s0 configure the following client service:

.Vb 6 [socks_client] client = yes accept = 127.0.0.1:1080 connect = vpn_server:9080 verifyPeer = yes CAfile = stunnel.pem .Ve

The corresponding configuration on the vpn_server host:

.Vb 5 [socks_server] protocol = socks accept = 9080 cert = stunnel.pem key = stunnel.key .Ve

Now test your configuration on the client machine with:

.Vb 1 curl --socks4a localhost http://www.example.com/ .Ve

An example server mode \s-1SNI\s0 configuration:

.Vb 5 [virtual] ; master service accept = 443 cert = default.pem connect = default.internal.mydomain.com:8080 \& [sni1] ; slave service 1 sni = virtual:server1.mydomain.com cert = server1.pem connect = server1.internal.mydomain.com:8081 \& [sni2] ; slave service 2 sni = virtual:server2.mydomain.com cert = server2.pem connect = server2.internal.mydomain.com:8082 verifyPeer = yes CAfile = server2-allowed-clients.pem .Ve

An example of advanced engine configuration allows for authentication with private keys stored in the Windows certificate store (Windows only). With the \s-1CAPI\s0 engine you don't need to manually select the client key to use. The client key is automatically selected based on the list of CAs trusted by the server.

.Vb 1 engine = capi \& [service] engineId = capi client = yes accept = 127.0.0.1:8080 connect = example.com:8443 .Ve

An example of advanced engine configuration to use the certificate and the corresponding private key from a pkcs11 engine:

.Vb 3 engine = pkcs11 engineCtrl = MODULE_PATH:opensc-pkcs11.so engineCtrl = PIN:123456 \& [service] engineId = pkcs11 client = yes accept = 127.0.0.1:8080 connect = example.com:843 cert = pkcs11:token=MyToken;object=MyCert key = pkcs11:token=MyToken;object=MyKey .Ve

An example of advanced engine configuration to use the certificate and the corresponding private key from a SoftHSM token:

.Vb 3 engine = pkcs11 engineCtrl = MODULE_PATH:softhsm2.dll engineCtrl = PIN:12345 \& [service] engineId = pkcs11 client = yes accept = 127.0.0.1:8080 connect = example.com:843 cert = pkcs11:token=MyToken;object=KeyCert .Ve

"NOTES"
Header "NOTES"
"\s-1RESTRICTIONS\s0"
Subsection "RESTRICTIONS" \fBstunnel cannot be used for the \s-1FTP\s0 daemon because of the nature of the \s-1FTP\s0 protocol which utilizes multiple ports for data transfers. There are available TLS-enabled versions of \s-1FTP\s0 and telnet daemons, however.
"\s-1INETD MODE\s0"
Subsection "INETD MODE" The most common use of stunnel is to listen on a network port and establish communication with either a new port via the connect option, or a new program via the exec option. However there is a special case when you wish to have some other program accept incoming connections and launch stunnel, for example with inetd, xinetd, or tcpserver.

For example, if you have the following line in inetd.conf:

.Vb 1 imaps stream tcp nowait root @bindir@/stunnel stunnel @sysconfdir@/stunnel/imaps.conf .Ve

In these cases, the inetd-style program is responsible for binding a network socket (imaps above) and handing it to stunnel when a connection is received. Thus you do not want stunnel to have any accept option. All the Service Level Options should be placed in the global options section, and no [service_name] section will be present. See the \s-1EXAMPLES\s0 section for example configurations.

"\s-1CERTIFICATES\s0"
Subsection "CERTIFICATES" Each TLS-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 OpenSSL package. You can find more information on certificates generation on pages listed below.

The .pem file should contain the unencrypted private key and a signed certificate (not certificate request). So the file should look like this:

.Vb 6 -----BEGIN RSA PRIVATE KEY----- [encoded key] -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- [encoded certificate] -----END CERTIFICATE----- .Ve

"\s-1RANDOMNESS\s0"
Subsection "RANDOMNESS" \fBstunnel needs to seed the \s-1PRNG\s0 (pseudo-random number generator) in order for \s-1TLS\s0 to use good randomness. The following sources are loaded in order until sufficient random data has been gathered:
"\(bu" 4
The file specified with the RNDfile flag.
"\(bu" 4
The file specified by the \s-1RANDFILE\s0 environment variable, if set.
"\(bu" 4
The file .rnd in your home directory, if \s-1RANDFILE\s0 not set.
"\(bu" 4
The file specified with '--with-random' at compile time.
"\(bu" 4
The contents of the screen if running on Windows.
"\(bu" 4
The egd socket specified with the \s-1EGD\s0 flag.
"\(bu" 4
The egd socket specified with '--with-egd-sock' at compile time.
"\(bu" 4
The /dev/urandom device.

Note that on Windows machines that do not have console user interaction (mouse movements, creating windows, etc.) the screen contents are not variable enough to be sufficient, and you should provide a random file for use with the RNDfile flag.

Note that the file specified with the RNDfile flag should contain random data \*(-- that means it should contain different information each time stunnel is run. This is handled automatically unless the RNDoverwrite flag is used. If you wish to update this file manually, the openssl rand command in recent versions of OpenSSL, would be useful.

Important note: If /dev/urandom is available, OpenSSL often seeds the \s-1PRNG\s0 with it while checking the random state. On systems with /dev/urandom \fBOpenSSL is likely to use it even though it is listed at the very bottom of the list above. This is the behaviour of OpenSSL and not stunnel.

"\s-1DH PARAMETERS\s0"
Subsection "DH PARAMETERS" \fBstunnel 4.40 and later contains hardcoded 2048-bit \s-1DH\s0 parameters. Starting with stunnel 5.18, these hardcoded \s-1DH\s0 parameters are replaced every 24 hours with autogenerated temporary \s-1DH\s0 parameters. \s-1DH\s0 parameter generation may take several minutes.

Alternatively, it is possible to specify static \s-1DH\s0 parameters in the certificate file, which disables generating temporary \s-1DH\s0 parameters:

.Vb 1 openssl dhparam 2048 >> stunnel.pem .Ve

"FILES"
Header "FILES"
"\f(CI@sysconfdir@/stunnel/stunnel.conf" 4
Item "@sysconfdir@/stunnel/stunnel.conf" \fBstunnel configuration file
"BUGS"
Header "BUGS" The execArgs option and the Win32 command line do not support quoting.
"SEE ALSO"
Header "SEE ALSO"
"tcpd\|(8)" 4
Item "tcpd" access control facility for internet services
"inetd\|(8)" 4
Item "inetd" internet 'super-server'
"http://www.stunnel.org/" 4
Item "http://www.stunnel.org/" \fBstunnel homepage
"http://www.openssl.org/" 4
Item "http://www.openssl.org/" \fBOpenSSL project website
"AUTHOR"
Header "AUTHOR"
"Michał Trojnara" 4
Item "Michał Trojnara" <Michal.Trojnara@stunnel.org>