.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" 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'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "stunnel 8" .TH stunnel 8 2024.02.15 5.72 "stunnel4 TLS Proxy" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME stunnel \- TLS offloading and load\-balancing proxy .SH SYNOPSIS .IX Header "SYNOPSIS" .IP \fBUnix:\fR 4 .IX Item "Unix:" \&\fBstunnel\fR [FILE] | \-fd\ N | \-help | \-version | \-sockets | \-options .IP \fBWIN32:\fR 4 .IX Item "WIN32:" \&\fBstunnel\fR [ [ \-install | \-uninstall | \-start | \-stop | \-reload | \-reopen | \-exit ] [\-quiet] [FILE] ] | \-help | \-version | \-sockets | \-options .SH DESCRIPTION .IX Header "DESCRIPTION" The \fBstunnel\fR program is designed to work as \fITLS\fR encryption wrapper between remote clients and local (\fIinetd\fR\-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 \fITLS\fR channels. .PP \&\fBstunnel\fR can be used to add \fITLS\fR 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 .IX Header "OPTIONS" .IP \fBFILE\fR 4 .IX Item "FILE" Use specified configuration file .IP "\fB\-fd N\fR (Unix only)" 4 .IX Item "-fd N (Unix only)" Read the config file from specified file descriptor .IP \fB\-help\fR 4 .IX Item "-help" Print \fBstunnel\fR help menu .IP \fB\-version\fR 4 .IX Item "-version" Print \fBstunnel\fR version and compile time defaults .IP \fB\-sockets\fR 4 .IX Item "-sockets" Print default socket options .IP \fB\-options\fR 4 .IX Item "-options" Print supported TLS options .IP "\fB\-install\fR (Windows NT and later only)" 4 .IX Item "-install (Windows NT and later only)" Install NT Service .IP "\fB\-uninstall\fR (Windows NT and later only)" 4 .IX Item "-uninstall (Windows NT and later only)" Uninstall NT Service .IP "\fB\-start\fR (Windows NT and later only)" 4 .IX Item "-start (Windows NT and later only)" Start NT Service .IP "\fB\-stop\fR (Windows NT and later only)" 4 .IX Item "-stop (Windows NT and later only)" Stop NT Service .IP "\fB\-reload\fR (Windows NT and later only)" 4 .IX Item "-reload (Windows NT and later only)" Reload the configuration file of the running NT Service .IP "\fB\-reopen\fR (Windows NT and later only)" 4 .IX Item "-reopen (Windows NT and later only)" Reopen the log file of the running NT Service .IP "\fB\-exit\fR (Win32 only)" 4 .IX Item "-exit (Win32 only)" Exit an already started stunnel .IP "\fB\-quiet\fR (Win32 only)" 4 .IX Item "-quiet (Win32 only)" Don't display any message boxes .SH "CONFIGURATION FILE" .IX Header "CONFIGURATION FILE" Each line of the configuration file can be either: .IP \(bu 4 An empty line (ignored). .IP \(bu 4 A comment starting with ';' (ignored). .IP \(bu 4 An 'option_name = option_value' pair. .IP \(bu 4 \&'[service_name]' indicating a start of a service definition. .PP An address parameter of an option may be either: .IP \(bu 4 A port number. .IP \(bu 4 A colon-separated pair of IP address (either IPv4, IPv6, or domain name) and port number. .IP \(bu 4 A Unix socket path (Unix only). .SS "GLOBAL OPTIONS" .IX Subsection "GLOBAL OPTIONS" .IP "\fBchroot\fR = DIRECTORY (Unix only)" 4 .IX Item "chroot = DIRECTORY (Unix only)" directory to chroot \fBstunnel\fR process .Sp \&\fBchroot\fR keeps \fBstunnel\fR in a chrooted jail. \fICApath\fR, \fICRLpath\fR, \fIpid\fR and \fIexec\fR are located inside the jail and the patches have to be relative to the directory specified with \fBchroot\fR. .Sp Several functions of the operating system also need their files to be located within the chroot jail, e.g.: .RS 4 .IP \(bu 4 Delayed resolver typically needs /etc/nsswitch.conf and /etc/resolv.conf. .IP \(bu 4 Local time in log files needs /etc/timezone. .IP \(bu 4 Some other functions may need devices, e.g. /dev/zero or /dev/null. .RE .RS 4 .RE .IP "\fBcompression\fR = deflate | zlib" 4 .IX Item "compression = deflate | zlib" select data compression algorithm .Sp default: no compression .Sp Deflate is the standard compression method as described in RFC 1951. .IP "\fBdebug\fR = [FACILITY.]LEVEL" 4 .IX 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. .Sp The \fIdebug = debug\fR (or the equivalent ) level produces for the most verbose log output. This logging level is only meant to be understood by stunnel developers, and not by users. Please either use the debug level when requested to do so by an stunnel developer, or when you intend to get confused. .Sp The default logging level is notice (5). .Sp The syslog 'daemon' facility will be used unless a facility name is supplied. (Facilities are not supported on Win32.) .Sp Case is ignored for both facilities and levels. .IP "\fBEGD\fR = EGD_PATH (Unix only)" 4 .IX Item "EGD = EGD_PATH (Unix only)" path to Entropy Gathering Daemon socket .Sp Entropy Gathering Daemon socket to use to feed the \fBOpenSSL\fR random number generator. .IP "\fBengine\fR = auto | ENGINE_ID" 4 .IX 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. .IP "\fBengineCtrl\fR = COMMAND[:PARAMETER]" 4 .IX Item "engineCtrl = COMMAND[:PARAMETER]" control hardware engine .IP "\fBengineDefault\fR = TASK_LIST" 4 .IX 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: ALL, RSA, DSA, ECDH, ECDSA, DH, RAND, CIPHERS, DIGESTS, PKEY, PKEY_CRYPTO, PKEY_ASN1. .IP "\fBfips\fR = yes | no" 4 .IX Item "fips = yes | no" enable or disable FIPS 140\-2 mode. .Sp This option allows you to disable entering FIPS mode if \fBstunnel\fR was compiled with FIPS 140\-2 support. .Sp default: no (since version 5.00) .IP "\fBforeground\fR = yes | quiet | no (Unix only)" 4 .IX Item "foreground = yes | quiet | no (Unix only)" foreground mode .Sp Stay in foreground (don't fork). .Sp With the \fIyes\fR parameter it also logs to stderr in addition to the destinations specified with \fIsyslog\fR and \fIoutput\fR. .Sp default: background in daemon mode .IP "\fBiconActive\fR = ICON_FILE (GUI only)" 4 .IX Item "iconActive = ICON_FILE (GUI only)" GUI 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. .IP "\fBiconError\fR = ICON_FILE (GUI only)" 4 .IX Item "iconError = ICON_FILE (GUI only)" GUI 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. .IP "\fBiconIdle\fR = ICON_FILE (GUI only)" 4 .IX Item "iconIdle = ICON_FILE (GUI only)" GUI 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. .IP "\fBlog\fR = append | overwrite" 4 .IX Item "log = append | overwrite" log file handling .Sp This option allows you to choose whether the log file (specified with the \&\fIoutput\fR option) is appended or overwritten when opened or re-opened. .Sp default: append .IP "\fBoutput\fR = FILE" 4 .IX 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). .IP "\fBpid\fR = FILE (Unix only)" 4 .IX Item "pid = FILE (Unix only)" pid file location .Sp If the argument is empty, then no pid file will be created. .Sp \&\fIpid\fR path is relative to the \fIchroot\fR directory if specified. .IP "\fBRNDbytes\fR = BYTES" 4 .IX Item "RNDbytes = BYTES" bytes to read from random seed files .IP "\fBRNDfile\fR = FILE" 4 .IX 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. .IP "\fBRNDoverwrite\fR = yes | no" 4 .IX Item "RNDoverwrite = yes | no" overwrite the random seed files with new random data .Sp default: yes .IP "\fBservice\fR = SERVICE (Unix only)" 4 .IX Item "service = SERVICE (Unix only)" stunnel service name .Sp The specified service name is used for syslog and as the \fIinetd\fR mode service name for TCP Wrappers. While this option can technically be specified in the service sections, it is only useful in global options. .Sp default: stunnel .IP "\fBsyslog\fR = yes | no (Unix only)" 4 .IX Item "syslog = yes | no (Unix only)" enable logging via syslog .Sp default: yes .IP "\fBtaskbar\fR = yes | no (WIN32 only)" 4 .IX Item "taskbar = yes | no (WIN32 only)" enable the taskbar icon .Sp default: yes .SS "SERVICE-LEVEL OPTIONS" .IX Subsection "SERVICE-LEVEL OPTIONS" Each configuration section begins with a service name in square brackets. The service name is used for libwrap (TCP Wrappers) access control and lets you distinguish \fBstunnel\fR services in your log files. .PP Note that if you wish to run \fBstunnel\fR in \fIinetd\fR mode (where it is provided a network socket by a server such as \fIinetd\fR, \fIxinetd\fR, or \fItcpserver\fR) then you should read the section entitled \fIINETD MODE\fR below. .IP "\fBaccept\fR = [HOST:]PORT" 4 .IX 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 .IP "\fBCAengine\fR = ENGINE\-SPECIFIC_CA_CERTIFICATE_IDENTIFIER" 4 .IX Item "CAengine = ENGINE-SPECIFIC_CA_CERTIFICATE_IDENTIFIER" load a trusted CA certificate from an engine .Sp The loaded CA certificates will be used with the \fIverifyChain\fR and \&\fIverifyPeer\fR options. .Sp Multiple \fICAengine\fR options are allowed in a single service section. .Sp Currently supported engines: pkcs11, cng. .IP "\fBCApath\fR = CA_DIRECTORY" 4 .IX Item "CApath = CA_DIRECTORY" load trusted CA certificates from a directory .Sp The loaded CA certificates will be used with the \fIverifyChain\fR and \&\fIverifyPeer\fR options. Note that the certificates in this directory should be named XXXXXXXX.0 where XXXXXXXX is the hash value of the DER encoded subject of the cert. .Sp The hash algorithm has been changed in \fBOpenSSL 1.0.0\fR. It is required to c_rehash the directory on upgrade from \fBOpenSSL 0.x.x\fR to \fBOpenSSL 1.x.x\fR or later. .Sp \&\fICApath\fR path is relative to the \fIchroot\fR directory if specified. .IP "\fBCAfile\fR = CA_FILE" 4 .IX Item "CAfile = CA_FILE" load trusted CA certificates from a file .Sp The loaded CA certificates will be used with the \fIverifyChain\fR and \&\fIverifyPeer\fR options. .IP "\fBcert\fR = CERT_FILE" 4 .IX Item "cert = CERT_FILE" certificate chain file name .Sp The parameter specifies the file containing certificates used by \fBstunnel\fR 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 CA certificate. The file must be either in PEM 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. .IP "\fBcheckEmail\fR = EMAIL" 4 .IX Item "checkEmail = EMAIL" verify the email address of the end-entity (leaf) peer certificate subject .Sp Certificates are accepted if no subject checks were specified, or the email address of the end-entity (leaf) peer certificate matches any of the email addresses specified with \fIcheckEmail\fR. .Sp Multiple \fIcheckEmail\fR options are allowed in a single service section. .Sp This option requires OpenSSL 1.0.2 or later. .IP "\fBcheckHost\fR = HOST" 4 .IX Item "checkHost = HOST" verify the host of the end-entity (leaf) peer certificate subject .Sp Certificates are accepted if no subject checks were specified, or the host name of the end-entity (leaf) peer certificate matches any of the hosts specified with \fIcheckHost\fR. .Sp Multiple \fIcheckHost\fR options are allowed in a single service section. .Sp This option requires OpenSSL 1.0.2 or later. .IP "\fBcheckIP\fR = IP" 4 .IX Item "checkIP = IP" verify the IP address of the end-entity (leaf) peer certificate subject .Sp Certificates are accepted if no subject checks were specified, or the IP address of the end-entity (leaf) peer certificate matches any of the IP addresses specified with \fIcheckIP\fR. .Sp Multiple \fIcheckIP\fR options are allowed in a single service section. .Sp This option requires OpenSSL 1.0.2 or later. .IP "\fBciphers\fR = CIPHER_LIST" 4 .IX Item "ciphers = CIPHER_LIST" select permitted TLS 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 TLS connection, for example DES\-CBC3\-SHA:IDEA\-CBC\-MD5. .IP "\fBciphersuites\fR = CIPHERSUITES_LIST" 4 .IX 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: TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256 .IP "\fBclient\fR = yes | no" 4 .IX Item "client = yes | no" client mode (remote service uses TLS) .Sp default: no (server mode) .IP "\fBconfig\fR = COMMAND[:PARAMETER]" 4 .IX Item "config = COMMAND[:PARAMETER]" \&\fBOpenSSL\fR configuration command .Sp The \fBOpenSSL\fR 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 \&\fR\f(BISSL_CONF_cmd\fR\fI\|(3ssl)\fR manual page. .Sp Several \fIconfig\fR lines can be used to specify multiple configuration commands. .Sp Use \fIcurves\fR option instead of enabling \fIconfig = Curves:list_curves\fR to support elliptic curves. .Sp This option requires OpenSSL 1.0.2 or later. .IP "\fBconnect\fR = [HOST:]PORT" 4 .IX Item "connect = [HOST:]PORT" connect to a remote address .Sp If no host is specified, the host defaults to localhost. .Sp Multiple \fIconnect\fR options are allowed in a single service section. If host resolves to multiple addresses and/or if multiple \fIconnect\fR options are specified, then the remote address is chosen using a round-robin algorithm. .IP "\fBCRLpath\fR = DIRECTORY" 4 .IX Item "CRLpath = DIRECTORY" Certificate Revocation Lists directory .Sp This is the directory in which \fBstunnel\fR will look for CRLs when using the \&\fIverifyChain\fR and \fIverifyPeer\fR options. Note that the CRLs in this directory should be named XXXXXXXX.r0 where XXXXXXXX is the hash value of the CRL. .Sp The hash algorithm has been changed in \fBOpenSSL 1.0.0\fR. It is required to c_rehash the directory on upgrade from \fBOpenSSL 0.x.x\fR to \fBOpenSSL 1.x.x\fR. .Sp \&\fICRLpath\fR path is relative to the \fIchroot\fR directory if specified. .IP "\fBCRLfile\fR = CRL_FILE" 4 .IX Item "CRLfile = CRL_FILE" Certificate Revocation Lists file .Sp This file contains multiple CRLs, used with the \fIverifyChain\fR and \&\fIverifyPeer\fR options. .IP "\fBcurves\fR = list" 4 .IX Item "curves = list" ECDH 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 .IP "\fBlogId\fR = TYPE" 4 .IX 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: .RS 4 .IP \fIsequential\fR 4 .IX Item "sequential" The numeric sequential identifier is only unique within a single instance of \&\fBstunnel\fR, but very compact. It is most useful for manual log analysis. .IP \fIunique\fR 4 .IX Item "unique" This alphanumeric identifier is globally unique, but longer than the sequential number. It is most useful for automated log analysis. .IP \fIthread\fR 4 .IX Item "thread" The operating system thread identifier is neither unique (even within a single instance of \fBstunnel\fR) nor short. It is most useful for debugging software or configuration issues. .IP \fIprocess\fR 4 .IX Item "process" The operating system process identifier (PID) may be useful in the inetd mode. .RE .RS 4 .Sp default: sequential .RE .IP "\fBdebug\fR = LEVEL" 4 .IX 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 \fIdebug = debug\fR or \fIdebug = 7\fR 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 \fBwill\fR be confusing. .IP "\fBdelay\fR = yes | no" 4 .IX Item "delay = yes | no" delay DNS lookup for the \fIconnect\fR option .Sp This option is useful for dynamic DNS, or when DNS is not available during \&\fBstunnel\fR startup (road warrior VPN, dial-up configurations). .Sp Delayed resolver mode is automatically engaged when stunnel fails to resolve on startup any of the \fIconnect\fR targets for a service. .Sp Delayed resolver inflicts \fIfailover = prio\fR. .Sp default: no .IP "\fBengineId\fR = ENGINE_ID" 4 .IX Item "engineId = ENGINE_ID" select engine ID for the service .IP "\fBengineNum\fR = ENGINE_NUMBER" 4 .IX Item "engineNum = ENGINE_NUMBER" select engine number for the service .Sp The engines are numbered starting from 1. .IP "\fBexec\fR = EXECUTABLE_PATH" 4 .IX Item "exec = EXECUTABLE_PATH" execute a local inetd-type program .Sp \&\fIexec\fR path is relative to the \fIchroot\fR directory if specified. .Sp The following environmental variables are set on Unix platforms: REMOTE_HOST, REMOTE_PORT, SSL_CLIENT_DN, SSL_CLIENT_I_DN. .ie n .IP "\fBexecArgs\fR = $0 $1 $2 ..." 4 .el .IP "\fBexecArgs\fR = \f(CW$0\fR \f(CW$1\fR \f(CW$2\fR ..." 4 .IX Item "execArgs = $0 $1 $2 ..." arguments for \fIexec\fR including the program name ($0) .Sp Quoting is currently not supported. Arguments are separated with an arbitrary amount of whitespace. .IP "\fBfailover\fR = rr | prio" 4 .IX Item "failover = rr | prio" Failover strategy for multiple "connect" targets. .RS 4 .IP \fIrr\fR 4 .IX Item "rr" round robin \- fair load distribution .IP \fIprio\fR 4 .IX Item "prio" priority \- use the order specified in config file .RE .RS 4 .Sp default: prio .RE .IP "\fBident\fR = USERNAME" 4 .IX Item "ident = USERNAME" use IDENT (RFC 1413) username checking .IP "\fBinclude\fR = DIRECTORY" 4 .IX Item "include = DIRECTORY" include all configuration file parts located in DIRECTORY .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 .IP "\fBkey\fR = KEY_FILE" 4 .IX Item "key = KEY_FILE" private key for the certificate specified with \fIcert\fR 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 \fIcert\fR option .IP "\fBlibwrap\fR = yes | no" 4 .IX Item "libwrap = yes | no" Enable or disable the use of /etc/hosts.allow and /etc/hosts.deny. .Sp default: no (since version 5.00) .IP "\fBlocal\fR = HOST" 4 .IX Item "local = HOST" By default, the IP address of the outgoing interface is used as the source for remote connections. Use this option to bind a static local IP address instead. .IP "\fBOCSP\fR = URL" 4 .IX Item "OCSP = URL" select OCSP responder for the end-entity (leaf) peer certificate verification .IP "\fBOCSPaia\fR = yes | no" 4 .IX Item "OCSPaia = yes | no" validate certificates with their AIA OCSP responders .Sp This option enables \fIstunnel\fR to validate certificates with the list of OCSP responder URLs retrieved from their AIA (Authority Information Access) extension. .IP "\fBOCSPflag\fR = OCSP_FLAG" 4 .IX Item "OCSPflag = OCSP_FLAG" specify OCSP responder flag .Sp Several \fIOCSPflag\fR can be used to specify multiple flags. .Sp currently supported flags: NOCERTS, NOINTERN, NOSIGS, NOCHAIN, NOVERIFY, NOEXPLICIT, NOCASIGN, NODELEGATED, NOCHECKS, TRUSTOTHER, RESPID_KEY, NOTIME .IP "\fBOCSPnonce\fR = yes | no" 4 .IX Item "OCSPnonce = yes | no" send and verify the OCSP nonce extension .Sp This option protects the OCSP 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 OCSP responders. .IP "\fBOCSPrequire\fR = yes | no" 4 .IX Item "OCSPrequire = yes | no" require a conclusive OCSP response .Sp Disable this option to allow a connection even though no conclusive OCSP response was retrieved from stapling and a direct request to the OCSP responder. .Sp default: yes .IP "\fBoptions\fR = SSL_OPTIONS" 4 .IX Item "options = SSL_OPTIONS" \&\fBOpenSSL\fR library options .Sp The parameter is the \fBOpenSSL\fR option name as described in the \&\fR\f(BISSL_CTX_set_options\fR\fI\|(3ssl)\fR manual, but without \fISSL_OP_\fR prefix. \&\fIstunnel \-options\fR lists the options found to be allowed in the current combination of \fIstunnel\fR and the \fIOpenSSL\fR library used to build it. .Sp Several \fIoption\fR lines can be used to specify multiple options. An option name can be prepended with a dash ("\-") to disable the option. .Sp For example, for compatibility with the erroneous Eudora TLS 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 \fIsslVersionMax\fR or \fIsslVersionMin\fR option instead of disabling specific TLS protocol versions when compiled with \fBOpenSSL 1.1.0\fR or later. .IP "\fBprotocol\fR = PROTO" 4 .IX Item "protocol = PROTO" application protocol to negotiate TLS .Sp This option enables initial, protocol-specific negotiation of the TLS encryption. The \fIprotocol\fR option should not be used with TLS encryption on a separate port. .Sp Currently supported protocols: .RS 4 .IP \fIcifs\fR 4 .IX Item "cifs" Proprietary (undocummented) extension of CIFS protocol implemented in Samba. Support for this extension was dropped in Samba 3.0.0. .IP \fIcapwin\fR 4 .IX Item "capwin" http://www.capwin.org/ application support .IP \fIcapwinctrl\fR 4 .IX Item "capwinctrl" http://www.capwin.org/ application support .Sp This protocol is only supported in client mode. .IP \fIconnect\fR 4 .IX Item "connect" Based on RFC 2817 \- \fIUpgrading to TLS Within HTTP/1.1\fR, section 5.2 \- \fIRequesting a Tunnel with CONNECT\fR .Sp This protocol is only supported in client mode. .IP \fIimap\fR 4 .IX Item "imap" Based on RFC 2595 \- \fIUsing TLS with IMAP, POP3 and ACAP\fR .IP \fIldap\fR 4 .IX Item "ldap" Based on RFC 2830 \- \fILightweight Directory Access Protocol (v3): Extension for Transport Layer Security\fR .IP \fInntp\fR 4 .IX Item "nntp" Based on RFC 4642 \- \fIUsing Transport Layer Security (TLS) with Network News Transfer Protocol (NNTP)\fR .Sp This protocol is only supported in client mode. .IP \fIpgsql\fR 4 .IX Item "pgsql" Based on \&\fIhttp://www.postgresql.org/docs/8.3/static/protocol\-flow.html#AEN73982\fR .IP \fIpop3\fR 4 .IX Item "pop3" Based on RFC 2449 \- \fIPOP3 Extension Mechanism\fR .IP \fIproxy\fR 4 .IX Item "proxy" Passing of the original client IP address with HAProxy PROXY protocol version 1 \&\fIhttps://www.haproxy.org/download/1.8/doc/proxy\-protocol.txt\fR .IP \fIsmtp\fR 4 .IX Item "smtp" Based on RFC 2487 \- \fISMTP Service Extension for Secure SMTP over TLS\fR .IP \fIsocks\fR 4 .IX Item "socks" SOCKS versions 4, 4a, and 5 are supported. The SOCKS protocol itself is encapsulated within TLS encryption layer to protect the final destination address. .Sp \&\fIhttp://www.openssh.com/txt/socks4.protocol\fR .Sp \&\fIhttp://www.openssh.com/txt/socks4a.protocol\fR .Sp The BIND command of the SOCKS protocol is not supported. The USERID parameter is ignored. .Sp See Examples section for sample configuration files for VPN based on SOCKS encryption. .RE .RS 4 .RE .IP "\fBprotocolAuthentication\fR = AUTHENTICATION" 4 .IX 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'. .IP "\fBprotocolDomain\fR = DOMAIN" 4 .IX Item "protocolDomain = DOMAIN" domain for the protocol negotiations .Sp Currently, this option is only supported in the client-side 'connect' protocol. .IP "\fBprotocolHeader\fR = HEADER" 4 .IX Item "protocolHeader = HEADER" header for the protocol negotiations .Sp Currently, this option is only supported in the client-side 'connect' protocol. .IP "\fBprotocolHost\fR = ADDRESS" 4 .IX Item "protocolHost = ADDRESS" host address for the protocol negotiations .Sp For the 'connect' protocol negotiations, \fIprotocolHost\fR specifies HOST:PORT of the final TLS server to be connected to by the proxy. The proxy server directly connected by \fBstunnel\fR must be specified with the \fIconnect\fR option. .Sp For the 'smtp' protocol negotiations, \fIprotocolHost\fR controls the client SMTP HELO/EHLO value. .IP "\fBprotocolPassword\fR = PASSWORD" 4 .IX Item "protocolPassword = PASSWORD" password for the protocol negotiations .Sp Currently, this option is only supported in the client-side 'connect' and \&'smtp' protocols. .IP "\fBprotocolUsername\fR = USERNAME" 4 .IX Item "protocolUsername = USERNAME" username for the protocol negotiations .Sp Currently, this option is only supported in the client-side 'connect' and \&'smtp' protocols. .IP "\fBPSKidentity\fR = IDENTITY" 4 .IX Item "PSKidentity = IDENTITY" PSK identity for the PSK client .Sp \&\fIPSKidentity\fR can be used on \fBstunnel\fR clients to select the PSK identity used for authentication. This option is ignored in server sections. .Sp default: the first identity specified in the \fIPSKsecrets\fR file. .IP "\fBPSKsecrets\fR = FILE" 4 .IX Item "PSKsecrets = FILE" file with PSK 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. .IP "\fBpty\fR = yes | no (Unix only)" 4 .IX Item "pty = yes | no (Unix only)" allocate a pseudoterminal for 'exec' option .IP "\fBredirect\fR = [HOST:]PORT" 4 .IX Item "redirect = [HOST:]PORT" redirect TLS client connections on certificate-based authentication failures .Sp This option only works in server mode. Some protocol negotiations are also incompatible with the \fIredirect\fR option. .IP "\fBrenegotiation\fR = yes | no" 4 .IX Item "renegotiation = yes | no" support TLS renegotiation .Sp Applications of the TLS 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\fR .Sp Please note that disabling TLS renegotiation does not fully mitigate this issue. .Sp default: yes (if supported by \fBOpenSSL\fR) .IP "\fBreset\fR = yes | no" 4 .IX Item "reset = yes | no" attempt to use the TCP RST flag to indicate an error .Sp This option is not supported on some platforms. .Sp default: yes .IP "\fBretry\fR = yes | no | DELAY" 4 .IX Item "retry = yes | no | DELAY" reconnect a connect+exec section after it was disconnected .Sp The DELAY value specifies the number of milliseconds before retrying. "retry = yes" has the same effect as "retry = 1000". .Sp default: no .IP "\fBsecurityLevel\fR = LEVEL" 4 .IX Item "securityLevel = LEVEL" set the security level .Sp The meaning of each level is described below: .RS 4 .IP "level 0" 4 .IX Item "level 0" Everything is permitted. .IP "level 1" 4 .IX 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 RSA, DSA and DH keys shorter than 1024 bits and ECC keys shorter than 160 bits are prohibited. All export cipher suites are prohibited since they all offer less than 80 bits of security. SSL version 2 is prohibited. Any cipher suite using MD5 for the MAC is also prohibited. .IP "level 2" 4 .IX Item "level 2" Security level set to 112 bits of security. As a result RSA, DSA and DH keys shorter than 2048 bits and ECC keys shorter than 224 bits are prohibited. In addition to the level 1 exclusions any cipher suite using RC4 is also prohibited. SSL version 3 is also not allowed. Compression is disabled. .IP "level 3" 4 .IX Item "level 3" Security level set to 128 bits of security. As a result RSA, DSA and DH keys shorter than 3072 bits and ECC keys shorter than 256 bits are prohibited. In addition to the level 2 exclusions cipher suites not offering forward secrecy are prohibited. TLS versions below 1.1 are not permitted. Session tickets are disabled. .IP "level 4" 4 .IX Item "level 4" Security level set to 192 bits of security. As a result RSA, DSA and DH keys shorter than 7680 bits and ECC keys shorter than 384 bits are prohibited. Cipher suites using SHA1 for the MAC are prohibited. TLS versions below 1.2 are not permitted. .IP "level 5" 4 .IX Item "level 5" Security level set to 256 bits of security. As a result RSA, DSA and DH keys shorter than 15360 bits and ECC keys shorter than 512 bits are prohibited. .IP "default: 2" 4 .IX Item "default: 2" .RE .RS 4 .Sp The \fIsecurityLevel\fR option is only available when compiled with \fBOpenSSL 1.1.0\fR and later. .RE .IP "\fBrequireCert\fR = yes | no" 4 .IX Item "requireCert = yes | no" require a client certificate for \fIverifyChain\fR or \fIverifyPeer\fR .Sp With \fIrequireCert\fR set to \fIno\fR, the \fBstunnel\fR server accepts client connections that did not present a certificate. .Sp Both \fIverifyChain = yes\fR and \fIverifyPeer = yes\fR imply \fIrequireCert = yes\fR. .Sp default: no .IP "\fBsetgid\fR = GROUP (Unix only)" 4 .IX Item "setgid = GROUP (Unix only)" Unix group id .Sp As a global option: \fBsetgid()\fR 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 "accept". .IP "\fBsetuid\fR = USER (Unix only)" 4 .IX Item "setuid = USER (Unix only)" Unix user id .Sp As a global option: \fBsetuid()\fR to the specified user in daemon mode. .Sp As a service-level option: set the owner of the Unix socket specified with "accept". .IP "\fBsessionCacheSize\fR = NUM_ENTRIES" 4 .IX Item "sessionCacheSize = NUM_ENTRIES" session cache size .Sp \&\fIsessionCacheSize\fR 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. .IP "\fBsessionCacheTimeout\fR = TIMEOUT" 4 .IX Item "sessionCacheTimeout = TIMEOUT" session cache timeout .Sp This is the number of seconds to keep cached TLS sessions. .IP "\fBsessionResume\fR = yes | no" 4 .IX Item "sessionResume = yes | no" allow or disallow session resumption .Sp default: yes .IP "\fBsessiond\fR = HOST:PORT" 4 .IX Item "sessiond = HOST:PORT" address of sessiond TLS cache server .IP "\fBsni\fR = SERVICE_NAME:SERVER_NAME_PATTERN (server mode)" 4 .IX Item "sni = SERVICE_NAME:SERVER_NAME_PATTERN (server mode)" Use the service as a secondary service (a name-based virtual server) for Server Name Indication TLS extension (RFC 3546). .Sp \&\fISERVICE_NAME\fR specifies the primary service that accepts client connections with the \fIaccept\fR option. \fISERVER_NAME_PATTERN\fR specifies the host name to be redirected. The pattern may start with the '*' character, e.g. \&'*.example.com'. Multiple secondary services are normally specified for a single primary service. The \fIsni\fR option can also be specified more than once within a single secondary service. .Sp This service, as well as the primary service, may not be configured in client mode. .Sp The \fIconnect\fR option of the secondary service is ignored when the \fIprotocol\fR option is specified, as \fIprotocol\fR connects to the remote host before TLS handshake. .Sp Libwrap checks (Unix only) are performed twice: with the primary service name after TCP connection is accepted, and with the secondary service name during the TLS handshake. .Sp The \fIsni\fR option is only available when compiled with \fBOpenSSL 1.0.0\fR and later. .IP "\fBsni\fR = SERVER_NAME (client mode)" 4 .IX Item "sni = SERVER_NAME (client mode)" Use the parameter as the value of TLS Server Name Indication (RFC 3546) extension. .Sp Empty SERVER_NAME disables sending the SNI extension. .Sp The \fIsni\fR option is only available when compiled with \fBOpenSSL 1.0.0\fR and later. .IP "\fBsocket\fR = a|l|r:OPTION=VALUE[:VALUE]" 4 .IX 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 .IP "\fBsslVersion\fR = SSL_VERSION" 4 .IX Item "sslVersion = SSL_VERSION" select the TLS 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 \fBOpenSSL 1.1.0\fR and later. .IP "\fBsslVersionMax\fR = SSL_VERSION" 4 .IX Item "sslVersionMax = SSL_VERSION" maximum supported protocol versions .Sp Supported versions: all, SSLv3, TLSv1, TLSv1.1, TLSv1.2, TLSv1.3 .Sp \&\fIall\fR 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 \fIsslVersionMax\fR option is only available when compiled with \&\fBOpenSSL 1.1.0\fR and later. .Sp default: all .IP "\fBsslVersionMin\fR = SSL_VERSION" 4 .IX Item "sslVersionMin = SSL_VERSION" minimum supported protocol versions .Sp Supported versions: all, SSLv3, TLSv1, TLSv1.1, TLSv1.2, TLSv1.3 .Sp \&\fIall\fR 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 \fIsslVersionMin\fR option is only available when compiled with \&\fBOpenSSL 1.1.0\fR and later. .Sp default: TLSv1 .IP "\fBstack\fR = BYTES (except for FORK model)" 4 .IX Item "stack = BYTES (except for FORK model)" CPU 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) .IP "\fBticketKeySecret\fR = SECRET" 4 .IX Item "ticketKeySecret = SECRET" hexadecimal symmetric key used for session ticket confidentiality protection .Sp Session tickets defined in RFC 5077 provide an enhanced session resumption capability, where the server-side caching is not required to maintain per session state. .Sp Combining \fIticketKeySecret\fR and \fIticketMacSecret\fR 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 \fIticketKeySecret\fR option is only available when compiled with \&\fBOpenSSL 1.0.0\fR and later. .Sp Disabling \fINO_TICKET\fR option is required for the ticket support in OpenSSL older than 1.1.1, but note that this option is incompatible with the \&\fIredirect\fR option. .IP "\fBticketMacSecret\fR = SECRET" 4 .IX 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 \fIticketMacSecret\fR option is only available when compiled with \&\fBOpenSSL 1.0.0\fR and later. .IP "\fBTIMEOUTbusy\fR = SECONDS" 4 .IX Item "TIMEOUTbusy = SECONDS" time to wait for expected data .IP "\fBTIMEOUTclose\fR = SECONDS" 4 .IX Item "TIMEOUTclose = SECONDS" time to wait for close_notify (set to 0 for buggy MSIE) .IP "\fBTIMEOUTconnect\fR = SECONDS" 4 .IX Item "TIMEOUTconnect = SECONDS" time to wait to connect a remote host .IP "\fBTIMEOUTidle\fR = SECONDS" 4 .IX Item "TIMEOUTidle = SECONDS" time to keep an idle connection .IP "\fBTIMEOUTocsp\fR = SECONDS" 4 .IX Item "TIMEOUTocsp = SECONDS" time to wait to connect an OCSP responder .IP "\fBtransparent\fR = none | source | destination | both (Unix only)" 4 .IX Item "transparent = none | source | destination | both (Unix only)" enable transparent proxy support on selected platforms .Sp Supported values: .RS 4 .IP \fInone\fR 4 .IX Item "none" Disable transparent proxy support. This is the default. .IP \fIsource\fR 4 .IX Item "source" Re-write the address to appear as if a wrapped daemon is connecting from the TLS client machine instead of the machine running \fBstunnel\fR. .Sp This option is currently available in: .RS 4 .IP "Remote mode (\fIconnect\fR option) on \fILinux >=2.6.28\fR" 4 .IX Item "Remote mode (connect option) on Linux >=2.6.28" This configuration requires \fBstunnel\fR to be executed as root and without the \fIsetuid\fR 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\fR must also to be executed as root and without the \fIsetuid\fR option. .IP "Remote mode (\fIconnect\fR option) on \fILinux 2.2.x\fR" 4 .IX Item "Remote mode (connect option) on Linux 2.2.x" This configuration requires the kernel to be compiled with the \fItransparent proxy\fR option. Connected service must be installed on a separate host. Routing towards the clients has to go through the \fBstunnel\fR box. .Sp \&\fBstunnel\fR must also to be executed as root and without the \fIsetuid\fR option. .IP "Remote mode (\fIconnect\fR option) on \fIFreeBSD >=8.0\fR" 4 .IX Item "Remote mode (connect option) on FreeBSD >=8.0" This configuration requires additional firewall and routing setup. \&\fBstunnel\fR must also to be executed as root and without the \fIsetuid\fR option. .IP "Local mode (\fIexec\fR option)" 4 .IX Item "Local mode (exec option)" This configuration works by pre-loading the \fIlibstunnel.so\fR shared library. _RLD_LIST environment variable is used on Tru64, and LD_PRELOAD variable on other platforms. .RE .RS 4 .RE .IP \fIdestination\fR 4 .IX Item "destination" The original destination is used instead of the \fIconnect\fR option. .Sp A service section for transparent destination may look like this: .Sp .Vb 4 \& [transparent] \& client = yes \& accept = \& 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 \e \& \-m ! \-\-uid\-owner \e \& \-j DNAT \-\-to\-destination : .Ve .Sp For a connect target installed on a remote host: .Sp .Vb 3 \& /sbin/iptables \-I INPUT \-i eth0 \-p tcp \-\-dport \-j ACCEPT \& /sbin/iptables \-t nat \-I PREROUTING \-p tcp \-\-dport \e \& \-i eth0 \-j DNAT \-\-to\-destination : .Ve .Sp The transparent destination option is currently only supported on Linux. .IP \fIboth\fR 4 .IX Item "both" Use both \fIsource\fR and \fIdestination\fR transparent proxy. .RE .RS 4 .Sp Two legacy options are also supported for backward compatibility: .IP \fIyes\fR 4 .IX Item "yes" This option has been renamed to \fIsource\fR. .IP \fIno\fR 4 .IX Item "no" This option has been renamed to \fInone\fR. .RE .RS 4 .RE .IP "\fBverify\fR = LEVEL" 4 .IX Item "verify = LEVEL" verify the peer certificate .Sp This option is obsolete and should be replaced with the \fIverifyChain\fR and \fIverifyPeer\fR options. .RS 4 .IP "level 0" 4 .IX Item "level 0" Request and ignore the peer certificate chain. .IP "level 1" 4 .IX Item "level 1" Verify the peer certificate chain if present. .IP "level 2" 4 .IX Item "level 2" Verify the peer certificate chain. .IP "level 3" 4 .IX Item "level 3" Verify the peer certificate chain and the end-entity (leaf) peer certificate against a locally installed certificate. .IP "level 4" 4 .IX Item "level 4" Ignore the peer certificate chain and only verify the end-entity (leaf) peer certificate against a locally installed certificate. .IP default 4 .IX Item "default" No verify. .RE .RS 4 .RE .IP "\fBverifyChain\fR = yes | no" 4 .IX Item "verifyChain = yes | no" verify the peer certificate chain starting from the root CA .Sp For server certificate verification it is essential to also require a specific certificate with \fIcheckHost\fR or \fIcheckIP\fR. .Sp The self-signed root CA certificate needs to be stored either in the file specified with \fICAfile\fR, or in the directory specified with \fICApath\fR. .Sp default: no .IP "\fBverifyPeer\fR = yes | no" 4 .IX Item "verifyPeer = yes | no" verify the end-entity (leaf) peer certificate .Sp The end-entity (leaf) peer certificate needs to be stored either in the file specified with \fICAfile\fR, or in the directory specified with \fICApath\fR. .Sp default: no .SH "RETURN VALUE" .IX Header "RETURN VALUE" \&\fBstunnel\fR returns zero on success, non-zero on error. .SH SIGNALS .IX Header "SIGNALS" The following signals can be used to control \fBstunnel\fR in Unix environment: .IP SIGHUP 4 .IX Item "SIGHUP" Force a reload of the configuration file. .Sp Some global options will not be reloaded: .RS 4 .IP \(bu 4 chroot .IP \(bu 4 foreground .IP \(bu 4 pid .IP \(bu 4 setgid .IP \(bu 4 setuid .RE .RS 4 .Sp The use of the 'setuid' option will also prevent \fBstunnel\fR from binding to privileged (<1024) ports during configuration reloading. .Sp When the 'chroot' option is used, \fBstunnel\fR will look for all its files (including the configuration file, certificates, the log file and the pid file) within the chroot jail. .RE .IP SIGUSR1 4 .IX Item "SIGUSR1" Close and reopen the \fBstunnel\fR log file. This function can be used for log rotation. .IP SIGUSR2 4 .IX Item "SIGUSR2" Log the list of active connections. .IP "SIGTERM, SIGQUIT, SIGINT" 4 .IX Item "SIGTERM, SIGQUIT, SIGINT" Shut \fBstunnel\fR down. .PP The result of sending any other signals to the server is undefined. .SH EXAMPLES .IX Header "EXAMPLES" In order to provide TLS encapsulation to your local \fIimapd\fR service, use: .PP .Vb 4 \& [imapd] \& accept = 993 \& exec = /usr/sbin/imapd \& execArgs = imapd .Ve .PP or in remote mode: .PP .Vb 3 \& [imapd] \& accept = 993 \& connect = 143 .Ve .PP In order to let your local e\-mail client connect to a TLS-enabled \fIimapd\fR service on another server, configure the e\-mail client to connect to localhost on port 119 and use: .PP .Vb 4 \& [imap] \& client = yes \& accept = 143 \& connect = servername:993 .Ve .PP If you want to provide tunneling to your \fIpppd\fR daemon on port 2020, use something like: .PP .Vb 5 \& [vpn] \& accept = 2020 \& exec = /usr/sbin/pppd \& execArgs = pppd local \& pty = yes .Ve .PP If you want to use \fBstunnel\fR in \fIinetd\fR mode to launch your imapd process, you'd use this \fIstunnel.conf\fR. Note there must be no \fI[service_name]\fR section. .PP .Vb 2 \& exec = /usr/sbin/imapd \& execArgs = imapd .Ve .PP To setup SOCKS VPN configure the following client service: .PP .Vb 6 \& [socks_client] \& client = yes \& accept = 127.0.0.1:1080 \& connect = vpn_server:9080 \& verifyPeer = yes \& CAfile = stunnel.pem .Ve .PP The corresponding configuration on the vpn_server host: .PP .Vb 5 \& [socks_server] \& protocol = socks \& accept = 9080 \& cert = stunnel.pem \& key = stunnel.key .Ve .PP Now test your configuration on the client machine with: .PP .Vb 1 \& curl \-\-socks4a localhost http://www.example.com/ .Ve .PP An example server mode SNI configuration: .PP .Vb 5 \& [virtual] \& ; primary service \& accept = 443 \& cert = default.pem \& connect = default.internal.mydomain.com:8080 \& \& [sni1] \& ; secondary service 1 \& sni = virtual:server1.mydomain.com \& cert = server1.pem \& connect = server1.internal.mydomain.com:8081 \& \& [sni2] \& ; secondary service 2 \& sni = virtual:server2.mydomain.com \& cert = server2.pem \& connect = server2.internal.mydomain.com:8082 \& verifyPeer = yes \& CAfile = server2\-allowed\-clients.pem .Ve .PP An example of advanced engine configuration allows for authentication with private keys stored in the Windows certificate store (Windows only). With the CAPI 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. .PP .Vb 1 \& engine = capi \& \& [service] \& engineId = capi \& client = yes \& accept = 127.0.0.1:8080 \& connect = example.com:8443 .Ve .PP An example of advanced engine configuration to use the certificate and the corresponding private key from a pkcs11 engine: .PP .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 .PP An example of advanced engine configuration to use the certificate and the corresponding private key from a SoftHSM token: .PP .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 .SH NOTES .IX Header "NOTES" .SS RESTRICTIONS .IX Subsection "RESTRICTIONS" \&\fBstunnel\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 TLS-enabled versions of FTP and telnet daemons, however. .SS "INETD MODE" .IX Subsection "INETD MODE" The most common use of \fBstunnel\fR 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 \fIexec\fR option. However there is a special case when you wish to have some other program accept incoming connections and launch \fBstunnel\fR, for example with \fIinetd\fR, \fIxinetd\fR, or \fItcpserver\fR. .PP For example, if you have the following line in \fIinetd.conf\fR: .PP .Vb 1 \& imaps stream tcp nowait root /usr/bin/stunnel stunnel /etc/stunnel/imaps.conf .Ve .PP In these cases, the \fIinetd\fR\-style program is responsible for binding a network socket (\fIimaps\fR above) and handing it to \fBstunnel\fR when a connection is received. Thus you do not want \fBstunnel\fR to have any \fIaccept\fR option. All the \fIService Level Options\fR should be placed in the global options section, and no \fI[service_name]\fR section will be present. See the \fIEXAMPLES\fR section for example configurations. .SS CERTIFICATES .IX 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 \fBOpenSSL\fR package. You can find more information on certificates generation on pages listed below. .PP The \fI.pem\fR file should contain the unencrypted private key and a signed certificate (not certificate request). So the file should look like this: .PP .Vb 6 \& \-\-\-\-\-BEGIN RSA PRIVATE KEY\-\-\-\-\- \& [encoded key] \& \-\-\-\-\-END RSA PRIVATE KEY\-\-\-\-\- \& \-\-\-\-\-BEGIN CERTIFICATE\-\-\-\-\- \& [encoded certificate] \& \-\-\-\-\-END CERTIFICATE\-\-\-\-\- .Ve .SS RANDOMNESS .IX Subsection "RANDOMNESS" \&\fBstunnel\fR needs to seed the PRNG (pseudo-random number generator) in order for TLS to use good randomness. The following sources are loaded in order until sufficient random data has been gathered: .IP \(bu 4 The file specified with the \fIRNDfile\fR flag. .IP \(bu 4 The file specified by the RANDFILE environment variable, if set. .IP \(bu 4 The file .rnd in your home directory, if RANDFILE not set. .IP \(bu 4 The file specified with '\-\-with\-random' at compile time. .IP \(bu 4 The contents of the screen if running on Windows. .IP \(bu 4 The egd socket specified with the \fIEGD\fR flag. .IP \(bu 4 The egd socket specified with '\-\-with\-egd\-sock' at compile time. .IP \(bu 4 The /dev/urandom device. .PP 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 \fIRNDfile\fR flag. .PP Note that the file specified with the \fIRNDfile\fR flag should contain random data \-\- that means it should contain different information each time \fBstunnel\fR is run. This is handled automatically unless the \fIRNDoverwrite\fR flag is used. If you wish to update this file manually, the \fIopenssl rand\fR command in recent versions of \fBOpenSSL\fR, would be useful. .PP Important note: If /dev/urandom is available, \fBOpenSSL\fR often seeds the PRNG with it while checking the random state. On systems with /dev/urandom \&\fBOpenSSL\fR is likely to use it even though it is listed at the very bottom of the list above. This is the behaviour of \fBOpenSSL\fR and not \fBstunnel\fR. .SS "DH PARAMETERS" .IX Subsection "DH PARAMETERS" \&\fBstunnel\fR 4.40 and later contains hardcoded 2048\-bit DH parameters. Starting with \fBstunnel\fR 5.18, these hardcoded DH parameters are replaced every 24 hours with autogenerated temporary DH parameters. DH parameter generation may take several minutes. .PP Alternatively, it is possible to specify static DH parameters in the certificate file, which disables generating temporary DH parameters: .PP .Vb 1 \& openssl dhparam 2048 >> stunnel.pem .Ve .SH FILES .IX Header "FILES" .ie n .IP \fR\fI@sysconfdir\fR\fI@/stunnel/stunnel.conf\fR 4 .el .IP \fR\f(CI@sysconfdir\fR\fI@/stunnel/stunnel.conf\fR 4 .IX Item "/etc/stunnel/stunnel.conf" \&\fBstunnel\fR configuration file .SH BUGS .IX Header "BUGS" The \fIexecArgs\fR option and the Win32 command line do not support quoting. .SH "SEE ALSO" .IX Header "SEE ALSO" .IP \fBtcpd\fR\|(8) 4 .IX Item "tcpd" access control facility for internet services .IP \fBinetd\fR\|(8) 4 .IX Item "inetd" internet 'super\-server' .IP \fIhttp://www.stunnel.org/\fR 4 .IX Item "http://www.stunnel.org/" \&\fBstunnel\fR homepage .IP \fIhttp://www.openssl.org/\fR 4 .IX Item "http://www.openssl.org/" \&\fBOpenSSL\fR project website .SH AUTHOR .IX Header "AUTHOR" .IP "Michał Trojnara" 4 .IX Item "Michał Trojnara" <\fIMichal.Trojnara@stunnel.org\fR>