1stunnel(8) stunnel TLS Proxy stunnel(8)
2
3
4
6 stunnel - TLS offloading and load-balancing proxy
7
9 Unix:
10 stunnel [FILE] | -fd N | -help | -version | -sockets | -options
11
12 WIN32:
13 stunnel [ [ -install | -uninstall | -start | -stop |
14 -reload | -reopen | -exit ] [-quiet] [FILE] ] |
15 -help | -version | -sockets | -options
16
18 The stunnel program is designed to work as TLS encryption wrapper
19 between remote clients and local (inetd-startable) or remote servers.
20 The concept is that having non-TLS aware daemons running on your system
21 you can easily set them up to communicate with clients over secure TLS
22 channels.
23
24 stunnel can be used to add TLS functionality to commonly used Inetd
25 daemons like POP-2, POP-3, and IMAP servers, to standalone daemons like
26 NNTP, SMTP and HTTP, and in tunneling PPP over network sockets without
27 changes to the source code.
28
29 This product includes cryptographic software written by Eric Young
30 (eay@cryptsoft.com)
31
33 FILE
34 Use specified configuration file
35
36 -fd N (Unix only)
37 Read the config file from specified file descriptor
38
39 -help
40 Print stunnel help menu
41
42 -version
43 Print stunnel version and compile time defaults
44
45 -sockets
46 Print default socket options
47
48 -options
49 Print supported TLS options
50
51 -install (Windows NT and later only)
52 Install NT Service
53
54 -uninstall (Windows NT and later only)
55 Uninstall NT Service
56
57 -start (Windows NT and later only)
58 Start NT Service
59
60 -stop (Windows NT and later only)
61 Stop NT Service
62
63 -reload (Windows NT and later only)
64 Reload the configuration file of the running NT Service
65
66 -reopen (Windows NT and later only)
67 Reopen the log file of the running NT Service
68
69 -exit (Win32 only)
70 Exit an already started stunnel
71
72 -quiet (Win32 only)
73 Don't display any message boxes
74
76 Each line of the configuration file can be either:
77
78 · An empty line (ignored).
79
80 · A comment starting with ';' (ignored).
81
82 · An 'option_name = option_value' pair.
83
84 · '[service_name]' indicating a start of a service definition.
85
86 An address parameter of an option may be either:
87
88 · A port number.
89
90 · A colon-separated pair of IP address (either IPv4, IPv6, or domain
91 name) and port number.
92
93 · A Unix socket path (Unix only).
94
95 GLOBAL OPTIONS
96 chroot = DIRECTORY (Unix only)
97 directory to chroot stunnel process
98
99 chroot keeps stunnel in a chrooted jail. CApath, CRLpath, pid and
100 exec are located inside the jail and the patches have to be
101 relative to the directory specified with chroot.
102
103 Several functions of the operating system also need their files to
104 be located within the chroot jail, e.g.:
105
106 · Delayed resolver typically needs /etc/nsswitch.conf and
107 /etc/resolv.conf.
108
109 · Local time in log files needs /etc/timezone.
110
111 · Some other functions may need devices, e.g. /dev/zero or
112 /dev/null.
113
114 compression = deflate | zlib
115 select data compression algorithm
116
117 default: no compression
118
119 Deflate is the standard compression method as described in RFC
120 1951.
121
122 debug = [FACILITY.]LEVEL
123 debugging level
124
125 Level is one of the syslog level names or numbers emerg (0), alert
126 (1), crit (2), err (3), warning (4), notice (5), info (6), or debug
127 (7). All logs for the specified level and all levels numerically
128 less than it will be shown. Use debug = debug or debug = 7 for
129 greatest debugging output. The default is notice (5).
130
131 The syslog facility 'authpriv' will be used unless a facility name
132 is supplied. (Facilities are not supported on Win32.)
133
134 Case is ignored for both facilities and levels.
135
136 EGD = EGD_PATH (Unix only)
137 path to Entropy Gathering Daemon socket
138
139 Entropy Gathering Daemon socket to use to feed the OpenSSL random
140 number generator.
141
142 engine = auto | ENGINE_ID
143 select hardware or software cryptographic engine
144
145 default: software-only cryptography
146
147 See Examples section for an engine configuration to use the
148 certificate and the corresponding private key from a cryptographic
149 device.
150
151 engineCtrl = COMMAND[:PARAMETER]
152 control hardware engine
153
154 engineDefault = TASK_LIST
155 set OpenSSL tasks delegated to the current engine
156
157 The parameter specifies a comma-separated list of task to be
158 delegated to the current engine.
159
160 The following tasks may be available, if supported by the engine:
161 ALL, RSA, DSA, ECDH, ECDSA, DH, RAND, CIPHERS, DIGESTS, PKEY,
162 PKEY_CRYPTO, PKEY_ASN1.
163
164 fips = yes | no
165 enable or disable FIPS 140-2 mode.
166
167 This option allows you to disable entering FIPS mode if stunnel was
168 compiled with FIPS 140-2 support.
169
170 default: no (since version 5.00)
171
172 foreground = yes | quiet | no (Unix only)
173 foreground mode
174
175 Stay in foreground (don't fork).
176
177 With the yes parameter it also logs to stderr in addition to the
178 destinations specified with syslog and output.
179
180 default: background in daemon mode
181
182 iconActive = ICON_FILE (GUI only)
183 GUI icon to be displayed when there are established connections
184
185 On Windows platform the parameter should be an .ico file containing
186 a 16x16 pixel image.
187
188 iconError = ICON_FILE (GUI only)
189 GUI icon to be displayed when no valid configuration is loaded
190
191 On Windows platform the parameter should be an .ico file containing
192 a 16x16 pixel image.
193
194 iconIdle = ICON_FILE (GUI only)
195 GUI icon to be displayed when there are no established connections
196
197 On Windows platform the parameter should be an .ico file containing
198 a 16x16 pixel image.
199
200 log = append | overwrite
201 log file handling
202
203 This option allows you to choose whether the log file (specified
204 with the output option) is appended or overwritten when opened or
205 re-opened.
206
207 default: append
208
209 output = FILE
210 append log messages to a file
211
212 /dev/stdout device can be used to send log messages to the standard
213 output (for example to log them with daemontools splogger).
214
215 pid = FILE (Unix only)
216 pid file location
217
218 If the argument is empty, then no pid file will be created.
219
220 pid path is relative to the chroot directory if specified.
221
222 RNDbytes = BYTES
223 bytes to read from random seed files
224
225 RNDfile = FILE
226 path to file with random seed data
227
228 The OpenSSL library will use data from this file first to seed the
229 random number generator.
230
231 RNDoverwrite = yes | no
232 overwrite the random seed files with new random data
233
234 default: yes
235
236 service = SERVICE (Unix only)
237 stunnel service name
238
239 The specified service name is used for syslog and as the inetd mode
240 service name for TCP Wrappers. While this option can technically
241 be specified in the service sections, it is only useful in global
242 options.
243
244 default: stunnel
245
246 syslog = yes | no (Unix only)
247 enable logging via syslog
248
249 default: yes
250
251 taskbar = yes | no (WIN32 only)
252 enable the taskbar icon
253
254 default: yes
255
256 SERVICE-LEVEL OPTIONS
257 Each configuration section begins with a service name in square
258 brackets. The service name is used for libwrap (TCP Wrappers) access
259 control and lets you distinguish stunnel services in your log files.
260
261 Note that if you wish to run stunnel in inetd mode (where it is
262 provided a network socket by a server such as inetd, xinetd, or
263 tcpserver) then you should read the section entitled INETD MODE below.
264
265 accept = [HOST:]PORT
266 accept connections on specified address
267
268 If no host specified, defaults to all IPv4 addresses for the local
269 host.
270
271 To listen on all IPv6 addresses use:
272
273 accept = :::PORT
274
275 CApath = DIRECTORY
276 Certificate Authority directory
277
278 This is the directory in which stunnel will look for certificates
279 when using the verifyChain or verifyPeer options. Note that the
280 certificates in this directory should be named XXXXXXXX.0 where
281 XXXXXXXX is the hash value of the DER encoded subject of the cert.
282
283 The hash algorithm has been changed in OpenSSL 1.0.0. It is
284 required to c_rehash the directory on upgrade from OpenSSL 0.x.x to
285 OpenSSL 1.x.x.
286
287 CApath path is relative to the chroot directory if specified.
288
289 CAfile = CA_FILE
290 Certificate Authority file
291
292 This file contains multiple CA certificates, to be used with the
293 verifyChain and verifyPeer options.
294
295 cert = CERT_FILE
296 certificate chain file name
297
298 The parameter specifies the file containing certificates used by
299 stunnel to authenticate itself against the remote client or server.
300 The file should contain the whole certificate chain starting from
301 the actual server/client certificate, and ending with the self-
302 signed root CA certificate. The file must be either in PEM or P12
303 format.
304
305 A certificate chain is required in server mode, and optional in
306 client mode.
307
308 This parameter is also used as the certificate identifier when a
309 hardware engine is enabled.
310
311 checkEmail = EMAIL
312 email address of the peer certificate subject
313
314 Multiple checkEmail options are allowed in a single service
315 section. Certificates are accepted if no subject checks were
316 specified, or the email address of the peer certificate matches any
317 of the email addresses specified with checkEmail.
318
319 This option requires OpenSSL 1.0.2 or later.
320
321 checkHost = HOST
322 host of the peer certificate subject
323
324 Multiple checkHost options are allowed in a single service section.
325 Certificates are accepted if no subject checks were specified, or
326 the host name of the peer certificate matches any of the hosts
327 specified with checkHost.
328
329 This option requires OpenSSL 1.0.2 or later.
330
331 checkIP = IP
332 IP address of the peer certificate subject
333
334 Multiple checkIP options are allowed in a single service section.
335 Certificates are accepted if no subject checks were specified, or
336 the IP address of the peer certificate matches any of the IP
337 addresses specified with checkIP.
338
339 This option requires OpenSSL 1.0.2 or later.
340
341 ciphers = CIPHER_LIST
342 select permitted TLS ciphers (TLSv1.2 and below)
343
344 This option does not impact TLSv1.3 ciphersuites.
345
346 A colon-delimited list of the ciphers to allow in the TLS
347 connection, for example DES-CBC3-SHA:IDEA-CBC-MD5.
348
349 ciphersuites = CIPHERSUITES_LIST
350 select permitted TLSv1.3 ciphersuites
351
352 A colon-delimited list of TLSv1.3 ciphersuites names in order of
353 preference.
354
355 This option requires OpenSSL 1.1.1 or later.
356
357 default:
358 TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256
359
360 client = yes | no
361 client mode (remote service uses TLS)
362
363 default: no (server mode)
364
365 config = COMMAND[:PARAMETER]
366 OpenSSL configuration command
367
368 The OpenSSL configuration command is executed with the specified
369 parameter. This allows any configuration commands to be invoked
370 from the stunnel configuration file. Supported commands are
371 described on the SSL_CONF_cmd(3ssl) manual page.
372
373 Several config lines can be used to specify multiple configuration
374 commands.
375
376 This option requires OpenSSL 1.0.2 or later.
377
378 connect = [HOST:]PORT
379 connect to a remote address
380
381 If no host is specified, the host defaults to localhost.
382
383 Multiple connect options are allowed in a single service section.
384
385 If host resolves to multiple addresses and/or if multiple connect
386 options are specified, then the remote address is chosen using a
387 round-robin algorithm.
388
389 CRLpath = DIRECTORY
390 Certificate Revocation Lists directory
391
392 This is the directory in which stunnel will look for CRLs when
393 using the verifyChain and verifyPeer options. Note that the CRLs in
394 this directory should be named XXXXXXXX.r0 where XXXXXXXX is the
395 hash value of the CRL.
396
397 The hash algorithm has been changed in OpenSSL 1.0.0. It is
398 required to c_rehash the directory on upgrade from OpenSSL 0.x.x to
399 OpenSSL 1.x.x.
400
401 CRLpath path is relative to the chroot directory if specified.
402
403 CRLfile = CRL_FILE
404 Certificate Revocation Lists file
405
406 This file contains multiple CRLs, used with the verifyChain and
407 verifyPeer options.
408
409 curves = list
410 ECDH curves separated with ':'
411
412 Only a single curve name is allowed for OpenSSL older than 1.1.0.
413
414 To get a list of supported curves use:
415
416 openssl ecparam -list_curves
417
418 default:
419
420 X25519:P-256:X448:P-521:P-384 (OpenSSL 1.1.1 or later)
421
422 prime256v1 (OpenSSL older than 1.1.1)
423
424 logId = TYPE
425 connection identifier type
426
427 This identifier allows you to distinguish log entries generated for
428 each of the connections.
429
430 Currently supported types:
431
432 sequential
433 The numeric sequential identifier is only unique within a
434 single instance of stunnel, but very compact. It is most
435 useful for manual log analysis.
436
437 unique
438 This alphanumeric identifier is globally unique, but longer
439 than the sequential number. It is most useful for automated
440 log analysis.
441
442 thread
443 The operating system thread identifier is neither unique (even
444 within a single instance of stunnel) nor short. It is most
445 useful for debugging software or configuration issues.
446
447 process
448 The operating system process identifier (PID) may be useful in
449 the inetd mode.
450
451 default: sequential
452
453 debug = LEVEL
454 debugging level
455
456 Level is a one of the syslog level names or numbers emerg (0),
457 alert (1), crit (2), err (3), warning (4), notice (5), info (6), or
458 debug (7). All logs for the specified level and all levels
459 numerically less than it will be shown. Use debug = debug or debug
460 = 7 for greatest debugging output. The default is notice (5).
461
462 delay = yes | no
463 delay DNS lookup for the connect option
464
465 This option is useful for dynamic DNS, or when DNS is not available
466 during stunnel startup (road warrior VPN, dial-up configurations).
467
468 Delayed resolver mode is automatically engaged when stunnel fails
469 to resolve on startup any of the connect targets for a service.
470
471 Delayed resolver inflicts failover = prio.
472
473 default: no
474
475 engineId = ENGINE_ID
476 select engine ID for the service
477
478 engineNum = ENGINE_NUMBER
479 select engine number for the service
480
481 The engines are numbered starting from 1.
482
483 exec = EXECUTABLE_PATH
484 execute a local inetd-type program
485
486 exec path is relative to the chroot directory if specified.
487
488 The following environmental variables are set on Unix platforms:
489 REMOTE_HOST, REMOTE_PORT, SSL_CLIENT_DN, SSL_CLIENT_I_DN.
490
491 execArgs = $0 $1 $2 ...
492 arguments for exec including the program name ($0)
493
494 Quoting is currently not supported. Arguments are separated with
495 an arbitrary amount of whitespace.
496
497 failover = rr | prio
498 Failover strategy for multiple "connect" targets.
499
500 rr round robin - fair load distribution
501
502 prio
503 priority - use the order specified in config file
504
505 default: prio
506
507 ident = USERNAME
508 use IDENT (RFC 1413) username checking
509
510 include = DIRECTORY
511 include all configuration file parts located in DIRECTORY
512
513 The files are included in the ascending alphabetical order of their
514 names. The recommended filename convention is
515
516 for global options:
517
518 00-global.conf
519
520 for local service-level options:
521
522 01-service.conf
523
524 02-service.conf
525
526 key = KEY_FILE
527 private key for the certificate specified with cert option
528
529 A private key is needed to authenticate the certificate owner.
530 Since this file should be kept secret it should only be readable by
531 its owner. On Unix systems you can use the following command:
532
533 chmod 600 keyfile
534
535 This parameter is also used as the private key identifier when a
536 hardware engine is enabled.
537
538 default: the value of the cert option
539
540 libwrap = yes | no
541 Enable or disable the use of /etc/hosts.allow and /etc/hosts.deny.
542
543 default: no (since version 5.00)
544
545 local = HOST
546 By default, the IP address of the outgoing interface is used as the
547 source for remote connections. Use this option to bind a static
548 local IP address instead.
549
550 OCSP = URL
551 select OCSP responder for certificate verification
552
553 OCSPaia = yes | no
554 validate certificates with their AIA OCSP responders
555
556 This option enables stunnel to validate certificates with the list
557 of OCSP responder URLs retrieved from their AIA (Authority
558 Information Access) extension.
559
560 OCSPflag = OCSP_FLAG
561 specify OCSP responder flag
562
563 Several OCSPflag can be used to specify multiple flags.
564
565 currently supported flags: NOCERTS, NOINTERN, NOSIGS, NOCHAIN,
566 NOVERIFY, NOEXPLICIT, NOCASIGN, NODELEGATED, NOCHECKS, TRUSTOTHER,
567 RESPID_KEY, NOTIME
568
569 OCSPnonce = yes | no
570 send and verify the OCSP nonce extension
571
572 This option protects the OCSP protocol against replay attacks. Due
573 to its computational overhead, the nonce extension is usually only
574 supported on internal (e.g. corporate) responders, and not on
575 public OCSP responders.
576
577 options = SSL_OPTIONS
578 OpenSSL library options
579
580 The parameter is the OpenSSL option name as described in the
581 SSL_CTX_set_options(3ssl) manual, but without SSL_OP_ prefix.
582 stunnel -options lists the options found to be allowed in the
583 current combination of stunnel and the OpenSSL library used to
584 build it.
585
586 Several option lines can be used to specify multiple options. An
587 option name can be prepended with a dash ("-") to disable the
588 option.
589
590 For example, for compatibility with the erroneous Eudora TLS
591 implementation, the following option can be used:
592
593 options = DONT_INSERT_EMPTY_FRAGMENTS
594
595 default:
596
597 options = NO_SSLv2
598 options = NO_SSLv3
599
600 Use sslVersionMax or sslVersionMin option instead of disabling
601 specific TLS protocol versions when compiled with OpenSSL 1.1.0 or
602 later.
603
604 protocol = PROTO
605 application protocol to negotiate TLS
606
607 This option enables initial, protocol-specific negotiation of the
608 TLS encryption. The protocol option should not be used with TLS
609 encryption on a separate port.
610
611 Currently supported protocols:
612
613 cifs
614 Proprietary (undocummented) extension of CIFS protocol
615 implemented in Samba. Support for this extension was dropped
616 in Samba 3.0.0.
617
618 connect
619 Based on RFC 2817 - Upgrading to TLS Within HTTP/1.1, section
620 5.2 - Requesting a Tunnel with CONNECT
621
622 This protocol is only supported in client mode.
623
624 imap
625 Based on RFC 2595 - Using TLS with IMAP, POP3 and ACAP
626
627 nntp
628 Based on RFC 4642 - Using Transport Layer Security (TLS) with
629 Network News Transfer Protocol (NNTP)
630
631 This protocol is only supported in client mode.
632
633 pgsql
634 Based on
635 http://www.postgresql.org/docs/8.3/static/protocol-flow.html#AEN73982
636
637 pop3
638 Based on RFC 2449 - POP3 Extension Mechanism
639
640 proxy
641 Passing of the original client IP with HAProxy PROXY protocol
642 version 1
643 https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt
644
645 smtp
646 Based on RFC 2487 - SMTP Service Extension for Secure SMTP over
647 TLS
648
649 socks
650 SOCKS versions 4, 4a, and 5 are supported. The SOCKS protocol
651 itself is encapsulated within TLS encryption layer to protect
652 the final destination address.
653
654 http://www.openssh.com/txt/socks4.protocol
655
656 http://www.openssh.com/txt/socks4a.protocol
657
658 The BIND command of the SOCKS protocol is not supported. The
659 USERID parameter is ignored.
660
661 See Examples section for sample configuration files for VPN
662 based on SOCKS encryption.
663
664 protocolAuthentication = AUTHENTICATION
665 authentication type for the protocol negotiations
666
667 Currently, this option is only supported in the client-side
668 'connect' and 'smtp' protocols.
669
670 Supported authentication types for the 'connect' protocol are
671 'basic' or 'ntlm'. The default 'connect' authentication type is
672 'basic'.
673
674 Supported authentication types for the 'smtp' protocol are 'plain'
675 or 'login'. The default 'smtp' authentication type is 'plain'.
676
677 protocolDomain = DOMAIN
678 domain for the protocol negotiations
679
680 Currently, this option is only supported in the client-side
681 'connect' protocol.
682
683 protocolHost = HOST:PORT
684 destination address for the protocol negotiations
685
686 protocolHost specifies the final TLS server to be connected to by
687 the proxy, and not the proxy server directly connected by stunnel.
688 The proxy server should be specified with the 'connect' option.
689
690 Currently the protocol destination address only applies to the
691 'connect' protocol.
692
693 protocolPassword = PASSWORD
694 password for the protocol negotiations
695
696 Currently, this option is only supported in the client-side
697 'connect' and 'smtp' protocols.
698
699 protocolUsername = USERNAME
700 username for the protocol negotiations
701
702 Currently, this option is only supported in the client-side
703 'connect' and 'smtp' protocols.
704
705 PSKidentity = IDENTITY
706 PSK identity for the PSK client
707
708 PSKidentity can be used on stunnel clients to select the PSK
709 identity used for authentication. This option is ignored in server
710 sections.
711
712 default: the first identity specified in the PSKsecrets file.
713
714 PSKsecrets = FILE
715 file with PSK identities and corresponding keys
716
717 Each line of the file in the following format:
718
719 IDENTITY:KEY
720
721 Hexadecimal keys are automatically converted to binary form. Keys
722 are required to be at least 16 bytes long, which implies at least
723 32 characters for hexadecimal keys. The file should neither be
724 world-readable nor world-writable.
725
726 pty = yes | no (Unix only)
727 allocate a pseudoterminal for 'exec' option
728
729 redirect = [HOST:]PORT
730 redirect TLS client connections on certificate-based authentication
731 failures
732
733 This option only works in server mode. Some protocol negotiations
734 are also incompatible with the redirect option.
735
736 renegotiation = yes | no
737 support TLS renegotiation
738
739 Applications of the TLS renegotiation include some authentication
740 scenarios, or re-keying long lasting connections.
741
742 On the other hand this feature can facilitate a trivial CPU-
743 exhaustion DoS attack:
744
745 http://vincent.bernat.im/en/blog/2011-ssl-dos-mitigation.html
746
747 Please note that disabling TLS renegotiation does not fully
748 mitigate this issue.
749
750 default: yes (if supported by OpenSSL)
751
752 reset = yes | no
753 attempt to use the TCP RST flag to indicate an error
754
755 This option is not supported on some platforms.
756
757 default: yes
758
759 retry = yes | no
760 reconnect a connect+exec section after it was disconnected
761
762 default: no
763
764 requireCert = yes | no
765 require a client certificate for verifyChain or verifyPeer
766
767 With requireCert set to no, the stunnel server accepts client
768 connections that did not present a certificate.
769
770 Both verifyChain = yes and verifyPeer = yes imply requireCert =
771 yes.
772
773 default: no
774
775 setgid = GROUP (Unix only)
776 Unix group id
777
778 As a global option: setgid() to the specified group in daemon mode
779 and clear all other groups.
780
781 As a service-level option: set the group of the Unix socket
782 specified with "accept".
783
784 setuid = USER (Unix only)
785 Unix user id
786
787 As a global option: setuid() to the specified user in daemon mode.
788
789 As a service-level option: set the owner of the Unix socket
790 specified with "accept".
791
792 sessionCacheSize = NUM_ENTRIES
793 session cache size
794
795 sessionCacheSize specifies the maximum number of the internal
796 session cache entries.
797
798 The value of 0 can be used for unlimited size. It is not
799 recommended for production use due to the risk of a memory
800 exhaustion DoS attack.
801
802 sessionCacheTimeout = TIMEOUT
803 session cache timeout
804
805 This is the number of seconds to keep cached TLS sessions.
806
807 sessiond = HOST:PORT
808 address of sessiond TLS cache server
809
810 sni = SERVICE_NAME:SERVER_NAME_PATTERN (server mode)
811 Use the service as a slave service (a name-based virtual server)
812 for Server Name Indication TLS extension (RFC 3546).
813
814 SERVICE_NAME specifies the master service that accepts client
815 connections with the accept option. SERVER_NAME_PATTERN specifies
816 the host name to be redirected. The pattern may start with the '*'
817 character, e.g. '*.example.com'. Multiple slave services are
818 normally specified for a single master service. The sni option can
819 also be specified more than once within a single slave service.
820
821 This service, as well as the master service, may not be configured
822 in client mode.
823
824 The connect option of the slave service is ignored when the
825 protocol option is specified, as protocol connects to the remote
826 host before TLS handshake.
827
828 Libwrap checks (Unix only) are performed twice: with the master
829 service name after TCP connection is accepted, and with the slave
830 service name during the TLS handshake.
831
832 The sni option is only available when compiled with OpenSSL 1.0.0
833 and later.
834
835 sni = SERVER_NAME (client mode)
836 Use the parameter as the value of TLS Server Name Indication (RFC
837 3546) extension.
838
839 Empty SERVER_NAME disables sending the SNI extension.
840
841 The sni option is only available when compiled with OpenSSL 1.0.0
842 and later.
843
844 socket = a|l|r:OPTION=VALUE[:VALUE]
845 Set an option on the accept/local/remote socket
846
847 The values for the linger option are l_onof:l_linger. The values
848 for the time are tv_sec:tv_usec.
849
850 Examples:
851
852 socket = l:SO_LINGER=1:60
853 set one minute timeout for closing local socket
854 socket = r:SO_OOBINLINE=yes
855 place out-of-band data directly into the
856 receive data stream for remote sockets
857 socket = a:SO_REUSEADDR=no
858 disable address reuse (enabled by default)
859 socket = a:SO_BINDTODEVICE=lo
860 only accept connections on loopback interface
861
862 sslVersion = SSL_VERSION
863 select the TLS protocol version
864
865 Supported versions: all, SSLv2, SSLv3, TLSv1, TLSv1.1, TLSv1.2,
866 TLSv1.3
867
868 Availability of specific protocols depends on the linked OpenSSL
869 library. Older versions of OpenSSL do not support TLSv1.1, TLSv1.2
870 and TLSv1.3. Newer versions of OpenSSL do not support SSLv2.
871
872 Obsolete SSLv2 and SSLv3 are currently disabled by default.
873
874 Setting the option
875
876 sslVersion = SSL_VERSION
877
878 is equivalent to options
879
880 sslVersionMax = SSL_VERSION
881 sslVersionMin = SSL_VERSION
882
883 when compiled with OpenSSL 1.1.0 and later.
884
885 sslVersionMax = SSL_VERSION
886 maximum supported protocol versions
887
888 Supported versions: all, SSLv3, TLSv1, TLSv1.1, TLSv1.2, TLSv1.3
889
890 all enable protocol versions up to the highest version supported by
891 the linked OpenSSL library.
892
893 Availability of specific protocols depends on the linked OpenSSL
894 library.
895
896 The sslVersionMax option is only available when compiled with
897 OpenSSL 1.1.0 and later.
898
899 default: all
900
901 sslVersionMin = SSL_VERSION
902 minimum supported protocol versions
903
904 Supported versions: all, SSLv3, TLSv1, TLSv1.1, TLSv1.2, TLSv1.3
905
906 all enable protocol versions down to the lowest version supported
907 by the linked OpenSSL library.
908
909 Availability of specific protocols depends on the linked OpenSSL
910 library.
911
912 The sslVersionMin option is only available when compiled with
913 OpenSSL 1.1.0 and later.
914
915 default: TLSv1
916
917 stack = BYTES (except for FORK model)
918 CPU stack size of created threads
919
920 Excessive thread stack size increases virtual memory usage.
921 Insufficient thread stack size may cause application crashes.
922
923 default: 65536 bytes (sufficient for all platforms we tested)
924
925 ticketKeySecret = SECRET
926 hexadecimal symmetric key used for session ticket confidentiality
927 protection
928
929 Session tickets defined in RFC 5077 provide an enhanced session
930 resumption capability, where the server-side caching is not
931 required to maintain per session state.
932
933 Combining ticketKeySecret and ticketMacSecret options allow to
934 resume a negotiated session on other cluster nodes, or to resume
935 resume a negotiated session after server restart.
936
937 The key is required to be either 16 or 32 bytes long, which implies
938 exactly 32 or 64 hexadecimal digits. Colons may optionally be used
939 between two-character hexadecimal bytes.
940
941 This option only works in server mode.
942
943 The ticketKeySecret option is only available when compiled with
944 OpenSSL 1.0.0 and later.
945
946 Disabling NO_TICKET option is required for the ticket support in
947 OpenSSL older than 1.1.1, but note that this option is incompatible
948 with the redirect option.
949
950 ticketMacSecret = SECRET
951 hexadecimal symmetric key used for session ticket integrity
952 protection
953
954 The key is required to be either 16 or 32 bytes long, which implies
955 exactly 32 or 64 hexadecimal digits. Colons may optionally be used
956 between two-character hexadecimal bytes.
957
958 This option only works in server mode.
959
960 The ticketMacSecret option is only available when compiled with
961 OpenSSL 1.0.0 and later.
962
963 TIMEOUTbusy = SECONDS
964 time to wait for expected data
965
966 TIMEOUTclose = SECONDS
967 time to wait for close_notify (set to 0 for buggy MSIE)
968
969 TIMEOUTconnect = SECONDS
970 time to wait to connect to a remote host
971
972 TIMEOUTidle = SECONDS
973 time to keep an idle connection
974
975 transparent = none | source | destination | both (Unix only)
976 enable transparent proxy support on selected platforms
977
978 Supported values:
979
980 none
981 Disable transparent proxy support. This is the default.
982
983 source
984 Re-write the address to appear as if a wrapped daemon is
985 connecting from the TLS client machine instead of the machine
986 running stunnel.
987
988 This option is currently available in:
989
990 Remote mode (connect option) on Linux >=2.6.28
991 This configuration requires stunnel to be executed as root
992 and without the setuid option.
993
994 This configuration requires the following setup for
995 iptables and routing (possibly in /etc/rc.local or
996 equivalent file):
997
998 iptables -t mangle -N DIVERT
999 iptables -t mangle -A PREROUTING -p tcp -m socket -j DIVERT
1000 iptables -t mangle -A DIVERT -j MARK --set-mark 1
1001 iptables -t mangle -A DIVERT -j ACCEPT
1002 ip rule add fwmark 1 lookup 100
1003 ip route add local 0.0.0.0/0 dev lo table 100
1004 echo 0 >/proc/sys/net/ipv4/conf/lo/rp_filter
1005
1006 stunnel must also to be executed as root and without the
1007 setuid option.
1008
1009 Remote mode (connect option) on Linux 2.2.x
1010 This configuration requires the kernel to be compiled with
1011 the transparent proxy option. Connected service must be
1012 installed on a separate host. Routing towards the clients
1013 has to go through the stunnel box.
1014
1015 stunnel must also to be executed as root and without the
1016 setuid option.
1017
1018 Remote mode (connect option) on FreeBSD >=8.0
1019 This configuration requires additional firewall and routing
1020 setup. stunnel must also to be executed as root and
1021 without the setuid option.
1022
1023 Local mode (exec option)
1024 This configuration works by pre-loading the libstunnel.so
1025 shared library. _RLD_LIST environment variable is used on
1026 Tru64, and LD_PRELOAD variable on other platforms.
1027
1028 destination
1029 The original destination is used instead of the connect option.
1030
1031 A service section for transparent destination may look like
1032 this:
1033
1034 [transparent]
1035 client = yes
1036 accept = <stunnel_port>
1037 transparent = destination
1038
1039 This configuration requires iptables setup to work, possibly in
1040 /etc/rc.local or equivalent file.
1041
1042 For a connect target installed on the same host:
1043
1044 /sbin/iptables -t nat -I OUTPUT -p tcp --dport <redirected_port> \
1045 -m ! --uid-owner <stunnel_user_id> \
1046 -j DNAT --to-destination <local_ip>:<stunnel_port>
1047
1048 For a connect target installed on a remote host:
1049
1050 /sbin/iptables -I INPUT -i eth0 -p tcp --dport <stunnel_port> -j ACCEPT
1051 /sbin/iptables -t nat -I PREROUTING -p tcp --dport <redirected_port> \
1052 -i eth0 -j DNAT --to-destination <local_ip>:<stunnel_port>
1053
1054 The transparent destination option is currently only supported
1055 on Linux.
1056
1057 both
1058 Use both source and destination transparent proxy.
1059
1060 Two legacy options are also supported for backward compatibility:
1061
1062 yes This option has been renamed to source.
1063
1064 no This option has been renamed to none.
1065
1066 verify = LEVEL
1067 verify the peer certificate
1068
1069 This option is obsolete and should be replaced with the verifyChain
1070 and verifyPeer options.
1071
1072 level 0
1073 Request and ignore the peer certificate.
1074
1075 level 1
1076 Verify the peer certificate if present.
1077
1078 level 2
1079 Verify the peer certificate.
1080
1081 level 3
1082 Verify the peer against a locally installed certificate.
1083
1084 level 4
1085 Ignore the chain and only verify the peer certificate.
1086
1087 default
1088 No verify.
1089
1090 verifyChain = yes | no
1091 verify the peer certificate chain starting from the root CA
1092
1093 For server certificate verification it is essential to also require
1094 a specific certificate with checkHost or checkIP.
1095
1096 The self-signed root CA certificate needs to be stored either in
1097 the file specified with CAfile, or in the directory specified with
1098 CApath.
1099
1100 default: no
1101
1102 verifyPeer = yes | no
1103 verify the peer certificate
1104
1105 The peer certificate needs to be stored either in the file
1106 specified with CAfile, or in the directory specified with CApath.
1107
1108 default: no
1109
1111 stunnel returns zero on success, non-zero on error.
1112
1114 The following signals can be used to control stunnel in Unix
1115 environment:
1116
1117 SIGHUP
1118 Force a reload of the configuration file.
1119
1120 Some global options will not be reloaded:
1121
1122 · chroot
1123
1124 · foreground
1125
1126 · pid
1127
1128 · setgid
1129
1130 · setuid
1131
1132 The use of the 'setuid' option will also prevent stunnel from
1133 binding to privileged (<1024) ports during configuration reloading.
1134
1135 When the 'chroot' option is used, stunnel will look for all its
1136 files (including the configuration file, certificates, the log file
1137 and the pid file) within the chroot jail.
1138
1139 SIGUSR1
1140 Close and reopen the stunnel log file. This function can be used
1141 for log rotation.
1142
1143 SIGUSR2
1144 Log the list of active connections.
1145
1146 SIGTERM, SIGQUIT, SIGINT
1147 Shut stunnel down.
1148
1149 The result of sending any other signals to the server is undefined.
1150
1152 In order to provide TLS encapsulation to your local imapd service, use:
1153
1154 [imapd]
1155 accept = 993
1156 exec = /usr/sbin/imapd
1157 execArgs = imapd
1158
1159 or in remote mode:
1160
1161 [imapd]
1162 accept = 993
1163 connect = 143
1164
1165 In order to let your local e-mail client connect to a TLS-enabled imapd
1166 service on another server, configure the e-mail client to connect to
1167 localhost on port 119 and use:
1168
1169 [imap]
1170 client = yes
1171 accept = 143
1172 connect = servername:993
1173
1174 If you want to provide tunneling to your pppd daemon on port 2020, use
1175 something like:
1176
1177 [vpn]
1178 accept = 2020
1179 exec = /usr/sbin/pppd
1180 execArgs = pppd local
1181 pty = yes
1182
1183 If you want to use stunnel in inetd mode to launch your imapd process,
1184 you'd use this stunnel.conf. Note there must be no [service_name]
1185 section.
1186
1187 exec = /usr/sbin/imapd
1188 execArgs = imapd
1189
1190 To setup SOCKS VPN configure the following client service:
1191
1192 [socks_client]
1193 client = yes
1194 accept = 127.0.0.1:1080
1195 connect = vpn_server:9080
1196 verifyPeer = yes
1197 CAfile = stunnel.pem
1198
1199 The corresponding configuration on the vpn_server host:
1200
1201 [socks_server]
1202 protocol = socks
1203 accept = 9080
1204 cert = stunnel.pem
1205 key = stunnel.key
1206
1207 Now test your configuration on the client machine with:
1208
1209 curl --socks4a localhost http://www.example.com/
1210
1211 An example server mode SNI configuration:
1212
1213 [virtual]
1214 ; master service
1215 accept = 443
1216 cert = default.pem
1217 connect = default.internal.mydomain.com:8080
1218
1219 [sni1]
1220 ; slave service 1
1221 sni = virtual:server1.mydomain.com
1222 cert = server1.pem
1223 connect = server1.internal.mydomain.com:8081
1224
1225 [sni2]
1226 ; slave service 2
1227 sni = virtual:server2.mydomain.com
1228 cert = server2.pem
1229 connect = server2.internal.mydomain.com:8082
1230 verifyPeer = yes
1231 CAfile = server2-allowed-clients.pem
1232
1233 An example of advanced engine configuration allows for authentication
1234 with private keys stored in the Windows certificate store (Windows
1235 only). With the CAPI engine you don't need to manually select the
1236 client key to use. The client key is automatically selected based on
1237 the list of CAs trusted by the server.
1238
1239 engine = capi
1240
1241 [service]
1242 engineId = capi
1243 client = yes
1244 accept = 127.0.0.1:8080
1245 connect = example.com:8443
1246
1247 An example of advanced engine configuration to use the certificate and
1248 the corresponding private key from a pkcs11 engine:
1249
1250 engine = pkcs11
1251 engineCtrl = MODULE_PATH:opensc-pkcs11.so
1252 engineCtrl = PIN:123456
1253
1254 [service]
1255 engineId = pkcs11
1256 client = yes
1257 accept = 127.0.0.1:8080
1258 connect = example.com:843
1259 cert = pkcs11:token=MyToken;object=MyCert
1260 key = pkcs11:token=MyToken;object=MyKey
1261
1262 An example of advanced engine configuration to use the certificate and
1263 the corresponding private key from a SoftHSM token:
1264
1265 engine = pkcs11
1266 engineCtrl = MODULE_PATH:softhsm2.dll
1267 engineCtrl = PIN:12345
1268
1269 [service]
1270 engineId = pkcs11
1271 client = yes
1272 accept = 127.0.0.1:8080
1273 connect = example.com:843
1274 cert = pkcs11:token=MyToken;object=KeyCert
1275
1277 RESTRICTIONS
1278 stunnel cannot be used for the FTP daemon because of the nature of the
1279 FTP protocol which utilizes multiple ports for data transfers. There
1280 are available TLS-enabled versions of FTP and telnet daemons, however.
1281
1282 INETD MODE
1283 The most common use of stunnel is to listen on a network port and
1284 establish communication with either a new port via the connect option,
1285 or a new program via the exec option. However there is a special case
1286 when you wish to have some other program accept incoming connections
1287 and launch stunnel, for example with inetd, xinetd, or tcpserver.
1288
1289 For example, if you have the following line in inetd.conf:
1290
1291 imaps stream tcp nowait root /usr/bin/stunnel stunnel /etc/stunnel/imaps.conf
1292
1293 In these cases, the inetd-style program is responsible for binding a
1294 network socket (imaps above) and handing it to stunnel when a
1295 connection is received. Thus you do not want stunnel to have any
1296 accept option. All the Service Level Options should be placed in the
1297 global options section, and no [service_name] section will be present.
1298 See the EXAMPLES section for example configurations.
1299
1300 CERTIFICATES
1301 Each TLS-enabled daemon needs to present a valid X.509 certificate to
1302 the peer. It also needs a private key to decrypt the incoming data. The
1303 easiest way to obtain a certificate and a key is to generate them with
1304 the free OpenSSL package. You can find more information on certificates
1305 generation on pages listed below.
1306
1307 The .pem file should contain the unencrypted private key and a signed
1308 certificate (not certificate request). So the file should look like
1309 this:
1310
1311 -----BEGIN RSA PRIVATE KEY-----
1312 [encoded key]
1313 -----END RSA PRIVATE KEY-----
1314 -----BEGIN CERTIFICATE-----
1315 [encoded certificate]
1316 -----END CERTIFICATE-----
1317
1318 RANDOMNESS
1319 stunnel needs to seed the PRNG (pseudo-random number generator) in
1320 order for TLS to use good randomness. The following sources are loaded
1321 in order until sufficient random data has been gathered:
1322
1323 · The file specified with the RNDfile flag.
1324
1325 · The file specified by the RANDFILE environment variable, if set.
1326
1327 · The file .rnd in your home directory, if RANDFILE not set.
1328
1329 · The file specified with '--with-random' at compile time.
1330
1331 · The contents of the screen if running on Windows.
1332
1333 · The egd socket specified with the EGD flag.
1334
1335 · The egd socket specified with '--with-egd-sock' at compile time.
1336
1337 · The /dev/urandom device.
1338
1339 Note that on Windows machines that do not have console user interaction
1340 (mouse movements, creating windows, etc.) the screen contents are not
1341 variable enough to be sufficient, and you should provide a random file
1342 for use with the RNDfile flag.
1343
1344 Note that the file specified with the RNDfile flag should contain
1345 random data -- that means it should contain different information each
1346 time stunnel is run. This is handled automatically unless the
1347 RNDoverwrite flag is used. If you wish to update this file manually,
1348 the openssl rand command in recent versions of OpenSSL, would be
1349 useful.
1350
1351 Important note: If /dev/urandom is available, OpenSSL often seeds the
1352 PRNG with it while checking the random state. On systems with
1353 /dev/urandom OpenSSL is likely to use it even though it is listed at
1354 the very bottom of the list above. This is the behaviour of OpenSSL
1355 and not stunnel.
1356
1357 DH PARAMETERS
1358 stunnel 4.40 and later contains hardcoded 2048-bit DH parameters.
1359 Starting with stunnel 5.18, these hardcoded DH parameters are replaced
1360 every 24 hours with autogenerated temporary DH parameters. DH
1361 parameter generation may take several minutes.
1362
1363 Alternatively, it is possible to specify static DH parameters in the
1364 certificate file, which disables generating temporary DH parameters:
1365
1366 openssl dhparam 2048 >> stunnel.pem
1367
1369 @sysconfdir@/stunnel/stunnel.conf
1370 stunnel configuration file
1371
1373 The execArgs option and the Win32 command line do not support quoting.
1374
1376 tcpd(8)
1377 access control facility for internet services
1378
1379 inetd(8)
1380 internet 'super-server'
1381
1382 http://www.stunnel.org/
1383 stunnel homepage
1384
1385 http://www.openssl.org/
1386 OpenSSL project website
1387
1389 Michał Trojnara
1390 <Michal.Trojnara@stunnel.org>
1391
1392
1393
13945.55 2019.09.26 stunnel(8)