Merge tag 'upstream/4.57'

Upstream version 4.57
This commit is contained in:
Mario Fetka 2017-03-28 10:18:04 +02:00
commit b8998ae382
49 changed files with 3268 additions and 1874 deletions

View File

@ -1,6 +1,6 @@
stunnel license (see COPYRIGHT.GPL for detailed GPL conditions) stunnel license (see COPYRIGHT.GPL for detailed GPL conditions)
Copyright (C) 1998-2012 Michal Trojnara Copyright (C) 1998-2013 Michal Trojnara
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software

View File

@ -1,6 +1,80 @@
stunnel change log stunnel change log
Version 4.57, 2015.04.01, urgency: HIGH:
* Security bugfixes
- Added PRNG state update in fork threading (CVE-2014-0016).
Version 4.56, 2013.03.22, urgency: HIGH:
* New features
- Win32 installer automatically configures firewall exceptions.
- Win32 installer configures administrative shortcuts to invoke UAC.
- Improved Win32 GUI shutdown time.
* Bugfixes
- Fixed a regression bug introduced in version 4.55 causing random
crashes on several platforms, including Windows 7.
- Fixed startup crashes on some Win32 systems.
- Fixed incorrect "stunnel -exit" process synchronisation.
- Fixed FIPS detection with new versions of the OpenSSL library.
- Failure to open the log file at startup is no longer ignored.
Version 4.55, 2013.03.03, urgency: HIGH:
* Security bugfixes
- Buffer overflow vulnerability fixed in the NTLM authentication
of the CONNECT protocol negotiation.
See https://www.stunnel.org/CVE-2013-1762.html for details.
- OpenSSL updated to version 1.0.1e in Win32/Android builds.
* New features
- SNI wildcard matching in server mode.
- Terminal version of stunnel (tstunnel.exe) build for Win32.
* Bugfixes
- Fixed write half-close handling in the transfer() function (thx to
Dustin Lundquist).
- Fixed EAGAIN error handling in the transfer() function (thx to Jan Bee).
- Restored default signal handlers before execvp() (thx to Michael Weiser).
- Fixed memory leaks in protocol negotiation (thx to Arthur Mesh).
- Fixed a file descriptor leak during configuration file reload (thx to
Arthur Mesh).
- Closed SSL sockets were removed from the transfer() c->fds poll.
- Minor fix in handling exotic inetd-mode configurations.
- WCE compilation fixes.
- IPv6 compilation fix in protocol.c.
- Windows installer fixes.
Version 4.54, 2012.10.09, urgency: MEDIUM:
* New Win32 features
- FIPS module updated to version 2.0.
- OpenSSL DLLs updated to version 1.0.1c.
- zlib DLL updated to version 1.2.7.
- Engine DLLs added: 4758cca, aep, atalla, capi, chil, cswift, gmp, gost,
nuron, padlock, sureware, ubsec.
* Other new features
- "session" option renamed to more readable "sessionCacheTimeout".
The old name remains accepted for backward compatibility.
- New service-level "sessionCacheSize" option to control session cache size.
- New service-level option "reset" to control whether TCP RST flag is used
to indicate errors. The default value is "reset = yes".
- New service-level option "renegotiation" to disable SSL renegotiation.
This feature is based on a public-domain patch by Janusz Dziemidowicz.
- New FreeBSD socket options: IP_FREEBIND, IP_BINDANY, IPV6_BINDANY (thx
to Janusz Dziemidowicz).
- New parameters to configure TLS v1.1/v1.2 with OpenSSL version 1.0.1
or higher (thx to Henrik Riomar).
* Bugfixes
- Fixed "Application Failed to Initialize Properly (0xc0150002)" error.
- Fixed missing SSL state debug log entries.
- Fixed a race condition in libwrap code resulting in random stalls (thx
to Andrew Skalski).
- Session cache purged at configuration file reload to reduce memory leak.
Remaining leak of a few kilobytes per section is yet to be fixed.
- Fixed a regression bug in "transparent = destination" functionality (thx
to Stefan Lauterbach). This bug was introduced in stunnel 4.51.
- "transparent = destination" is now a valid endpoint in inetd mode.
- "delay = yes" fixed to work even if specified *after* "connect" option.
- Multiple "connect" targets fixed to also work with delayed resolver.
- The number of resolver retries of EAI_AGAIN error has been limited to 3
in order to prevent infinite loops.
Version 4.53, 2012.03.19, urgency: MEDIUM: Version 4.53, 2012.03.19, urgency: MEDIUM:
* New features * New features
- Added client-mode "sni" option to directly control the value of - Added client-mode "sni" option to directly control the value of
@ -94,14 +168,14 @@ Version 4.46, 2011.11.04, urgency: LOW:
- Added "verify = 4" mode to ignore CA chain and only verify peer certificate. - Added "verify = 4" mode to ignore CA chain and only verify peer certificate.
- Removed the limit of 16 IP addresses for a single 'connect' option. - Removed the limit of 16 IP addresses for a single 'connect' option.
- Removed the limit of 256 stunnel.conf sections in PTHREAD threading model. - Removed the limit of 256 stunnel.conf sections in PTHREAD threading model.
It is still not possible have more than 63 sections on WIN32 platform. It is still not possible have more than 63 sections on Win32 platform.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms740141(v=vs.85).aspx http://msdn.microsoft.com/en-us/library/windows/desktop/ms740141(v=vs.85).aspx
* Optimizations * Optimizations
- Reduced per-connection memory usage. - Reduced per-connection memory usage.
- Performed a major refactoring of internal data structures. Extensive - Performed a major refactoring of internal data structures. Extensive
internal testing was performed, but some regression bugs are expected. internal testing was performed, but some regression bugs are expected.
* Bugfixes * Bugfixes
- Fixed WIN32 compilation with Mingw32. - Fixed Win32 compilation with Mingw32.
- Fixed non-blocking API emulation layer in UCONTEXT threading model. - Fixed non-blocking API emulation layer in UCONTEXT threading model.
- Fixed signal handling in UCONTEXT threading model. - Fixed signal handling in UCONTEXT threading model.
@ -146,7 +220,7 @@ Version 4.43, 2011.09.07, urgency: MEDIUM:
- Major optimization of the logging subsystem. - Major optimization of the logging subsystem.
Benchmarks indicate up to 15% stunnel performance improvement. Benchmarks indicate up to 15% stunnel performance improvement.
* Bugfixes * Bugfixes
- Fixed WIN32 configuration file reload. - Fixed Win32 configuration file reload.
- Fixed FORK and UCONTEXT threading models. - Fixed FORK and UCONTEXT threading models.
- Corrected INSTALL.W32 file. - Corrected INSTALL.W32 file.
@ -280,14 +354,14 @@ Version 4.34, 2010.09.19, urgency: LOW:
* Bugfixes * Bugfixes
- Implemented fixes in user interface to enter engine PIN. - Implemented fixes in user interface to enter engine PIN.
- Fixed a transfer() loop issue on socket errors. - Fixed a transfer() loop issue on socket errors.
- Fixed missing WIN32 taskbar icon while displaying a global option error. - Fixed missing Win32 taskbar icon while displaying a global option error.
Version 4.33, 2010.04.05, urgency: MEDIUM: Version 4.33, 2010.04.05, urgency: MEDIUM:
* New features * New features
- Win32 DLLs for OpenSSL 1.0.0. - Win32 DLLs for OpenSSL 1.0.0.
This library requires to c_rehash CApath/CRLpath directories on upgrade. This library requires to c_rehash CApath/CRLpath directories on upgrade.
- Win32 DLLs for zlib 1.2.4. - Win32 DLLs for zlib 1.2.4.
- Experimental support for local mode on WIN32 platform. - Experimental support for local mode on Win32 platform.
Try "exec = c:\windows\system32\cmd.exe". Try "exec = c:\windows\system32\cmd.exe".
* Bugfixes * Bugfixes
- Inetd mode fixed. - Inetd mode fixed.

View File

@ -23,15 +23,17 @@ distclean-local:
rm -rf autom4te.cache rm -rf autom4te.cache
rm -f $(distdir)-installer.exe rm -f $(distdir)-installer.exe
dist-hook: #dist-hook:
makensis -NOCD -DVERSION=${VERSION} -DSRCDIR=$(srcdir) \ # makensis -NOCD -DVERSION=${VERSION} -DSRCDIR=$(srcdir) \
-DDLLS=/usr/src/openssl-0.9.8s-fips/out32dll \ # -DOPENSSL=/usr/src/openssl-0.9.8u-fips/out32dll \
$(srcdir)/tools/stunnel.nsi # -DZLIB=/usr/src/zlib-1.2.6-i586 \
# $(srcdir)/tools/stunnel.nsi
# cp -f $(distdir)-installer.exe ../dist
# gpg --yes --armor --detach-sign --force-v3-sigs ../dist/$(distdir)-installer.exe
sign: dist sign: dist
cp -f $(distdir).tar.gz ../dist cp -f $(distdir).tar.gz ../dist
cp -f $(distdir)-installer.exe ../dist
gpg --yes --armor --detach-sign --force-v3-sigs ../dist/$(distdir).tar.gz gpg --yes --armor --detach-sign --force-v3-sigs ../dist/$(distdir).tar.gz
gpg --yes --armor --detach-sign --force-v3-sigs ../dist/$(distdir)-installer.exe
sha256sum $(distdir).tar.gz | tee ../dist/$(distdir).tar.gz.sha256 sha256sum $(distdir).tar.gz | tee ../dist/$(distdir).tar.gz.sha256

View File

@ -515,9 +515,6 @@ distdir: $(DISTFILES)
|| exit 1; \ || exit 1; \
fi; \ fi; \
done done
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$(top_distdir)" distdir="$(distdir)" \
dist-hook
-test -n "$(am__skip_mode_fix)" \ -test -n "$(am__skip_mode_fix)" \
|| find "$(distdir)" -type d ! -perm -755 \ || find "$(distdir)" -type d ! -perm -755 \
-exec chmod u+rwx,go+rx {} \; -o \ -exec chmod u+rwx,go+rx {} \; -o \
@ -578,7 +575,7 @@ distcheck: dist
*.zip*) \ *.zip*) \
unzip $(distdir).zip ;;\ unzip $(distdir).zip ;;\
esac esac
chmod -R a-w $(distdir); chmod a+w $(distdir) chmod -R a-w $(distdir); chmod u+w $(distdir)
mkdir $(distdir)/_build mkdir $(distdir)/_build
mkdir $(distdir)/_inst mkdir $(distdir)/_inst
chmod a-w $(distdir) chmod a-w $(distdir)
@ -742,19 +739,19 @@ uninstall-am: uninstall-docDATA
.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
all all-am am--refresh check check-am clean clean-generic \ all all-am am--refresh check check-am clean clean-generic \
clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \ clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \
dist-gzip dist-hook dist-lzma dist-shar dist-tarZ dist-xz \ dist-gzip dist-lzma dist-shar dist-tarZ dist-xz dist-zip \
dist-zip distcheck distclean distclean-generic \ distcheck distclean distclean-generic distclean-libtool \
distclean-libtool distclean-local distclean-tags \ distclean-local distclean-tags distcleancheck distdir \
distcleancheck distdir distuninstallcheck dvi dvi-am html \ distuninstallcheck dvi dvi-am html html-am info info-am \
html-am info info-am install install-am install-data \ install install-am install-data install-data-am \
install-data-am install-docDATA install-dvi install-dvi-am \ install-docDATA install-dvi install-dvi-am install-exec \
install-exec install-exec-am install-html install-html-am \ install-exec-am install-html install-html-am install-info \
install-info install-info-am install-man install-pdf \ install-info-am install-man install-pdf install-pdf-am \
install-pdf-am install-ps install-ps-am install-strip \ install-ps install-ps-am install-strip installcheck \
installcheck installcheck-am installdirs installdirs-am \ installcheck-am installdirs installdirs-am maintainer-clean \
maintainer-clean maintainer-clean-generic mostlyclean \ maintainer-clean-generic mostlyclean mostlyclean-generic \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
tags tags-recursive uninstall uninstall-am uninstall-docDATA uninstall uninstall-am uninstall-docDATA
libtool: $(LIBTOOL_DEPS) libtool: $(LIBTOOL_DEPS)
$(SHELL) ./config.status libtool $(SHELL) ./config.status libtool
@ -763,16 +760,18 @@ distclean-local:
rm -rf autom4te.cache rm -rf autom4te.cache
rm -f $(distdir)-installer.exe rm -f $(distdir)-installer.exe
dist-hook: #dist-hook:
makensis -NOCD -DVERSION=${VERSION} -DSRCDIR=$(srcdir) \ # makensis -NOCD -DVERSION=${VERSION} -DSRCDIR=$(srcdir) \
-DDLLS=/usr/src/openssl-0.9.8s-fips/out32dll \ # -DOPENSSL=/usr/src/openssl-0.9.8u-fips/out32dll \
$(srcdir)/tools/stunnel.nsi # -DZLIB=/usr/src/zlib-1.2.6-i586 \
# $(srcdir)/tools/stunnel.nsi
# cp -f $(distdir)-installer.exe ../dist
# gpg --yes --armor --detach-sign --force-v3-sigs ../dist/$(distdir)-installer.exe
sign: dist sign: dist
cp -f $(distdir).tar.gz ../dist cp -f $(distdir).tar.gz ../dist
cp -f $(distdir)-installer.exe ../dist
gpg --yes --armor --detach-sign --force-v3-sigs ../dist/$(distdir).tar.gz gpg --yes --armor --detach-sign --force-v3-sigs ../dist/$(distdir).tar.gz
gpg --yes --armor --detach-sign --force-v3-sigs ../dist/$(distdir)-installer.exe
sha256sum $(distdir).tar.gz | tee ../dist/$(distdir).tar.gz.sha256 sha256sum $(distdir).tar.gz | tee ../dist/$(distdir).tar.gz.sha256
# Tell versions [3.59,3.63) of GNU make to not export all variables. # Tell versions [3.59,3.63) of GNU make to not export all variables.

10
TODO
View File

@ -3,6 +3,7 @@ stunnel TODO
High priority features. They will likely be supported some day. High priority features. They will likely be supported some day.
A sponsor could allocate my time to get them faster. A sponsor could allocate my time to get them faster.
* Perform protocol negotiations after SSL negotiations if possible.
* Command-line server control interface on both Unix and Windows. * Command-line server control interface on both Unix and Windows.
* Separate GUI process running as current user on Windows. * Separate GUI process running as current user on Windows.
* Optional line-buffering of the log file. * Optional line-buffering of the log file.
@ -15,6 +16,7 @@ A sponsor could allocate my time to get them faster.
* Configuration file option to limit the number of concurrent connections. * Configuration file option to limit the number of concurrent connections.
* SOCKS 4 protocol support. * SOCKS 4 protocol support.
http://archive.socks.permeo.com/protocol/socks4.protocol http://archive.socks.permeo.com/protocol/socks4.protocol
* Option to redirect instead of rejecting connections on failed authentication.
Low priority features. They will unlikely ever be supported. Low priority features. They will unlikely ever be supported.
* Provide 64-bit Windows builds (besides 32-bit builds). * Provide 64-bit Windows builds (besides 32-bit builds).
@ -23,6 +25,7 @@ Low priority features. They will unlikely ever be supported.
* Service-level logging configuration (separate verbosity and destination). * Service-level logging configuration (separate verbosity and destination).
* Key renegotiation (re-handshake) for long connections. * Key renegotiation (re-handshake) for long connections.
* Logging to NT EventLog on Windows. * Logging to NT EventLog on Windows.
* Log rotation on Windows.
* Internationalization of logged messages (i18n). * Internationalization of logged messages (i18n).
* Generic scripting engine instead or static protocol.c. * Generic scripting engine instead or static protocol.c.
@ -32,8 +35,11 @@ Features I won't support, unless convinced otherwise by a wealthy sponsor.
This feature is less useful since PROXY protocol support is available. This feature is less useful since PROXY protocol support is available.
- Support for adding X-Forwarded-For to SMTP email headers. - Support for adding X-Forwarded-For to SMTP email headers.
This feature is most likely to be implemented as a separate proxy. This feature is most likely to be implemented as a separate proxy.
* Additional certificate checks (including wildcard comparison) based on CN * Additional certificate checks (including wildcard comparison) based on:
and X509v3 Subject Alternative Name. - CN (Common Name);
- SAN (Subject Alternative Name);
- O (Organization), and
- OU (Organizational Unit).
* Set processes title that appear on the ps(1) and top(1) commands. * Set processes title that appear on the ps(1) and top(1) commands.
I could not find a portable *and* non-copyleft library for it. I could not find a portable *and* non-copyleft library for it.

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
set -ev set -ev
VERSION=4.53 VERSION=4.57
DST=stunnel-$VERSION-android DST=stunnel-$VERSION-android
# to build Zlib: # to build Zlib:
@ -15,11 +15,14 @@ DST=stunnel-$VERSION-android
# make # make
# make install # make install
./configure --build=i686-pc-linux-gnu --host=arm-linux-androideabi --prefix=/data/local --with-ssl=/opt/androideabi/sysroot mkdir -p bin/android
cd bin/android
../../configure --build=i686-pc-linux-gnu --host=arm-linux-androideabi --prefix=/data/local --with-ssl=/opt/androideabi/sysroot
make clean make clean
make make
cd ../..
mkdir $DST mkdir $DST
cp src/stunnel /opt/androideabi/sysroot/bin/openssl $DST cp bin/android/src/stunnel /opt/androideabi/sysroot/bin/openssl $DST
# arm-linux-androideabi-strip $DST/stunnel $DST/openssl # arm-linux-androideabi-strip $DST/stunnel $DST/openssl
arm-linux-androideabi-strip $DST/openssl arm-linux-androideabi-strip $DST/openssl
zip -r $DST.zip $DST zip -r $DST.zip $DST

728
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,10 @@
# Process this file with autoconf to produce a configure script. # Process this file with autoconf to produce a configure script.
AC_INIT([stunnel],[4.53]) AC_INIT([stunnel],[4.57])
AC_MSG_NOTICE([**************************************** initialization]) AC_MSG_NOTICE([**************************************** initialization])
AC_CONFIG_AUX_DIR(auto) AC_CONFIG_AUX_DIR(auto)
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE(stunnel, 4.53) AM_INIT_AUTOMAKE(stunnel, 4.57)
AC_CONFIG_HEADERS([src/config.h]) AC_CONFIG_HEADERS([src/config.h])
AC_CONFIG_SRCDIR([src/stunnel.c]) AC_CONFIG_SRCDIR([src/stunnel.c])
AC_DEFINE([_GNU_SOURCE], [1], [Use GNU source]) AC_DEFINE([_GNU_SOURCE], [1], [Use GNU source])
@ -455,32 +455,27 @@ valid_CPPFLAGS="$CPPFLAGS"; CPPFLAGS="$CPPFLAGS -I$SSLDIR/include"
valid_LIBS="$LIBS"; LIBS="$LIBS -L$SSLDIR/lib64 -L$SSLDIR/lib -lssl -lcrypto" valid_LIBS="$LIBS"; LIBS="$LIBS -L$SSLDIR/lib64 -L$SSLDIR/lib -lssl -lcrypto"
AC_CHECK_HEADER([$SSLDIR/include/openssl/engine.h], AC_CHECK_HEADER([$SSLDIR/include/openssl/engine.h],
[AC_DEFINE([HAVE_OSSL_ENGINE_H], [1], [Define to 1 if you have <engine.h> header file.])], [AC_DEFINE([HAVE_OSSL_ENGINE_H], [1],
[Define to 1 if you have <engine.h> header file.])],
[AC_MSG_WARN([OpenSSL engine header not found])]) [AC_MSG_WARN([OpenSSL engine header not found])])
AC_CHECK_HEADER([$SSLDIR/include/openssl/ocsp.h], AC_CHECK_HEADER([$SSLDIR/include/openssl/ocsp.h],
[AC_DEFINE([HAVE_OSSL_OCSP_H], [1], [Define to 1 if you have <ocsp.h> header file.])], [AC_DEFINE([HAVE_OSSL_OCSP_H], [1],
[Define to 1 if you have <ocsp.h> header file.])],
[AC_MSG_WARN([OpenSSL ocsp header not found])]) [AC_MSG_WARN([OpenSSL ocsp header not found])])
AC_MSG_CHECKING([for FIPS_mode_set]) AC_CHECK_HEADER([$SSLDIR/include/openssl/fips.h],
[AC_DEFINE([HAVE_OSSL_FIPS_H], [1],
[Define to 1 if you have <fips.h> header file.])],
[AC_MSG_WARN([OpenSSL fips header not found])])
if test "$fips" = "auto"; then if test "$fips" = "auto"; then
AC_LINK_IFELSE( AC_CHECK_FUNCS(FIPS_mode_set, [
[AC_LANG_PROGRAM( AC_DEFINE([USE_FIPS], [1], [Define to 1 to enable OpenSSL FIPS mode.])
[ AC_MSG_NOTICE([FIPS mode detected])
#include <openssl/fips.h> ], [
], AC_MSG_NOTICE([FIPS mode not detected])
[ ])
FIPS_mode_set(1);
],
)],
[AC_MSG_RESULT([yes])
AC_DEFINE([USE_FIPS], [1], [Define to 1 to enable OpenSSL FIPS mode.])
], [
AC_MSG_RESULT([no])
]
)
else
AC_MSG_RESULT([test skipped])
fi fi
CPPFLAGS="$valid_CPPFLAGS" CPPFLAGS="$valid_CPPFLAGS"

View File

@ -62,7 +62,7 @@
.\" ======================================================================== .\" ========================================================================
.\" .\"
.IX Title "STUNNEL 8" .IX Title "STUNNEL 8"
.TH STUNNEL 8 "2012.01.14" "4.53" "stunnel" .TH STUNNEL 8 "2013.03.20" "4.56" "stunnel"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents. .\" way too many mistakes in technical documents.
.if n .ad l .if n .ad l
@ -132,21 +132,21 @@ Don't display any message boxes
.IX Header "CONFIGURATION FILE" .IX Header "CONFIGURATION FILE"
Each line of the configuration file can be either: Each line of the configuration file can be either:
.IP "\(bu" 4 .IP "\(bu" 4
an empty line (ignored) An empty line (ignored).
.IP "\(bu" 4 .IP "\(bu" 4
a comment starting with ';' (ignored) A comment starting with ';' (ignored).
.IP "\(bu" 4 .IP "\(bu" 4
an 'option_name = option_value' pair An 'option_name = option_value' pair.
.IP "\(bu" 4 .IP "\(bu" 4
\&'[service_name]' indicating a start of a service definition \&'[service_name]' indicating a start of a service definition.
.PP .PP
An address parameter of an option may be either: An address parameter of an option may be either:
.IP "\(bu" 4 .IP "\(bu" 4
a port number A port number.
.IP "\(bu" 4 .IP "\(bu" 4
a colon-separated pair of \s-1IP\s0 address (either IPv4, IPv6, or domain name) and port number A colon-separated pair of \s-1IP\s0 address (either IPv4, IPv6, or domain name) and port number.
.IP "\(bu" 4 .IP "\(bu" 4
a Unix socket path (Unix only) A Unix socket path (Unix only).
.SS "\s-1GLOBAL\s0 \s-1OPTIONS\s0" .SS "\s-1GLOBAL\s0 \s-1OPTIONS\s0"
.IX Subsection "GLOBAL OPTIONS" .IX Subsection "GLOBAL OPTIONS"
.IP "\fBchroot\fR = directory (Unix only)" 4 .IP "\fBchroot\fR = directory (Unix only)" 4
@ -156,6 +156,18 @@ directory to chroot \fBstunnel\fR process
\&\fBchroot\fR keeps \fBstunnel\fR in chrooted jail. \fICApath\fR, \fICRLpath\fR, \fIpid\fR \&\fBchroot\fR keeps \fBstunnel\fR in chrooted jail. \fICApath\fR, \fICRLpath\fR, \fIpid\fR
and \fIexec\fR are located inside the jail and the patches have to be relative and \fIexec\fR are located inside the jail and the patches have to be relative
to the directory specified with \fBchroot\fR. to the directory specified with \fBchroot\fR.
.Sp
Several functions of the operating system also need their files to be located within 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 | rle" 4 .IP "\fBcompression\fR = deflate | zlib | rle" 4
.IX Item "compression = deflate | zlib | rle" .IX Item "compression = deflate | zlib | rle"
select data compression algorithm select data compression algorithm
@ -164,10 +176,10 @@ default: no compression
.Sp .Sp
deflate is the standard compression method as described in \s-1RFC\s0 1951. deflate is the standard compression method as described in \s-1RFC\s0 1951.
.Sp .Sp
zlib compression of OpenSSL 0.9.8 or above is not backward compatible with zlib compression of \fBOpenSSL 0.9.8\fR or above is not backward compatible with
OpenSSL 0.9.7. \&\fBOpenSSL 0.9.7\fR.
.Sp .Sp
rle compression is currently not implemented by the OpenSSL library. rle compression is currently not implemented by the \fBOpenSSL\fR library.
.IP "\fBdebug\fR = [facility.]level" 4 .IP "\fBdebug\fR = [facility.]level" 4
.IX Item "debug = [facility.]level" .IX Item "debug = [facility.]level"
debugging level debugging level
@ -186,8 +198,8 @@ Case is ignored for both facilities and levels.
.IX Item "EGD = egd path (Unix only)" .IX Item "EGD = egd path (Unix only)"
path to Entropy Gathering Daemon socket path to Entropy Gathering Daemon socket
.Sp .Sp
Entropy Gathering Daemon socket to use to feed OpenSSL random number Entropy Gathering Daemon socket to use to feed \fBOpenSSL\fR random number
generator. (Available only if compiled with OpenSSL 0.9.5a or higher) generator. (Available only if compiled with \fBOpenSSL 0.9.5a\fR or higher)
.IP "\fBengine\fR = auto | <engine id>" 4 .IP "\fBengine\fR = auto | <engine id>" 4
.IX Item "engine = auto | <engine id>" .IX Item "engine = auto | <engine id>"
select hardware engine select hardware engine
@ -220,8 +232,8 @@ engine cryptogaphic module.
.IX Item "fips = yes | no" .IX Item "fips = yes | no"
Enable or disable \s-1FIPS\s0 140\-2 mode. Enable or disable \s-1FIPS\s0 140\-2 mode.
.Sp .Sp
This option allows to disable entering \s-1FIPS\s0 mode if stunnel was compiled with This option allows to disable entering \s-1FIPS\s0 mode if \fBstunnel\fR was compiled
\&\s-1FIPS\s0 140\-2 support. with \s-1FIPS\s0 140\-2 support.
.Sp .Sp
default: yes default: yes
.IP "\fBforeground\fR = yes | no (Unix only)" 4 .IP "\fBforeground\fR = yes | no (Unix only)" 4
@ -249,9 +261,9 @@ If the argument is empty, then no pid file will be created.
.IX Item "RNDbytes = bytes" .IX Item "RNDbytes = bytes"
bytes to read from random seed files bytes to read from random seed files
.Sp .Sp
Number of bytes of data read from random seed files. With \s-1SSL\s0 versions Number of bytes of data read from random seed files. With \s-1SSL\s0 versions less
less than 0.9.5a, also determines how many bytes of data are considered than \fB0.9.5a\fR, also determines how many bytes of data are considered
sufficient to seed the \s-1PRNG\s0. More recent OpenSSL versions have a builtin sufficient to seed the \s-1PRNG\s0. More recent \fBOpenSSL\fR versions have a builtin
function to determine when sufficient randomness is available. function to determine when sufficient randomness is available.
.IP "\fBRNDfile\fR = file" 4 .IP "\fBRNDfile\fR = file" 4
.IX Item "RNDfile = file" .IX Item "RNDfile = file"
@ -335,8 +347,8 @@ the \fIverify\fR. Note that the certificates in this directory should be named
\&\s-1XXXXXXXX\s0.0 where \s-1XXXXXXXX\s0 is the hash value of the \s-1DER\s0 encoded subject of the \&\s-1XXXXXXXX\s0.0 where \s-1XXXXXXXX\s0 is the hash value of the \s-1DER\s0 encoded subject of the
cert. cert.
.Sp .Sp
The hash algorithm has been changed in OpenSSL 1.0.0. It is required to The hash algorithm has been changed in \fBOpenSSL 1.0.0\fR. It is required to
c_rehash the directory on upgrade from OpenSSL 0.x.x to OpenSSL 1.x.x. c_rehash the directory on upgrade from \fBOpenSSL 0.x.x\fR to \fBOpenSSL 1.x.x\fR.
.Sp .Sp
\&\fICApath\fR path is relative to \fIchroot\fR directory if specified. \&\fICApath\fR path is relative to \fIchroot\fR directory if specified.
.IP "\fBCAfile\fR = certfile" 4 .IP "\fBCAfile\fR = certfile" 4
@ -383,8 +395,8 @@ This is the directory in which \fBstunnel\fR will look for CRLs when
using the \fIverify\fR. Note that the CRLs in this directory should using the \fIverify\fR. Note that the CRLs in this directory should
be named \s-1XXXXXXXX\s0.r0 where \s-1XXXXXXXX\s0 is the hash value of the \s-1CRL\s0. be named \s-1XXXXXXXX\s0.r0 where \s-1XXXXXXXX\s0 is the hash value of the \s-1CRL\s0.
.Sp .Sp
The hash algorithm has been changed in OpenSSL 1.0.0. It is required to The hash algorithm has been changed in \fBOpenSSL 1.0.0\fR. It is required to
c_rehash the directory on upgrade from OpenSSL 0.x.x to OpenSSL 1.x.x. c_rehash the directory on upgrade from \fBOpenSSL 0.x.x\fR to \fBOpenSSL 1.x.x\fR.
.Sp .Sp
\&\fICRLpath\fR path is relative to \fIchroot\fR directory if specified. \&\fICRLpath\fR path is relative to \fIchroot\fR directory if specified.
.IP "\fBCRLfile\fR = certfile" 4 .IP "\fBCRLfile\fR = certfile" 4
@ -408,7 +420,7 @@ default: prime256v1
delay \s-1DNS\s0 lookup for 'connect' option delay \s-1DNS\s0 lookup for 'connect' option
.Sp .Sp
This option is useful for dynamic \s-1DNS\s0, or when \s-1DNS\s0 is not available during This option is useful for dynamic \s-1DNS\s0, or when \s-1DNS\s0 is not available during
stunnel startup (road warrior \s-1VPN\s0, dial-up configurations). \&\fBstunnel\fR startup (road warrior \s-1VPN\s0, dial-up configurations).
.IP "\fBengineNum\fR = engine number" 4 .IP "\fBengineNum\fR = engine number" 4
.IX Item "engineNum = engine number" .IX Item "engineNum = engine number"
select engine number to read private key select engine number to read private key
@ -461,29 +473,34 @@ default: yes
.IX Item "local = host" .IX Item "local = host"
\&\s-1IP\s0 of the outgoing interface is used as source for remote connections. \&\s-1IP\s0 of the outgoing interface is used as source for remote connections.
Use this option to bind a static local \s-1IP\s0 address, instead. Use this option to bind a static local \s-1IP\s0 address, instead.
.IP "\fBsni\fR = service_name:server_name (server mode)" 4 .IP "\fBsni\fR = service_name:server_name_pattern (server mode)" 4
.IX Item "sni = service_name:server_name (server mode)" .IX Item "sni = service_name:server_name_pattern (server mode)"
Use the service as a slave service (a name-based virtual server) for Server Use the service as a slave service (a name-based virtual server) for Server
Name Indication \s-1TLS\s0 extension (\s-1RFC\s0 3546). Name Indication \s-1TLS\s0 extension (\s-1RFC\s0 3546).
.Sp .Sp
\&\fIservice_name\fR specifies the master service that accepts client connections \&\fIservice_name\fR specifies the master service that accepts client connections
with \fIaccept\fR option. \fIserver_name\fR specifies the host name to be redirected. with \fIaccept\fR option. \fIserver_name_pattern\fR specifies the host name to be
redirected. The pattern may start with '*' character, e.g. '*.example.com'.
Multiple slave services are normally specified for a single master service. Multiple slave services are normally specified for a single master service.
\&\fIsni\fR option can also be specified more than once within a single slave service. \&\fIsni\fR option can also be specified more than once within a single slave
service.
.Sp
This service, as well as the master service, may not be configured in client
mode.
.Sp .Sp
This service, as well as the master service, may not be configured in client mode.
\&\fIconnect\fR option of the slave service is ignored when \fIprotocol\fR option is \&\fIconnect\fR option of the slave service is ignored when \fIprotocol\fR option is
specified, as \fIprotocol\fR connects remote host before \s-1TLS\s0 handshake. specified, as \fIprotocol\fR connects remote host before \s-1TLS\s0 handshake.
.Sp
Libwrap checks (Unix only) are performed twice: with master service name after Libwrap checks (Unix only) are performed twice: with master service name after
\&\s-1TCP\s0 connection is accepted, and with slave service name during \s-1TLS\s0 handshake. \&\s-1TCP\s0 connection is accepted, and with slave service name during \s-1TLS\s0 handshake.
.Sp .Sp
Option \fIsni\fR is only available when compiled with OpenSSL 1.0.0 and later. Option \fIsni\fR is only available when compiled with \fBOpenSSL 1.0.0\fR and later.
.IP "\fBsni\fR = server_name (client mode)" 4 .IP "\fBsni\fR = server_name (client mode)" 4
.IX Item "sni = server_name (client mode)" .IX Item "sni = server_name (client mode)"
Use the parameter as the value of \s-1TLS\s0 Server Name Indication (\s-1RFC\s0 3546) Use the parameter as the value of \s-1TLS\s0 Server Name Indication (\s-1RFC\s0 3546)
extension. extension.
.Sp .Sp
Option \fIsni\fR is only available when compiled with OpenSSL 1.0.0 and later. Option \fIsni\fR is only available when compiled with \fBOpenSSL 1.0.0\fR and later.
.IP "\fB\s-1OCSP\s0\fR = url" 4 .IP "\fB\s-1OCSP\s0\fR = url" 4
.IX Item "OCSP = url" .IX Item "OCSP = url"
select \s-1OCSP\s0 server for certificate verification select \s-1OCSP\s0 server for certificate verification
@ -497,9 +514,9 @@ currently supported flags: \s-1NOCERTS\s0, \s-1NOINTERN\s0 \s-1NOSIGS\s0, \s-1NO
\&\s-1NOEXPLICIT\s0, \s-1NOCASIGN\s0, \s-1NODELEGATED\s0, \s-1NOCHECKS\s0, \s-1TRUSTOTHER\s0, \s-1RESPID_KEY\s0, \s-1NOTIME\s0 \&\s-1NOEXPLICIT\s0, \s-1NOCASIGN\s0, \s-1NODELEGATED\s0, \s-1NOCHECKS\s0, \s-1TRUSTOTHER\s0, \s-1RESPID_KEY\s0, \s-1NOTIME\s0
.IP "\fBoptions\fR = SSL_options" 4 .IP "\fBoptions\fR = SSL_options" 4
.IX Item "options = SSL_options" .IX Item "options = SSL_options"
OpenSSL library options \&\fBOpenSSL\fR library options
.Sp .Sp
The parameter is the OpenSSL option name as described in the The parameter is the \fBOpenSSL\fR option name as described in the
\&\fI\fISSL_CTX_set_options\fI\|(3ssl)\fR manual, but without \fI\s-1SSL_OP_\s0\fR prefix. \&\fI\fISSL_CTX_set_options\fI\|(3ssl)\fR manual, but without \fI\s-1SSL_OP_\s0\fR prefix.
Several \fIoptions\fR can be used to specify multiple options. Several \fIoptions\fR can be used to specify multiple options.
.Sp .Sp
@ -511,8 +528,10 @@ the following option can be used:
.Ve .Ve
.IP "\fBprotocol\fR = proto" 4 .IP "\fBprotocol\fR = proto" 4
.IX Item "protocol = proto" .IX Item "protocol = proto"
application protocol to negotiate \s-1SSL\s0 (e.g. \fIstarttls\fR or \fIstls\fR) application protocol to negotiate \s-1SSL\s0
.Sp .Sp
This option enables initial, protocol-specific negotiation of the \s-1SSL/TLS\s0
encryption.
\&\fIprotocol\fR option should not be used with \s-1SSL\s0 encryption on a separate port. \&\fIprotocol\fR option should not be used with \s-1SSL\s0 encryption on a separate port.
.Sp .Sp
Currently supported protocols: Currently supported protocols:
@ -555,12 +574,18 @@ authentication type for protocol negotiations
.Sp .Sp
currently supported: basic, \s-1NTLM\s0 currently supported: basic, \s-1NTLM\s0
.Sp .Sp
Currently authentication type only applies to 'connect' protocol. Currently authentication type only applies to the 'connect' protocol.
.Sp .Sp
default: basic default: basic
.IP "\fBprotocolHost\fR = host:port" 4 .IP "\fBprotocolHost\fR = host:port" 4
.IX Item "protocolHost = host:port" .IX Item "protocolHost = host:port"
destination address for protocol negotiations destination address for protocol negotiations
.Sp
\&\fIprotocolHost\fR specifies the final \s-1SSL\s0 server to be connected by the proxy,
and not the proxy server directly connected by \fBstunnel\fR.
The proxy server should be specified with the 'connect' option.
.Sp
Currently protocol destination address only applies to 'connect' protocol.
.IP "\fBprotocolPassword\fR = password" 4 .IP "\fBprotocolPassword\fR = password" 4
.IX Item "protocolPassword = password" .IX Item "protocolPassword = password"
password for protocol negotiations password for protocol negotiations
@ -570,14 +595,48 @@ username for protocol negotiations
.IP "\fBpty\fR = yes | no (Unix only)" 4 .IP "\fBpty\fR = yes | no (Unix only)" 4
.IX Item "pty = yes | no (Unix only)" .IX Item "pty = yes | no (Unix only)"
allocate pseudo terminal for 'exec' option allocate pseudo terminal for 'exec' option
.IP "\fBretry\fR = yes | no (Unix only)" 4 .IP "\fBrenegotiation\fR = yes | no" 4
.IX Item "retry = yes | no (Unix only)" .IX Item "renegotiation = yes | no"
support \s-1SSL\s0 renegotiation
.Sp
Applications of the \s-1SSL\s0 renegotiation include some authentication scenarios,
or re-keying long lasting connections.
.Sp
On the other hand this feature can facilitate a trivial CPU-exhaustion
DoS attack:
.Sp
http://vincent.bernat.im/en/blog/2011\-ssl\-dos\-mitigation.html
.Sp
Please note that disabling \s-1SSL\s0 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 \s-1TCP\s0 \s-1RST\s0 flag to indicate an error
.Sp
This option is not supported on some platforms.
.Sp
default: yes
.IP "\fBretry\fR = yes | no" 4
.IX Item "retry = yes | no"
reconnect a connect+exec section after it's disconnected reconnect a connect+exec section after it's disconnected
.Sp .Sp
default: no default: no
.IP "\fBsession\fR = timeout" 4 .IP "\fBsessionCacheSize\fR = size" 4
.IX Item "session = timeout" .IX Item "sessionCacheSize = size"
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 memory exhaustion DoS attack.
.IP "\fBsessionCacheTimeout\fR = timeout" 4
.IX Item "sessionCacheTimeout = timeout"
session cache timeout session cache timeout
.Sp
This is the number of seconds to keep cached \s-1SSL\s0 sessions.
.IP "\fBsessiond\fR = host:port" 4 .IP "\fBsessiond\fR = host:port" 4
.IX Item "sessiond = host:port" .IX Item "sessiond = host:port"
address of sessiond \s-1SSL\s0 cache server address of sessiond \s-1SSL\s0 cache server
@ -585,7 +644,7 @@ address of sessiond \s-1SSL\s0 cache server
.IX Item "sslVersion = version" .IX Item "sslVersion = version"
select version of \s-1SSL\s0 protocol select version of \s-1SSL\s0 protocol
.Sp .Sp
Allowed options: all, SSLv2, SSLv3, TLSv1 Allowed options: all, SSLv2, SSLv3, TLSv1, TLSv1.1, TLSv1.2
.IP "\fBstack\fR = bytes (except for \s-1FORK\s0 model)" 4 .IP "\fBstack\fR = bytes (except for \s-1FORK\s0 model)" 4
.IX Item "stack = bytes (except for FORK model)" .IX Item "stack = bytes (except for FORK model)"
thread stack size thread stack size
@ -619,7 +678,7 @@ This option is currently available in:
.RS 4 .RS 4
.IP "Remote mode (\fIconnect\fR option) on \fILinux >=2.6.28\fR" 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" .IX Item "Remote mode (connect option) on Linux >=2.6.28"
This configuration requires stunnel to be executed as root and without This configuration requires \fBstunnel\fR to be executed as root and without
\&\fIsetuid\fR option. \&\fIsetuid\fR option.
.Sp .Sp
This configuration requires the following setup for iptables and routing This configuration requires the following setup for iptables and routing
@ -638,9 +697,10 @@ This configuration requires the following setup for iptables and routing
\&\fBstunnel\fR must also to be executed as root and without \fIsetuid\fR option. \&\fBstunnel\fR must also to be executed as root and without \fIsetuid\fR option.
.IP "Remote mode (\fIconnect\fR option) on \fILinux 2.2.x\fR" 4 .IP "Remote mode (\fIconnect\fR option) on \fILinux 2.2.x\fR" 4
.IX Item "Remote mode (connect option) on Linux 2.2.x" .IX Item "Remote mode (connect option) on Linux 2.2.x"
This configuration requires kernel to be compiled with \fItransparent proxy\fR option. This configuration requires kernel to be compiled with \fItransparent proxy\fR
option.
Connected service must be installed on a separate host. Connected service must be installed on a separate host.
Routing towards the clients has to go through the stunnel box. Routing towards the clients has to go through the \fBstunnel\fR box.
.Sp .Sp
\&\fBstunnel\fR must also to be executed as root and without \fIsetuid\fR option. \&\fBstunnel\fR must also to be executed as root and without \fIsetuid\fR option.
.IP "Remote mode (\fIconnect\fR option) on \fIFreeBSD >=8.0\fR" 4 .IP "Remote mode (\fIconnect\fR option) on \fIFreeBSD >=8.0\fR" 4
@ -697,22 +757,26 @@ This options has been renamed to \fInone\fR.
.IX Item "verify = level" .IX Item "verify = level"
verify peer certificate verify peer certificate
.RS 4 .RS 4
.IP "\fIlevel 0\fR \- request and ignore peer certificate" 4 .IP "level 0" 4
.IX Item "level 0 - request and ignore peer certificate" .IX Item "level 0"
.PD 0 Request and ignore peer certificate.
.IP "\fIlevel 1\fR \- verify peer certificate if present" 4 .IP "level 1" 4
.IX Item "level 1 - verify peer certificate if present" .IX Item "level 1"
.IP "\fIlevel 2\fR \- verify peer certificate" 4 Verify peer certificate if present.
.IX Item "level 2 - verify peer certificate" .IP "level 2" 4
.IP "\fIlevel 3\fR \- verify peer with locally installed certificate" 4 .IX Item "level 2"
.IX Item "level 3 - verify peer with locally installed certificate" Verify peer certificate.
.IP "\fIlevel 4\fR \- ignore \s-1CA\s0 chain and only verify peer certificate" 4 .IP "level 3" 4
.IX Item "level 4 - ignore CA chain and only verify peer certificate" .IX Item "level 3"
.IP "\fIdefault\fR \- no verify" 4 Verify peer with locally installed certificate.
.IX Item "default - no verify" .IP "level 4" 4
.IX Item "level 4"
Ignore \s-1CA\s0 chain and only verify peer certificate.
.IP "default" 4
.IX Item "default"
No verify.
.RE .RE
.RS 4 .RS 4
.PD
.Sp .Sp
It is important to understand, that this option was solely designed for access It is important to understand, that this option was solely designed for access
control and not for authorization. Specifically for level 2 every non-revoked control and not for authorization. Specifically for level 2 every non-revoked
@ -725,7 +789,7 @@ for webservers. Level 3 is preferred for point-to-point connections.
\&\fBstunnel\fR returns zero on success, non-zero on error. \&\fBstunnel\fR returns zero on success, non-zero on error.
.SH "SIGNALS" .SH "SIGNALS"
.IX Header "SIGNALS" .IX Header "SIGNALS"
The following signals can be used to control stunnel in Unix environment: The following signals can be used to control \fBstunnel\fR in Unix environment:
.IP "\s-1SIGHUP\s0" 4 .IP "\s-1SIGHUP\s0" 4
.IX Item "SIGHUP" .IX Item "SIGHUP"
Force a reload of the configuration file. Force a reload of the configuration file.
@ -745,20 +809,20 @@ setuid
.RE .RE
.RS 4 .RS 4
.Sp .Sp
The use of 'setuid' option will also prevent stunnel from binding privileged The use of 'setuid' option will also prevent \fBstunnel\fR from binding privileged
(<1024) ports during configuration reloading. (<1024) ports during configuration reloading.
.Sp .Sp
When 'chroot' option is used, stunnel will look for all its files (including When 'chroot' option is used, \fBstunnel\fR will look for all its files (including
configuration file, certificates, log file and pid file) within the chroot configuration file, certificates, log file and pid file) within the chroot
jail. jail.
.RE .RE
.IP "\s-1SIGUSR1\s0" 4 .IP "\s-1SIGUSR1\s0" 4
.IX Item "SIGUSR1" .IX Item "SIGUSR1"
Close and reopen stunnel log file. Close and reopen \fBstunnel\fR log file.
This function can be used for log rotation. This function can be used for log rotation.
.IP "\s-1SIGTERM\s0, \s-1SIGQUIT\s0, \s-1SIGINT\s0" 4 .IP "\s-1SIGTERM\s0, \s-1SIGQUIT\s0, \s-1SIGINT\s0" 4
.IX Item "SIGTERM, SIGQUIT, SIGINT" .IX Item "SIGTERM, SIGQUIT, SIGINT"
Shut stunnel down. Shut \fBstunnel\fR down.
.PP .PP
The result of sending any other signals to the server is undefined. The result of sending any other signals to the server is undefined.
.SH "EXAMPLES" .SH "EXAMPLES"
@ -827,7 +891,7 @@ configurations.
Each \s-1SSL\s0 enabled daemon needs to present a valid X.509 certificate Each \s-1SSL\s0 enabled daemon needs to present a valid X.509 certificate
to the peer. It also needs a private key to decrypt the incoming 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 data. The easiest way to obtain a certificate and a key is to
generate them with the free \fIOpenSSL\fR package. You can find more generate them with the free \fBOpenSSL\fR package. You can find more
information on certificates generation on pages listed below. information on certificates generation on pages listed below.
.PP .PP
The order of contents of the \fI.pem\fR file is important. It should contain the The order of contents of the \fI.pem\fR file is important. It should contain the
@ -868,10 +932,10 @@ The egd socket specified with '\-\-with\-egd\-sock' at compile time.
.IP "\(bu" 4 .IP "\(bu" 4
The /dev/urandom device. The /dev/urandom device.
.PP .PP
With recent (>=OpenSSL 0.9.5a) version of \s-1SSL\s0 it will stop loading With recent (\fBOpenSSL 0.9.5a\fR or later) version of \s-1SSL\s0 it will stop loading
random data automatically when sufficient entropy has been gathered. random data automatically when sufficient entropy has been gathered. With
With previous versions it will continue to gather from all the above previous versions it will continue to gather from all the above sources since
sources since no \s-1SSL\s0 function exists to tell when enough data is available. no \s-1SSL\s0 function exists to tell when enough data is available.
.PP .PP
Note that on Windows machines that do not have console user interaction Note that on Windows machines that do not have console user interaction
(mouse movements, creating windows, etc.) the screen contents are not (mouse movements, creating windows, etc.) the screen contents are not
@ -882,14 +946,13 @@ Note that the file specified with the \fIRNDfile\fR flag should contain
random data \*(-- that means it should contain different information random data \*(-- that means it should contain different information
each time \fBstunnel\fR is run. This is handled automatically each time \fBstunnel\fR is run. This is handled automatically
unless the \fIRNDoverwrite\fR flag is used. If you wish to update this file unless the \fIRNDoverwrite\fR flag is used. If you wish to update this file
manually, the \fIopenssl rand\fR command in recent versions of OpenSSL, manually, the \fIopenssl rand\fR command in recent versions of \fBOpenSSL\fR,
would be useful. would be useful.
.PP .PP
One important note \*(-- if /dev/urandom is available, OpenSSL has a habit of Important note: If /dev/urandom is available, \fBOpenSSL\fR often seeds the \s-1PRNG\s0
seeding the \s-1PRNG\s0 with it even when checking the random state, so on with it while checking the random state. On systems with /dev/urandom
systems with /dev/urandom you're likely to use it even though it's listed \&\fBOpenSSL\fR is likely to use it even though it is listed at the very bottom of
at the very bottom of the list above. This isn't \fBstunnel's\fR behaviour, it's the list above. This is the behaviour of \fBOpenSSL\fR and not \fBstunnel\fR.
OpenSSLs.
.SS "\s-1DH\s0 \s-1PARAMETERS\s0" .SS "\s-1DH\s0 \s-1PARAMETERS\s0"
.IX Subsection "DH PARAMETERS" .IX Subsection "DH PARAMETERS"
Stunnel 4.40 and later contains hardcoded 2048\-bit \s-1DH\s0 parameters. Stunnel 4.40 and later contains hardcoded 2048\-bit \s-1DH\s0 parameters.
@ -908,7 +971,7 @@ It is also possible to specify \s-1DH\s0 parameters in the certificate file:
\&\fBstunnel\fR configuration file \&\fBstunnel\fR configuration file
.SH "BUGS" .SH "BUGS"
.IX Header "BUGS" .IX Header "BUGS"
Option \fIexecargs\fR does not support quoting. Option \fIexecargs\fR and Win32 command line does not support quoting.
.SH "SEE ALSO" .SH "SEE ALSO"
.IX Header "SEE ALSO" .IX Header "SEE ALSO"
.IP "\fItcpd\fR\|(8)" 4 .IP "\fItcpd\fR\|(8)" 4
@ -922,7 +985,7 @@ internet 'super\-server'
\&\fBstunnel\fR homepage \&\fBstunnel\fR homepage
.IP "\fIhttp://www.openssl.org/\fR" 4 .IP "\fIhttp://www.openssl.org/\fR" 4
.IX Item "http://www.openssl.org/" .IX Item "http://www.openssl.org/"
OpenSSL project website \&\fBOpenSSL\fR project website
.SH "AUTHOR" .SH "AUTHOR"
.IX Header "AUTHOR" .IX Header "AUTHOR"
.IP "Michał Trojnara" 4 .IP "Michał Trojnara" 4

View File

@ -62,7 +62,7 @@
.\" ======================================================================== .\" ========================================================================
.\" .\"
.IX Title "STUNNEL.FR 8" .IX Title "STUNNEL.FR 8"
.TH STUNNEL.FR 8 "2012.01.12" "4.53" "stunnel" .TH STUNNEL.FR 8 "2013.03.19" "4.56" "stunnel"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents. .\" way too many mistakes in technical documents.
.if n .ad l .if n .ad l

View File

@ -156,29 +156,29 @@ Eric Young (<a href="mailto:eay@cryptsoft.com">eay@cryptsoft.com</a>)</p>
<h1><a name="configuration_file">CONFIGURATION FILE</a></h1> <h1><a name="configuration_file">CONFIGURATION FILE</a></h1>
<p>Each line of the configuration file can be either:</p> <p>Each line of the configuration file can be either:</p>
<ul> <ul>
<li><strong><a name="line" class="item">an empty line (ignored)</a></strong> <li>
<p>An empty line (ignored).</p>
</li> </li>
<li><strong><a name="a_comment_starting_with_ignored" class="item">a comment starting with ';' (ignored)</a></strong> <li>
<p>A comment starting with ';' (ignored).</p>
</li> </li>
<li><strong><a name="an_option_name_option_value_pair" class="item">an 'option_name = option_value' pair</a></strong> <li>
<p>An 'option_name = option_value' pair.</p>
</li> </li>
<li><strong><a name="service_name_indicating_a_start_of_a_service_definition" class="item">'[service_name]' indicating a start of a service definition</a></strong> <li>
<p>'[service_name]' indicating a start of a service definition.</p>
</li> </li>
</ul> </ul>
<p>An address parameter of an option may be either:</p> <p>An address parameter of an option may be either:</p>
<ul> <ul>
<li><strong><a name="a_port_number" class="item">a port number</a></strong> <li>
<p>A port number.</p>
</li> </li>
<li><strong><a name="address" class="item">a colon-separated pair of IP address (either IPv4, IPv6, or domain name) and port number</a></strong> <li>
<p>A colon-separated pair of IP address (either IPv4, IPv6, or domain name) and port number.</p>
</li> </li>
<li><strong><a name="path" class="item">a Unix socket path (Unix only)</a></strong> <li>
<p>A Unix socket path (Unix only).</p>
</li> </li>
</ul> </ul>
<p> <p>
@ -192,6 +192,18 @@ Eric Young (<a href="mailto:eay@cryptsoft.com">eay@cryptsoft.com</a>)</p>
<p><strong>chroot</strong> keeps <strong>stunnel</strong> in chrooted jail. <em>CApath</em>, <em>CRLpath</em>, <em>pid</em> <p><strong>chroot</strong> keeps <strong>stunnel</strong> in chrooted jail. <em>CApath</em>, <em>CRLpath</em>, <em>pid</em>
and <em>exec</em> are located inside the jail and the patches have to be relative and <em>exec</em> are located inside the jail and the patches have to be relative
to the directory specified with <strong>chroot</strong>.</p> to the directory specified with <strong>chroot</strong>.</p>
<p>Several functions of the operating system also need their files to be located within chroot jail, e.g.:</p>
<ul>
<li>
<p>Delayed resolver typically needs /etc/nsswitch.conf and /etc/resolv.conf.</p>
</li>
<li>
<p>Local time in log files needs /etc/timezone.</p>
</li>
<li>
<p>Some other functions may need devices, e.g. /dev/zero or /dev/null.</p>
</li>
</ul>
</dd> </dd>
<dt><strong><a name="compression_deflate_zlib_rle" class="item"><strong>compression</strong> = deflate | zlib | rle</a></strong></dt> <dt><strong><a name="compression_deflate_zlib_rle" class="item"><strong>compression</strong> = deflate | zlib | rle</a></strong></dt>
@ -199,9 +211,9 @@ to the directory specified with <strong>chroot</strong>.</p>
<p>select data compression algorithm</p> <p>select data compression algorithm</p>
<p>default: no compression</p> <p>default: no compression</p>
<p>deflate is the standard compression method as described in <a href="http://www.ietf.org/rfc/rfc1951.txt" class="rfc">RFC 1951</a>.</p> <p>deflate is the standard compression method as described in <a href="http://www.ietf.org/rfc/rfc1951.txt" class="rfc">RFC 1951</a>.</p>
<p>zlib compression of OpenSSL 0.9.8 or above is not backward compatible with <p>zlib compression of <strong>OpenSSL 0.9.8</strong> or above is not backward compatible with
OpenSSL 0.9.7.</p> <strong>OpenSSL 0.9.7</strong>.</p>
<p>rle compression is currently not implemented by the OpenSSL library.</p> <p>rle compression is currently not implemented by the <strong>OpenSSL</strong> library.</p>
</dd> </dd>
<dt><strong><a name="debug_facility_level" class="item"><strong>debug</strong> = [facility.]level</a></strong></dt> <dt><strong><a name="debug_facility_level" class="item"><strong>debug</strong> = [facility.]level</a></strong></dt>
@ -216,12 +228,12 @@ all levels numerically less than it will be shown. Use <em>debug = debug</em> o
(Facilities are not supported on Win32.)</p> (Facilities are not supported on Win32.)</p>
<p>Case is ignored for both facilities and levels.</p> <p>Case is ignored for both facilities and levels.</p>
</dd> </dd>
<dt><strong><strong>EGD</strong> = egd path (Unix only)</strong></dt> <dt><strong><a name="path" class="item"><strong>EGD</strong> = egd path (Unix only)</a></strong></dt>
<dd> <dd>
<p>path to Entropy Gathering Daemon socket</p> <p>path to Entropy Gathering Daemon socket</p>
<p>Entropy Gathering Daemon socket to use to feed OpenSSL random number <p>Entropy Gathering Daemon socket to use to feed <strong>OpenSSL</strong> random number
generator. (Available only if compiled with OpenSSL 0.9.5a or higher)</p> generator. (Available only if compiled with <strong>OpenSSL 0.9.5a</strong> or higher)</p>
</dd> </dd>
<dt><strong><a name="engine_auto_engine_id" class="item"><strong>engine</strong> = auto | &lt;engine id&gt;</a></strong></dt> <dt><strong><a name="engine_auto_engine_id" class="item"><strong>engine</strong> = auto | &lt;engine id&gt;</a></strong></dt>
@ -254,8 +266,8 @@ engine cryptogaphic module.</p>
<dd> <dd>
<p>Enable or disable FIPS 140-2 mode.</p> <p>Enable or disable FIPS 140-2 mode.</p>
<p>This option allows to disable entering FIPS mode if stunnel was compiled with <p>This option allows to disable entering FIPS mode if <strong>stunnel</strong> was compiled
FIPS 140-2 support.</p> with FIPS 140-2 support.</p>
<p>default: yes</p> <p>default: yes</p>
</dd> </dd>
<dt><strong><a name="no" class="item"><strong>foreground</strong> = yes | no (Unix only)</a></strong></dt> <dt><strong><a name="no" class="item"><strong>foreground</strong> = yes | no (Unix only)</a></strong></dt>
@ -284,9 +296,9 @@ output (for example to log them with daemontools splogger).</p>
<dd> <dd>
<p>bytes to read from random seed files</p> <p>bytes to read from random seed files</p>
<p>Number of bytes of data read from random seed files. With SSL versions <p>Number of bytes of data read from random seed files. With SSL versions less
less than 0.9.5a, also determines how many bytes of data are considered than <strong>0.9.5a</strong>, also determines how many bytes of data are considered
sufficient to seed the PRNG. More recent OpenSSL versions have a builtin sufficient to seed the PRNG. More recent <strong>OpenSSL</strong> versions have a builtin
function to determine when sufficient randomness is available.</p> function to determine when sufficient randomness is available.</p>
</dd> </dd>
<dt><strong><a name="rndfile_file" class="item"><strong>RNDfile</strong> = file</a></strong></dt> <dt><strong><a name="rndfile_file" class="item"><strong>RNDfile</strong> = file</a></strong></dt>
@ -311,12 +323,12 @@ number generator.</p>
<dt><strong><a name="groupname" class="item"><strong>setgid</strong> = groupname (Unix only)</a></strong></dt> <dt><strong><a name="groupname" class="item"><strong>setgid</strong> = groupname (Unix only)</a></strong></dt>
<dd> <dd>
<p><a href="#setgid"><code>setgid()</code></a> to groupname in daemon mode and clears all other groups</p> <p><code>setgid()</code> to groupname in daemon mode and clears all other groups</p>
</dd> </dd>
<dt><strong><a name="username" class="item"><strong>setuid</strong> = username (Unix only)</a></strong></dt> <dt><strong><a name="username" class="item"><strong>setuid</strong> = username (Unix only)</a></strong></dt>
<dd> <dd>
<p><a href="#setuid"><code>setuid()</code></a> to username in daemon mode</p> <p><code>setuid()</code> to username in daemon mode</p>
</dd> </dd>
<dt><strong><a name="socket_a_l_r_option_value_value" class="item"><strong>socket</strong> = a|l|r:option=value[:value]</a></strong></dt> <dt><strong><a name="socket_a_l_r_option_value_value" class="item"><strong>socket</strong> = a|l|r:option=value[:value]</a></strong></dt>
@ -377,8 +389,8 @@ below.</p>
the <em>verify</em>. Note that the certificates in this directory should be named the <em>verify</em>. 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 XXXXXXXX.0 where XXXXXXXX is the hash value of the DER encoded subject of the
cert.</p> cert.</p>
<p>The hash algorithm has been changed in OpenSSL 1.0.0. It is required to <p>The hash algorithm has been changed in <strong>OpenSSL 1.0.0</strong>. It is required to
c_rehash the directory on upgrade from OpenSSL 0.x.x to OpenSSL 1.x.x.</p> c_rehash the directory on upgrade from <strong>OpenSSL 0.x.x</strong> to <strong>OpenSSL 1.x.x</strong>.</p>
<p><em>CApath</em> path is relative to <em>chroot</em> directory if specified.</p> <p><em>CApath</em> path is relative to <em>chroot</em> directory if specified.</p>
</dd> </dd>
<dt><strong><a name="cafile_certfile" class="item"><strong>CAfile</strong> = certfile</a></strong></dt> <dt><strong><a name="cafile_certfile" class="item"><strong>CAfile</strong> = certfile</a></strong></dt>
@ -427,8 +439,8 @@ round-robin algorithm.</p>
<p>This is the directory in which <strong>stunnel</strong> will look for CRLs when <p>This is the directory in which <strong>stunnel</strong> will look for CRLs when
using the <em>verify</em>. Note that the CRLs in this directory should using the <em>verify</em>. Note that the CRLs in this directory should
be named XXXXXXXX.r0 where XXXXXXXX is the hash value of the CRL.</p> be named XXXXXXXX.r0 where XXXXXXXX is the hash value of the CRL.</p>
<p>The hash algorithm has been changed in OpenSSL 1.0.0. It is required to <p>The hash algorithm has been changed in <strong>OpenSSL 1.0.0</strong>. It is required to
c_rehash the directory on upgrade from OpenSSL 0.x.x to OpenSSL 1.x.x.</p> c_rehash the directory on upgrade from <strong>OpenSSL 0.x.x</strong> to <strong>OpenSSL 1.x.x</strong>.</p>
<p><em>CRLpath</em> path is relative to <em>chroot</em> directory if specified.</p> <p><em>CRLpath</em> path is relative to <em>chroot</em> directory if specified.</p>
</dd> </dd>
<dt><strong><a name="crlfile_certfile" class="item"><strong>CRLfile</strong> = certfile</a></strong></dt> <dt><strong><a name="crlfile_certfile" class="item"><strong>CRLfile</strong> = certfile</a></strong></dt>
@ -451,7 +463,7 @@ c_rehash the directory on upgrade from OpenSSL 0.x.x to OpenSSL 1.x.x.</p>
<dd> <dd>
<p>delay DNS lookup for 'connect' option</p> <p>delay DNS lookup for 'connect' option</p>
<p>This option is useful for dynamic DNS, or when DNS is not available during <p>This option is useful for dynamic DNS, or when DNS is not available during
stunnel startup (road warrior VPN, dial-up configurations).</p> <strong>stunnel</strong> startup (road warrior VPN, dial-up configurations).</p>
</dd> </dd>
<dt><strong><a name="enginenum_engine_number" class="item"><strong>engineNum</strong> = engine number</a></strong></dt> <dt><strong><a name="enginenum_engine_number" class="item"><strong>engineNum</strong> = engine number</a></strong></dt>
@ -509,28 +521,31 @@ to its owner. On Unix systems you can use the following command:</p>
<p>IP of the outgoing interface is used as source for remote connections. <p>IP of the outgoing interface is used as source for remote connections.
Use this option to bind a static local IP address, instead.</p> Use this option to bind a static local IP address, instead.</p>
</dd> </dd>
<dt><strong><a name="server_name" class="item"><strong>sni</strong> = service_name:server_name (server mode)</a></strong></dt> <dt><strong><a name="server_name_pattern" class="item"><strong>sni</strong> = service_name:server_name_pattern (server mode)</a></strong></dt>
<dd> <dd>
<p>Use the service as a slave service (a name-based virtual server) for Server <p>Use the service as a slave service (a name-based virtual server) for Server
Name Indication TLS extension (<a href="http://www.ietf.org/rfc/rfc3546.txt" class="rfc">RFC 3546</a>).</p> Name Indication TLS extension (<a href="http://www.ietf.org/rfc/rfc3546.txt" class="rfc">RFC 3546</a>).</p>
<p><em>service_name</em> specifies the master service that accepts client connections <p><em>service_name</em> specifies the master service that accepts client connections
with <em>accept</em> option. <em>server_name</em> specifies the host name to be redirected. with <em>accept</em> option. <em>server_name_pattern</em> specifies the host name to be
redirected. The pattern may start with '*' character, e.g. '*.example.com'.
Multiple slave services are normally specified for a single master service. Multiple slave services are normally specified for a single master service.
<em>sni</em> option can also be specified more than once within a single slave service.</p> <em>sni</em> option can also be specified more than once within a single slave
<p>This service, as well as the master service, may not be configured in client mode. service.</p>
<em>connect</em> option of the slave service is ignored when <em>protocol</em> option is <p>This service, as well as the master service, may not be configured in client
specified, as <em>protocol</em> connects remote host before TLS handshake. mode.</p>
Libwrap checks (Unix only) are performed twice: with master service name after <p><em>connect</em> option of the slave service is ignored when <em>protocol</em> option is
specified, as <em>protocol</em> connects remote host before TLS handshake.</p>
<p>Libwrap checks (Unix only) are performed twice: with master service name after
TCP connection is accepted, and with slave service name during TLS handshake.</p> TCP connection is accepted, and with slave service name during TLS handshake.</p>
<p>Option <em>sni</em> is only available when compiled with OpenSSL 1.0.0 and later.</p> <p>Option <em>sni</em> is only available when compiled with <strong>OpenSSL 1.0.0</strong> and later.</p>
</dd> </dd>
<dt><strong><strong>sni</strong> = server_name (client mode)</strong></dt> <dt><strong><a name="server_name" class="item"><strong>sni</strong> = server_name (client mode)</a></strong></dt>
<dd> <dd>
<p>Use the parameter as the value of TLS Server Name Indication (<a href="http://www.ietf.org/rfc/rfc3546.txt" class="rfc">RFC 3546</a>) <p>Use the parameter as the value of TLS Server Name Indication (<a href="http://www.ietf.org/rfc/rfc3546.txt" class="rfc">RFC 3546</a>)
extension.</p> extension.</p>
<p>Option <em>sni</em> is only available when compiled with OpenSSL 1.0.0 and later.</p> <p>Option <em>sni</em> is only available when compiled with <strong>OpenSSL 1.0.0</strong> and later.</p>
</dd> </dd>
<dt><strong><a name="ocsp_url" class="item"><strong>OCSP</strong> = url</a></strong></dt> <dt><strong><a name="ocsp_url" class="item"><strong>OCSP</strong> = url</a></strong></dt>
@ -548,8 +563,8 @@ NOEXPLICIT, NOCASIGN, NODELEGATED, NOCHECKS, TRUSTOTHER, RESPID_KEY, NOTIME</p>
<dt><strong><a name="options_ssl_options" class="item"><strong>options</strong> = SSL_options</a></strong></dt> <dt><strong><a name="options_ssl_options" class="item"><strong>options</strong> = SSL_options</a></strong></dt>
<dd> <dd>
<p>OpenSSL library options</p> <p><strong>OpenSSL</strong> library options</p>
<p>The parameter is the OpenSSL option name as described in the <p>The parameter is the <strong>OpenSSL</strong> option name as described in the
<em>SSL_CTX_set_options(3ssl)</em> manual, but without <em>SSL_OP_</em> prefix. <em>SSL_CTX_set_options(3ssl)</em> manual, but without <em>SSL_OP_</em> prefix.
Several <em>options</em> can be used to specify multiple options.</p> Several <em>options</em> can be used to specify multiple options.</p>
<p>For example for compatibility with erroneous Eudora SSL implementation <p>For example for compatibility with erroneous Eudora SSL implementation
@ -560,8 +575,10 @@ the following option can be used:</p>
<dt><strong><a name="protocol_proto" class="item"><strong>protocol</strong> = proto</a></strong></dt> <dt><strong><a name="protocol_proto" class="item"><strong>protocol</strong> = proto</a></strong></dt>
<dd> <dd>
<p>application protocol to negotiate SSL (e.g. <em>starttls</em> or <em>stls</em>)</p> <p>application protocol to negotiate SSL</p>
<p><em>protocol</em> option should not be used with SSL encryption on a separate port.</p> <p>This option enables initial, protocol-specific negotiation of the SSL/TLS
encryption.
<em>protocol</em> option should not be used with SSL encryption on a separate port.</p>
<p>Currently supported protocols:</p> <p>Currently supported protocols:</p>
<dl> <dl>
<dt><strong><a name="cifs" class="item"><em>cifs</em></a></strong></dt> <dt><strong><a name="cifs" class="item"><em>cifs</em></a></strong></dt>
@ -614,13 +631,17 @@ Support for this extension was dropped in Samba 3.0.0.</p>
<dd> <dd>
<p>authentication type for protocol negotiations</p> <p>authentication type for protocol negotiations</p>
<p>currently supported: basic, NTLM</p> <p>currently supported: basic, NTLM</p>
<p>Currently authentication type only applies to 'connect' protocol.</p> <p>Currently authentication type only applies to the 'connect' protocol.</p>
<p>default: basic</p> <p>default: basic</p>
</dd> </dd>
<dt><strong><a name="protocolhost_host_port" class="item"><strong>protocolHost</strong> = host:port</a></strong></dt> <dt><strong><a name="protocolhost_host_port" class="item"><strong>protocolHost</strong> = host:port</a></strong></dt>
<dd> <dd>
<p>destination address for protocol negotiations</p> <p>destination address for protocol negotiations</p>
<p><em>protocolHost</em> specifies the final SSL server to be connected by the proxy,
and not the proxy server directly connected by <strong>stunnel</strong>.
The proxy server should be specified with the 'connect' option.</p>
<p>Currently protocol destination address only applies to 'connect' protocol.</p>
</dd> </dd>
<dt><strong><a name="protocolpassword_password" class="item"><strong>protocolPassword</strong> = password</a></strong></dt> <dt><strong><a name="protocolpassword_password" class="item"><strong>protocolPassword</strong> = password</a></strong></dt>
@ -637,16 +658,46 @@ Support for this extension was dropped in Samba 3.0.0.</p>
<dd> <dd>
<p>allocate pseudo terminal for 'exec' option</p> <p>allocate pseudo terminal for 'exec' option</p>
</dd> </dd>
<dt><strong><strong>retry</strong> = yes | no (Unix only)</strong></dt> <dt><strong><a name="renegotiation_yes_no" class="item"><strong>renegotiation</strong> = yes | no</a></strong></dt>
<dd>
<p>support SSL renegotiation</p>
<p>Applications of the SSL renegotiation include some authentication scenarios,
or re-keying long lasting connections.</p>
<p>On the other hand this feature can facilitate a trivial CPU-exhaustion
DoS attack:</p>
<p><a href="http://vincent.bernat.im/en/blog/2011-ssl-dos-mitigation.html">http://vincent.bernat.im/en/blog/2011-ssl-dos-mitigation.html</a></p>
<p>Please note that disabling SSL renegotiation does not fully mitigate
this issue.</p>
<p>default: yes (if supported by <strong>OpenSSL</strong>)</p>
</dd>
<dt><strong><a name="reset_yes_no" class="item"><strong>reset</strong> = yes | no</a></strong></dt>
<dd>
<p>attempt to use TCP RST flag to indicate an error</p>
<p>This option is not supported on some platforms.</p>
<p>default: yes</p>
</dd>
<dt><strong><a name="retry_yes_no" class="item"><strong>retry</strong> = yes | no</a></strong></dt>
<dd> <dd>
<p>reconnect a connect+exec section after it's disconnected</p> <p>reconnect a connect+exec section after it's disconnected</p>
<p>default: no</p> <p>default: no</p>
</dd> </dd>
<dt><strong><a name="session_timeout" class="item"><strong>session</strong> = timeout</a></strong></dt> <dt><strong><a name="sessioncachesize_size" class="item"><strong>sessionCacheSize</strong> = size</a></strong></dt>
<dd>
<p>session cache size</p>
<p><em>sessionCacheSize</em> specifies the maximum number of the internal session cache
entries.</p>
<p>The value of 0 can be used for unlimited size. It is not recommended
for production use due to the risk of memory exhaustion DoS attack.</p>
</dd>
<dt><strong><a name="sessioncachetimeout_timeout" class="item"><strong>sessionCacheTimeout</strong> = timeout</a></strong></dt>
<dd> <dd>
<p>session cache timeout</p> <p>session cache timeout</p>
<p>This is the number of seconds to keep cached SSL sessions.</p>
</dd> </dd>
<dt><strong><a name="sessiond_host_port" class="item"><strong>sessiond</strong> = host:port</a></strong></dt> <dt><strong><a name="sessiond_host_port" class="item"><strong>sessiond</strong> = host:port</a></strong></dt>
@ -657,7 +708,7 @@ Support for this extension was dropped in Samba 3.0.0.</p>
<dd> <dd>
<p>select version of SSL protocol</p> <p>select version of SSL protocol</p>
<p>Allowed options: all, SSLv2, SSLv3, TLSv1</p> <p>Allowed options: all, SSLv2, SSLv3, TLSv1, TLSv1.1, TLSv1.2</p>
</dd> </dd>
<dt><strong><a name="bytes" class="item"><strong>stack</strong> = bytes (except for FORK model)</a></strong></dt> <dt><strong><a name="bytes" class="item"><strong>stack</strong> = bytes (except for FORK model)</a></strong></dt>
@ -705,7 +756,7 @@ from the SSL client machine instead of the machine running <strong>stunnel</stro
<dt><strong><a name="mode" class="item">Remote mode (<em>connect</em> option) on <em>Linux &gt;=2.6.28</em></a></strong></dt> <dt><strong><a name="mode" class="item">Remote mode (<em>connect</em> option) on <em>Linux &gt;=2.6.28</em></a></strong></dt>
<dd> <dd>
<p>This configuration requires stunnel to be executed as root and without <p>This configuration requires <strong>stunnel</strong> to be executed as root and without
<em>setuid</em> option.</p> <em>setuid</em> option.</p>
<p>This configuration requires the following setup for iptables and routing <p>This configuration requires the following setup for iptables and routing
(possibly in /etc/rc.local or equivalent file):</p> (possibly in /etc/rc.local or equivalent file):</p>
@ -722,9 +773,10 @@ from the SSL client machine instead of the machine running <strong>stunnel</stro
<dt><strong>Remote mode (<em>connect</em> option) on <em>Linux 2.2.x</em></strong></dt> <dt><strong>Remote mode (<em>connect</em> option) on <em>Linux 2.2.x</em></strong></dt>
<dd> <dd>
<p>This configuration requires kernel to be compiled with <em>transparent proxy</em> option. <p>This configuration requires kernel to be compiled with <em>transparent proxy</em>
option.
Connected service must be installed on a separate host. Connected service must be installed on a separate host.
Routing towards the clients has to go through the stunnel box.</p> Routing towards the clients has to go through the <strong>stunnel</strong> box.</p>
<p><strong>stunnel</strong> must also to be executed as root and without <em>setuid</em> option.</p> <p><strong>stunnel</strong> must also to be executed as root and without <em>setuid</em> option.</p>
</dd> </dd>
<dt><strong>Remote mode (<em>connect</em> option) on <em>FreeBSD &gt;=8.0</em></strong></dt> <dt><strong>Remote mode (<em>connect</em> option) on <em>FreeBSD &gt;=8.0</em></strong></dt>
@ -784,18 +836,36 @@ other platforms.</p>
<dd> <dd>
<p>verify peer certificate</p> <p>verify peer certificate</p>
<dl> <dl>
<dt><strong><a name="level_0_request_and_ignore_peer_certificate" class="item"><em>level 0</em> - request and ignore peer certificate</a></strong></dt> <dt><strong><a name="level_0" class="item">level 0</a></strong></dt>
<dt><strong><a name="level_1_verify_peer_certificate_if_present" class="item"><em>level 1</em> - verify peer certificate if present</a></strong></dt> <dd>
<p>Request and ignore peer certificate.</p>
</dd>
<dt><strong><a name="level_1" class="item">level 1</a></strong></dt>
<dt><strong><a name="level_2_verify_peer_certificate" class="item"><em>level 2</em> - verify peer certificate</a></strong></dt> <dd>
<p>Verify peer certificate if present.</p>
</dd>
<dt><strong><a name="level_2" class="item">level 2</a></strong></dt>
<dt><strong><a name="level_3_verify_peer_with_locally_installed_certificate" class="item"><em>level 3</em> - verify peer with locally installed certificate</a></strong></dt> <dd>
<p>Verify peer certificate.</p>
</dd>
<dt><strong><a name="level_3" class="item">level 3</a></strong></dt>
<dt><strong><a name="level_4_ignore_ca_chain_and_only_verify_peer_certificate" class="item"><em>level 4</em> - ignore CA chain and only verify peer certificate</a></strong></dt> <dd>
<p>Verify peer with locally installed certificate.</p>
</dd>
<dt><strong><a name="level_4" class="item">level 4</a></strong></dt>
<dt><strong><a name="default_no_verify" class="item"><em>default</em> - no verify</a></strong></dt> <dd>
<p>Ignore CA chain and only verify peer certificate.</p>
</dd>
<dt><strong><a name="default" class="item">default</a></strong></dt>
<dd>
<p>No verify.</p>
</dd>
</dl> </dl>
<p>It is important to understand, that this option was solely designed for access <p>It is important to understand, that this option was solely designed for access
control and not for authorization. Specifically for level 2 every non-revoked control and not for authorization. Specifically for level 2 every non-revoked
@ -813,7 +883,7 @@ for webservers. Level 3 is preferred for point-to-point connections.</p>
</p> </p>
<hr /> <hr />
<h1><a name="signals">SIGNALS</a></h1> <h1><a name="signals">SIGNALS</a></h1>
<p>The following signals can be used to control stunnel in Unix environment:</p> <p>The following signals can be used to control <strong>stunnel</strong> in Unix environment:</p>
<dl> <dl>
<dt><strong><a name="sighup" class="item">SIGHUP</a></strong></dt> <dt><strong><a name="sighup" class="item">SIGHUP</a></strong></dt>
@ -821,38 +891,38 @@ for webservers. Level 3 is preferred for point-to-point connections.</p>
<p>Force a reload of the configuration file.</p> <p>Force a reload of the configuration file.</p>
<p>Some global options will not be reloaded:</p> <p>Some global options will not be reloaded:</p>
<ul> <ul>
<li><strong><a name="chroot" class="item">chroot</a></strong> <li>
<p>chroot</p>
</li> </li>
<li><strong><a name="foreground" class="item">foreground</a></strong> <li>
<p>foreground</p>
</li> </li>
<li><strong><a name="pid" class="item">pid</a></strong> <li>
<p>pid</p>
</li> </li>
<li><strong><a name="setgid" class="item">setgid</a></strong> <li>
<p>setgid</p>
</li> </li>
<li><strong><a name="setuid" class="item">setuid</a></strong> <li>
<p>setuid</p>
</li> </li>
</ul> </ul>
<p>The use of 'setuid' option will also prevent stunnel from binding privileged <p>The use of 'setuid' option will also prevent <strong>stunnel</strong> from binding privileged
(&lt;1024) ports during configuration reloading.</p> (&lt;1024) ports during configuration reloading.</p>
<p>When 'chroot' option is used, stunnel will look for all its files (including <p>When 'chroot' option is used, <strong>stunnel</strong> will look for all its files (including
configuration file, certificates, log file and pid file) within the chroot configuration file, certificates, log file and pid file) within the chroot
jail.</p> jail.</p>
</dd> </dd>
<dt><strong><a name="sigusr1" class="item">SIGUSR1</a></strong></dt> <dt><strong><a name="sigusr1" class="item">SIGUSR1</a></strong></dt>
<dd> <dd>
<p>Close and reopen stunnel log file. <p>Close and reopen <strong>stunnel</strong> log file.
This function can be used for log rotation.</p> This function can be used for log rotation.</p>
</dd> </dd>
<dt><strong><a name="sigterm_sigquit_sigint" class="item">SIGTERM, SIGQUIT, SIGINT</a></strong></dt> <dt><strong><a name="sigterm_sigquit_sigint" class="item">SIGTERM, SIGQUIT, SIGINT</a></strong></dt>
<dd> <dd>
<p>Shut stunnel down.</p> <p>Shut <strong>stunnel</strong> down.</p>
</dd> </dd>
</dl> </dl>
<p>The result of sending any other signals to the server is undefined.</p> <p>The result of sending any other signals to the server is undefined.</p>
@ -917,7 +987,7 @@ configurations.</p>
<p>Each SSL enabled daemon needs to present a valid X.509 certificate <p>Each SSL enabled daemon needs to present a valid X.509 certificate
to the peer. It also needs a private key to decrypt the incoming 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 data. The easiest way to obtain a certificate and a key is to
generate them with the free <em>OpenSSL</em> package. You can find more generate them with the free <strong>OpenSSL</strong> package. You can find more
information on certificates generation on pages listed below.</p> information on certificates generation on pages listed below.</p>
<p>The order of contents of the <em>.pem</em> file is important. It should contain the <p>The order of contents of the <em>.pem</em> file is important. It should contain the
unencrypted private key first, then a signed certificate (not certificate unencrypted private key first, then a signed certificate (not certificate
@ -940,35 +1010,35 @@ should be discarded. So the file should look like this:</p>
order for SSL to use good randomness. The following sources are loaded order for SSL to use good randomness. The following sources are loaded
in order until sufficient random data has been gathered:</p> in order until sufficient random data has been gathered:</p>
<ul> <ul>
<li><strong><a name="the_file_specified_with_the_rndfile_flag" class="item">The file specified with the <em>RNDfile</em> flag.</a></strong> <li>
<p>The file specified with the <em>RNDfile</em> flag.</p>
</li> </li>
<li><strong><a name="the_file_specified_by_the_randfile_environment_variable_if_set" class="item">The file specified by the RANDFILE environment variable, if set.</a></strong> <li>
<p>The file specified by the RANDFILE environment variable, if set.</p>
</li> </li>
<li><strong><a name="the_file_rnd_in_your_home_directory_if_randfile_not_set" class="item">The file .rnd in your home directory, if RANDFILE not set.</a></strong> <li>
<p>The file .rnd in your home directory, if RANDFILE not set.</p>
</li> </li>
<li><strong><a name="the_file_specified_with_with_random_at_compile_time" class="item">The file specified with '--with-random' at compile time.</a></strong> <li>
<p>The file specified with '--with-random' at compile time.</p>
</li> </li>
<li><strong><a name="the_contents_of_the_screen_if_running_on_windows" class="item">The contents of the screen if running on Windows.</a></strong> <li>
<p>The contents of the screen if running on Windows.</p>
</li> </li>
<li><strong><a name="the_egd_socket_specified_with_the_egd_flag" class="item">The egd socket specified with the <em>EGD</em> flag.</a></strong> <li>
<p>The egd socket specified with the <em>EGD</em> flag.</p>
</li> </li>
<li><strong><a name="the_egd_socket_specified_with_with_egd_sock_at_compile_time" class="item">The egd socket specified with '--with-egd-sock' at compile time.</a></strong> <li>
<p>The egd socket specified with '--with-egd-sock' at compile time.</p>
</li> </li>
<li><strong><a name="the_dev_urandom_device" class="item">The /dev/urandom device.</a></strong> <li>
<p>The /dev/urandom device.</p>
</li> </li>
</ul> </ul>
<p>With recent (&gt;=OpenSSL 0.9.5a) version of SSL it will stop loading <p>With recent (<strong>OpenSSL 0.9.5a</strong> or later) version of SSL it will stop loading
random data automatically when sufficient entropy has been gathered. random data automatically when sufficient entropy has been gathered. With
With previous versions it will continue to gather from all the above previous versions it will continue to gather from all the above sources since
sources since no SSL function exists to tell when enough data is available.</p> no SSL function exists to tell when enough data is available.</p>
<p>Note that on Windows machines that do not have console user interaction <p>Note that on Windows machines that do not have console user interaction
(mouse movements, creating windows, etc.) the screen contents are not (mouse movements, creating windows, etc.) the screen contents are not
variable enough to be sufficient, and you should provide a random file variable enough to be sufficient, and you should provide a random file
@ -977,13 +1047,12 @@ for use with the <em>RNDfile</em> flag.</p>
random data -- that means it should contain different information random data -- that means it should contain different information
each time <strong>stunnel</strong> is run. This is handled automatically each time <strong>stunnel</strong> is run. This is handled automatically
unless the <em>RNDoverwrite</em> flag is used. If you wish to update this file unless the <em>RNDoverwrite</em> flag is used. If you wish to update this file
manually, the <em>openssl rand</em> command in recent versions of OpenSSL, manually, the <em>openssl rand</em> command in recent versions of <strong>OpenSSL</strong>,
would be useful.</p> would be useful.</p>
<p>One important note -- if /dev/urandom is available, OpenSSL has a habit of <p>Important note: If /dev/urandom is available, <strong>OpenSSL</strong> often seeds the PRNG
seeding the PRNG with it even when checking the random state, so on with it while checking the random state. On systems with /dev/urandom
systems with /dev/urandom you're likely to use it even though it's listed <strong>OpenSSL</strong> is likely to use it even though it is listed at the very bottom of
at the very bottom of the list above. This isn't <strong>stunnel's</strong> behaviour, it's the list above. This is the behaviour of <strong>OpenSSL</strong> and not <strong>stunnel</strong>.</p>
OpenSSLs.</p>
<p> <p>
</p> </p>
<h2><a name="dh_parameters">DH PARAMETERS</a></h2> <h2><a name="dh_parameters">DH PARAMETERS</a></h2>
@ -1007,7 +1076,7 @@ OpenSSLs.</p>
</p> </p>
<hr /> <hr />
<h1><a name="bugs">BUGS</a></h1> <h1><a name="bugs">BUGS</a></h1>
<p>Option <em>execargs</em> does not support quoting.</p> <p>Option <em>execargs</em> and Win32 command line does not support quoting.</p>
<p> <p>
</p> </p>
<hr /> <hr />
@ -1031,7 +1100,7 @@ OpenSSLs.</p>
<dt><strong><a name="http_www_openssl_org" class="item"><em class="file"><a href="http://www.openssl.org/">http://www.openssl.org/</a></em></a></strong></dt> <dt><strong><a name="http_www_openssl_org" class="item"><em class="file"><a href="http://www.openssl.org/">http://www.openssl.org/</a></em></a></strong></dt>
<dd> <dd>
<p>OpenSSL project website</p> <p><strong>OpenSSL</strong> project website</p>
</dd> </dd>
</dl> </dl>
<p> <p>

View File

@ -62,7 +62,7 @@
.\" ======================================================================== .\" ========================================================================
.\" .\"
.IX Title "STUNNEL.PL 8" .IX Title "STUNNEL.PL 8"
.TH STUNNEL.PL 8 "2012.01.14" "4.53" "stunnel" .TH STUNNEL.PL 8 "2013.03.22" "4.56" "stunnel"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents. .\" way too many mistakes in technical documents.
.if n .ad l .if n .ad l
@ -158,6 +158,18 @@ Opcja określa katalog, w którym uwięziony zostanie proces programu
połączeń. Ścieżki podane w opcjach \fICApath\fR, \fICRLpath\fR, \fIpid\fR połączeń. Ścieżki podane w opcjach \fICApath\fR, \fICRLpath\fR, \fIpid\fR
oraz \fIexec\fR muszą być umieszczone wewnątrz katalogu podanego w opcji oraz \fIexec\fR muszą być umieszczone wewnątrz katalogu podanego w opcji
\&\fIchroot\fR i określone względem tego katalogu. \&\fIchroot\fR i określone względem tego katalogu.
.Sp
Niektóre funkcje systemu operacyjnego mogą wymagać dodatkowych plików umieszczonych w katalogu podanego w parametrze chroot:
.RS 4
.IP "\(bu" 4
opóźnione rozwinięcie adresów \s-1DNS\s0 typowo wymaga /etc/nsswitch.conf i /etc/resolv.conf
.IP "\(bu" 4
lokalizacja strefy czasowej w logach wymaga pliku /etc/timezone
.IP "\(bu" 4
niektóre inne pliki mogą potrzebować plików urządzeń, np. /dev/zero lub /dev/null
.RE
.RS 4
.RE
.IP "\fBcompression\fR = deflate | zlib | rle" 4 .IP "\fBcompression\fR = deflate | zlib | rle" 4
.IX Item "compression = deflate | zlib | rle" .IX Item "compression = deflate | zlib | rle"
wybór algorytmu kompresji przesyłanych danych wybór algorytmu kompresji przesyłanych danych
@ -166,10 +178,10 @@ domyślnie: bez kompresji
.Sp .Sp
Algorytm deflate jest standardową metodą kompresji zgodnie z \s-1RFC\s0 1951. Algorytm deflate jest standardową metodą kompresji zgodnie z \s-1RFC\s0 1951.
.Sp .Sp
Kompresja zlib zaimplementowana w OpenSSL 0.9.8 i nowszych nie jest Kompresja zlib zaimplementowana w \fBOpenSSL 0.9.8\fR i nowszych nie jest
kompatybilna implementacją OpenSSL 0.9.7. kompatybilna implementacją \fBOpenSSL 0.9.7\fR.
.Sp .Sp
Kompresja rle nie jest zaimplementowana w aktualnych wersjach OpenSSL. Kompresja rle nie jest zaimplementowana w aktualnych wersjach \fBOpenSSL\fR.
.IP "\fBdebug\fR = poziom[.podsystem]" 4 .IP "\fBdebug\fR = poziom[.podsystem]" 4
.IX Item "debug = poziom[.podsystem]" .IX Item "debug = poziom[.podsystem]"
szczegółowość logowania szczegółowość logowania
@ -191,7 +203,7 @@ Wielkość liter jest ignorowana zarówno dla poziomu jak podsystemu.
.Sp .Sp
Opcja pozwala określić ścieżkę do gniazda programu Entropy Gathering Daemon Opcja pozwala określić ścieżkę do gniazda programu Entropy Gathering Daemon
używanego do zainicjalizowania generatora ciągów pseudolosowych biblioteki używanego do zainicjalizowania generatora ciągów pseudolosowych biblioteki
OpenSSL. Opcja jest dostępna z biblioteką OpenSSL 0.9.5a lub nowszą. \&\fBOpenSSL\fR. Opcja jest dostępna z biblioteką \fBOpenSSL 0.9.5a\fR lub nowszą.
.IP "\fBengine\fR = auto | <identyfikator urządzenia>" 4 .IP "\fBengine\fR = auto | <identyfikator urządzenia>" 4
.IX Item "engine = auto | <identyfikator urządzenia>" .IX Item "engine = auto | <identyfikator urządzenia>"
wybór sprzętowego urządzenia kryptograficznego wybór sprzętowego urządzenia kryptograficznego
@ -224,15 +236,15 @@ modułu kryptograficznego urządzenia.
.IX Item "fips = yes | no" .IX Item "fips = yes | no"
Włącz lub wyłącz tryb \s-1FIPS\s0 140\-2. Włącz lub wyłącz tryb \s-1FIPS\s0 140\-2.
.Sp .Sp
Opcja pozwala wyłączyć wejście w tryb \s-1FIPS\s0, jeśli stunnel został skompilowany Opcja pozwala wyłączyć wejście w tryb \s-1FIPS\s0, jeśli \fBstunnel\fR został
ze wsparciem dla \s-1FIPS\s0 140\-2. skompilowany ze wsparciem dla \s-1FIPS\s0 140\-2.
.Sp .Sp
domyślnie: yes (pracuj w trybie \s-1FIPS\s0 140\-2) domyślnie: yes (pracuj w trybie \s-1FIPS\s0 140\-2)
.IP "\fBforeground\fR = yes | no (tylko Unix)" 4 .IP "\fBforeground\fR = yes | no (tylko Unix)" 4
.IX Item "foreground = yes | no (tylko Unix)" .IX Item "foreground = yes | no (tylko Unix)"
tryb pierwszoplanowy tryb pierwszoplanowy
.Sp .Sp
Użycie tej opcji powoduje, że \fIstunnel\fR nie przechodzi w tło logując Użycie tej opcji powoduje, że \fBstunnel\fR nie przechodzi w tło logując
swoje komunikaty na konsolę zamiast przez \fIsyslog\fR (o ile nie użyto swoje komunikaty na konsolę zamiast przez \fIsyslog\fR (o ile nie użyto
opcji \fIoutput\fR). opcji \fIoutput\fR).
.IP "\fBoutput\fR = plik" 4 .IP "\fBoutput\fR = plik" 4
@ -256,7 +268,7 @@ względem tego katalogu.
.IX Item "RNDbytes = liczba_bajtów" .IX Item "RNDbytes = liczba_bajtów"
liczba bajtów do zainicjowania generatora pseudolosowego liczba bajtów do zainicjowania generatora pseudolosowego
.Sp .Sp
W wersjach biblioteki OpenSSL starszych niż 0.9.5a opcja ta określa W wersjach biblioteki \fBOpenSSL\fR starszych niż \fB0.9.5a\fR opcja ta określa
również liczbę bajtów wystarczających do zainicjowania \s-1PRNG\s0. również liczbę bajtów wystarczających do zainicjowania \s-1PRNG\s0.
Nowsze wersje biblioteki mają wbudowaną funkcję określającą, czy Nowsze wersje biblioteki mają wbudowaną funkcję określającą, czy
dostarczona ilość losowości jest wystarczająca do zainicjowania generatora. dostarczona ilość losowości jest wystarczająca do zainicjowania generatora.
@ -264,7 +276,7 @@ dostarczona ilość losowości jest wystarczająca do zainicjowania generatora.
.IX Item "RNDfile = plik" .IX Item "RNDfile = plik"
ścieżka do pliku zawierającego losowe dane ścieżka do pliku zawierającego losowe dane
.Sp .Sp
Biblioteka OpenSSL użyje danych z tego pliku do zainicjowania Biblioteka \fBOpenSSL\fR użyje danych z tego pliku do zainicjowania
generatora pseudolosowego. generatora pseudolosowego.
.IP "\fBRNDoverwrite\fR = yes | no" 4 .IP "\fBRNDoverwrite\fR = yes | no" 4
.IX Item "RNDoverwrite = yes | no" .IX Item "RNDoverwrite = yes | no"
@ -278,10 +290,10 @@ użyj parametru jako nazwy serwisu dla biblioteki \s-1TCP\s0 Wrapper w trybie \f
domyślnie: stunnel domyślnie: stunnel
.IP "\fBsetgid\fR = identyfikator_grupy (tylko Unix)" 4 .IP "\fBsetgid\fR = identyfikator_grupy (tylko Unix)" 4
.IX Item "setgid = identyfikator_grupy (tylko Unix)" .IX Item "setgid = identyfikator_grupy (tylko Unix)"
grupa z której prawami pracował będzie \fIstunnel\fR grupa z której prawami pracował będzie \fBstunnel\fR
.IP "\fBsetuid\fR = identyfikator_użytkownika (tylko Unix)" 4 .IP "\fBsetuid\fR = identyfikator_użytkownika (tylko Unix)" 4
.IX Item "setuid = identyfikator_użytkownika (tylko Unix)" .IX Item "setuid = identyfikator_użytkownika (tylko Unix)"
użytkownik, z którego prawami pracował będzie \fIstunnel\fR użytkownik, z którego prawami pracował będzie \fBstunnel\fR
.IP "\fBsocket\fR = a|l|r:option=value[:value]" 4 .IP "\fBsocket\fR = a|l|r:option=value[:value]" 4
.IX Item "socket = a|l|r:option=value[:value]" .IX Item "socket = a|l|r:option=value[:value]"
ustaw opcję na akceptującym/lokalnym/zdalnym gnieździe ustaw opcję na akceptującym/lokalnym/zdalnym gnieździe
@ -330,7 +342,7 @@ lub \fItcpserver\fR), należy przeczytać sekcję \fI\s-1TRYB\s0 \s-1INETD\s0\fR
.IX Item "accept = [adres:]port" .IX Item "accept = [adres:]port"
nasłuchuje na połączenia na podanym adresie i porcie nasłuchuje na połączenia na podanym adresie i porcie
.Sp .Sp
Jeżeli nie został podany adres, \fIstunnel\fR domyślnie nasłuchuje Jeżeli nie został podany adres, \fBstunnel\fR domyślnie nasłuchuje
na wszystkich adresach IPv4 lokalnych interfejsów. na wszystkich adresach IPv4 lokalnych interfejsów.
.Sp .Sp
Aby nasłuchiwać na wszystkich adresach IPv6 należy użyć: Aby nasłuchiwać na wszystkich adresach IPv6 należy użyć:
@ -347,8 +359,8 @@ jeżeli użyta została opcja \fIverify\fR. Pliki z certyfikatami muszą
posiadać specjalne nazwy \s-1XXXXXXXX\s0.0, gdzie \s-1XXXXXXXX\s0 jest skrótem posiadać specjalne nazwy \s-1XXXXXXXX\s0.0, gdzie \s-1XXXXXXXX\s0 jest skrótem
kryptograficznym reprezentacji \s-1DER\s0 nazwy podmiotu certyfikatu. kryptograficznym reprezentacji \s-1DER\s0 nazwy podmiotu certyfikatu.
.Sp .Sp
Funkcja skrótu została zmieniona w wersji 1.0.0 biblioteki OpenSSL. Funkcja skrótu została zmieniona w \fBOpenSSL 1.0.0\fR.
Należy wykonać c_rehash przy zmianie OpenSSL 0.x.x na 1.x.x. Należy wykonać c_rehash przy zmianie \fBOpenSSL 0.x.x\fR na \fB1.x.x\fR.
.Sp .Sp
Jeżeli zdefiniowano katalog \fIchroot\fR, to ścieżka do \fICApath\fR jest określona Jeżeli zdefiniowano katalog \fIchroot\fR, to ścieżka do \fICApath\fR jest określona
względem tego katalogu. względem tego katalogu.
@ -381,7 +393,7 @@ domyślnie: no (tryb serwerowy)
.IX Item "connect = [adres:]port" .IX Item "connect = [adres:]port"
połącz się ze zdalnym serwerem na podany port połącz się ze zdalnym serwerem na podany port
.Sp .Sp
Jeżeli nie został podany adres, \fIstunnel\fR domyślnie łączy się Jeżeli nie został podany adres, \fBstunnel\fR domyślnie łączy się
z lokalnym serwerem. z lokalnym serwerem.
.Sp .Sp
Komenda może byc użyta wielokrotnie w pojedynczej sekcji Komenda może byc użyta wielokrotnie w pojedynczej sekcji
@ -396,8 +408,8 @@ jeżeli użyta została opcja \fIverify\fR. Pliki z listami \s-1CRL\s0 muszą
posiadać specjalne nazwy \s-1XXXXXXXX\s0.r0, gdzie \s-1XXXXXXXX\s0 jest skrótem posiadać specjalne nazwy \s-1XXXXXXXX\s0.r0, gdzie \s-1XXXXXXXX\s0 jest skrótem
listy \s-1CRL\s0. listy \s-1CRL\s0.
.Sp .Sp
Funkcja skrótu została zmieniona w wersji 1.0.0 biblioteki OpenSSL. Funkcja skrótu została zmieniona \fBOpenSSL 1.0.0\fR.
Należy wykonać c_rehash przy zmianie OpenSSL 0.x.x na 1.x.x. Należy wykonać c_rehash przy zmianie \fBOpenSSL 0.x.x\fR na \fB1.x.x\fR.
.Sp .Sp
Jeżeli zdefiniowano katalog \fIchroot\fR, to ścieżka do \fICRLpath\fR jest określona Jeżeli zdefiniowano katalog \fIchroot\fR, to ścieżka do \fICRLpath\fR jest określona
względem tego katalogu. względem tego katalogu.
@ -423,7 +435,7 @@ domyślnie: prime256v1
opóźnij rozwinięcie adresu \s-1DNS\s0 podanego w opcji \fIconnect\fR opóźnij rozwinięcie adresu \s-1DNS\s0 podanego w opcji \fIconnect\fR
.Sp .Sp
Opcja jest przydatna przy dynamicznym \s-1DNS\s0, albo gdy usługa \s-1DNS\s0 nie jest Opcja jest przydatna przy dynamicznym \s-1DNS\s0, albo gdy usługa \s-1DNS\s0 nie jest
dostępna przy starcie programu stunnel (klient \s-1VPN\s0, połączenie wdzwaniane). dostępna przy starcie programu \fBstunnel\fR (klient \s-1VPN\s0, połączenie wdzwaniane).
.IP "\fBengineNum\fR = <numer urządzenia>" 4 .IP "\fBengineNum\fR = <numer urządzenia>" 4
.IX Item "engineNum = <numer urządzenia>" .IX Item "engineNum = <numer urządzenia>"
wybierz urządzenie do odczyta klucza prywatnego wybierz urządzenie do odczyta klucza prywatnego
@ -480,32 +492,36 @@ domyślnie: yes
.Sp .Sp
Domyślnie używane jest \s-1IP\s0 najbardziej zewnętrznego interfejsu w stronę Domyślnie używane jest \s-1IP\s0 najbardziej zewnętrznego interfejsu w stronę
serwera, do którego nawiązywane jest połączenie. serwera, do którego nawiązywane jest połączenie.
.IP "\fBsni\fR = nazwa_usługi:nazwa_serwera (tryb serwera)" 4 .IP "\fBsni\fR = nazwa_usługi:wzorzec_nazwy_serwera (tryb serwera)" 4
.IX Item "sni = nazwa_usługi:nazwa_serwera (tryb serwera)" .IX Item "sni = nazwa_usługi:wzorzec_nazwy_serwera (tryb serwera)"
Użyj usługi jako podrzędnej (virtualnego serwera) dla rozszerzenia \s-1TLS\s0 Server Użyj usługi jako podrzędnej (virtualnego serwera) dla rozszerzenia \s-1TLS\s0 Server
Name Indication (\s-1RFC\s0 3546). Name Indication (\s-1RFC\s0 3546).
.Sp .Sp
\&\fInazwa_usługi\fR wskazuje usługę nadrzędną, która odbiera połączenia od klientów \&\fInazwa_usługi\fR wskazuje usługę nadrzędną, która odbiera połączenia od klientów
przy pomocy opcji \fIaccept\fR. \fInazwa_serwera\fR wskazuje nazwę serwera przy pomocy opcji \fIaccept\fR. \fIwzorzec_nazwy_serwera\fR wskazuje nazwę serwera
wirtualnego. Z pojedyńczą usługą nadrzędną powiązane jest zwykle wiele usług wirtualnego. Wzorzec może zaczynać się znakiem '*', np. '*.example.com".
podrzędnych. Opcja \fIsni\fR może być rownież użyta wielokrotnie w ramach jednej Z pojedyńczą usługą nadrzędną powiązane jest zwykle wiele usług podrzędnych.
usługi podrzędnej. Opcja \fIsni\fR może być rownież użyta wielokrotnie w ramach jednej usługi
podrzędnej.
.Sp .Sp
Zarówno usługa nadrzędna jak i podrzędna nie może być skonfigurowana w trybie Zarówno usługa nadrzędna jak i podrzędna nie może być skonfigurowana w trybie
klienckim. Opcja \fIconnect\fR usługi podrzędnej jest ignorowana w połączeniu z klienckim.
opcją \fIprotocol\fR, gdyż połączenie do zdalnego serwera jest w tym wypadku
nawiązywane przed negocjacją \s-1TLS\s0. Uwierzytelnienie przy pomocy biblioteki
libwrap jest realizowane dwukrotnie: najpierw dla usługi nadrzędnej po
odebraniu połączenia \s-1TCP\s0, a następnie dla usługi podrzędnej podczas negocjacji
\&\s-1TLS\s0.
.Sp .Sp
Opcja \fIsni\fR jest dostępna począwszy od wersji 1.0.0 biblioteki OpenSSL. Opcja \fIconnect\fR usługi podrzędnej jest ignorowana w połączeniu z opcją
\&\fIprotocol\fR, gdyż połączenie do zdalnego serwera jest w tym wypadku nawiązywane
przed negocjacją \s-1TLS\s0.
.Sp
Uwierzytelnienie przy pomocy biblioteki libwrap jest realizowane dwukrotnie:
najpierw dla usługi nadrzędnej po odebraniu połączenia \s-1TCP\s0, a następnie dla
usługi podrzędnej podczas negocjacji \s-1TLS\s0.
.Sp
Opcja \fIsni\fR jest dostępna począwszy od \fBOpenSSL 1.0.0\fR.
.IP "\fBsni\fR = nazwa_serwera (tryb klienta)" 4 .IP "\fBsni\fR = nazwa_serwera (tryb klienta)" 4
.IX Item "sni = nazwa_serwera (tryb klienta)" .IX Item "sni = nazwa_serwera (tryb klienta)"
Użyj parametru jako wartości rozszerzenia \s-1TLS\s0 Server Name Indication Użyj parametru jako wartości rozszerzenia \s-1TLS\s0 Server Name Indication
(\s-1RFC\s0 3546). (\s-1RFC\s0 3546).
.Sp .Sp
Opcja \fIsni\fR jest dostępna począwszy od wersji 1.0.0 biblioteki OpenSSL. Opcja \fIsni\fR jest dostępna począwszy od \fBOpenSSL 1.0.0\fR.
.IP "\fB\s-1OCSP\s0\fR = \s-1URL\s0" 4 .IP "\fB\s-1OCSP\s0\fR = \s-1URL\s0" 4
.IX Item "OCSP = URL" .IX Item "OCSP = URL"
serwer \s-1OCSP\s0 do weryfikacji certyfikatów serwer \s-1OCSP\s0 do weryfikacji certyfikatów
@ -519,7 +535,7 @@ aktualnie wspierane flagi: \s-1NOCERTS\s0, \s-1NOINTERN\s0 \s-1NOSIGS\s0, \s-1NO
Aby wyspecyfikować kilka flag należy użyć \fIOCSPflag\fR wielokrotnie. Aby wyspecyfikować kilka flag należy użyć \fIOCSPflag\fR wielokrotnie.
.IP "\fBoptions\fR = opcje_SSL" 4 .IP "\fBoptions\fR = opcje_SSL" 4
.IX Item "options = opcje_SSL" .IX Item "options = opcje_SSL"
opcje biblioteki OpenSSL opcje biblioteki \fBOpenSSL\fR
.Sp .Sp
Parametrem jest nazwa opcji zgodnie z opisem w \fI\fISSL_CTX_set_options\fI\|(3ssl)\fR, Parametrem jest nazwa opcji zgodnie z opisem w \fI\fISSL_CTX_set_options\fI\|(3ssl)\fR,
ale bez przedrostka \fI\s-1SSL_OP_\s0\fR. ale bez przedrostka \fI\s-1SSL_OP_\s0\fR.
@ -533,8 +549,10 @@ w programie Eudora można użyć opcji:
.Ve .Ve
.IP "\fBprotocol\fR = protokół" 4 .IP "\fBprotocol\fR = protokół" 4
.IX Item "protocol = protokół" .IX Item "protocol = protokół"
negocjuj \s-1SSL\s0 podanym protokołem aplikacyjnym (np. \fIstarttls\fR lub \fIstls\fR) negocjuj \s-1SSL\s0 podanym protokołem aplikacyjnym
.Sp .Sp
Opcja ta włącza wstępną negocjację szyfrowania \s-1SSL\s0 dla wybranego protokołu
aplikacyjnego.
Opcji \fIprotocol\fR nie należy używać z szyfrowaniem \s-1SSL\s0 na osobnym porcie. Opcji \fIprotocol\fR nie należy używać z szyfrowaniem \s-1SSL\s0 na osobnym porcie.
.Sp .Sp
Aktualnie wspierane protokoły: Aktualnie wspierane protokoły:
@ -583,6 +601,13 @@ domyślnie: basic
.IP "\fBprotocolHost\fR = adres:port" 4 .IP "\fBprotocolHost\fR = adres:port" 4
.IX Item "protocolHost = adres:port" .IX Item "protocolHost = adres:port"
adres docelowy do negocjacji protokołu adres docelowy do negocjacji protokołu
.Sp
\&\fIprotocolHost\fR określa docelowy serwer \s-1SSL\s0, do którego połączyć ma się proxy.
Nie jest to adres serwera proxy, do którego połączenie zestawia \fBstunnel\fR.
Adres serwera proxy powinien być określony przy pomocy opcji 'connect'.
.Sp
W obecnej wersji adres docelowy protokołu ma zastosowanie wyłącznie w protokole
\&'connect'.
.IP "\fBprotocolPassword\fR = hasło" 4 .IP "\fBprotocolPassword\fR = hasło" 4
.IX Item "protocolPassword = hasło" .IX Item "protocolPassword = hasło"
hasło do negocjacji protokołu hasło do negocjacji protokołu
@ -592,14 +617,50 @@ nazwa użytkownika do negocjacji protokołu
.IP "\fBpty\fR = yes | no (tylko Unix)" 4 .IP "\fBpty\fR = yes | no (tylko Unix)" 4
.IX Item "pty = yes | no (tylko Unix)" .IX Item "pty = yes | no (tylko Unix)"
alokuj pseudoterminal dla programu uruchamianego w opcji 'exec' alokuj pseudoterminal dla programu uruchamianego w opcji 'exec'
.IP "\fBretry\fR = yes | no (tylko Unix)" 4 .IP "\fBrenegotiation\fR = yes | no" 4
.IX Item "retry = yes | no (tylko Unix)" .IX Item "renegotiation = yes | no"
pozwalaj na renegocjację \s-1SSL\s0
.Sp
Wśród zastosowań renegocjacji \s-1SSL\s0 są niektóre scenariusze uwierzytelnienia,
oraz renegocjacja kluczy dla długotrwałych połączeń.
.Sp
Z drugiej strony własność na może ułatwić trywialny atak DoS poprzez
wygenerowanie obciążenia procesora:
.Sp
http://vincent.bernat.im/en/blog/2011\-ssl\-dos\-mitigation.html
.Sp
Warto zauważyć, że zablokowanie renegocjacji \s-1SSL\s0 nie zebezpiecza w pełni
przed opisanym problemem.
.Sp
domyślnie: yes (o ile wspierane przez \fBOpenSSL\fR)
.IP "\fBreset\fR = yes | no" 4
.IX Item "reset = yes | no"
sygnalizuj wystąpienie błędu przy pomocy flagi \s-1TCP\s0 \s-1RST\s0
.Sp
Ta opcja nie jest wspierana na niektórych platformach.
.Sp
domyślnie: yes
.IP "\fBretry\fR = yes | no" 4
.IX Item "retry = yes | no"
połącz ponownie sekcję connect+exec po rozłączeniu połącz ponownie sekcję connect+exec po rozłączeniu
.Sp .Sp
domyślnie: no domyślnie: no
.IP "\fBsession\fR = przeterminowanie_pamięci_podręcznej_sesji" 4 .IP "\fBsessionCacheSize\fR = rozmiar" 4
.IX Item "session = przeterminowanie_pamięci_podręcznej_sesji" .IX Item "sessionCacheSize = rozmiar"
czas w sekundach, po którym sesja \s-1SSL\s0 zostanie usunięta z pamięci podręcznej rozmiar pamięci podręcznej sesji \s-1SSL\s0
.Sp
Parametr określa maksymalną liczbę pozycji wewnętrznej pamięci podręcznej
sesji.
.Sp
Wartość 0 oznacza brak ograniczenia rozmiaru. Nie jest to zalecane dla
systemów produkcyjnych z uwagi na ryzyko ataku DoS przez wyczerpanie pamięci
\&\s-1RAM\s0.
.IP "\fBsessionCacheTimeout\fR = czas" 4
.IX Item "sessionCacheTimeout = czas"
przeterminowanie pamięci podręcznej sesji \s-1SSL\s0
.Sp
Parametr określa czas w sekundach, po którym sesja \s-1SSL\s0 zostanie usunięta z
pamięci podręcznej.
.IP "\fBsessiond\fR = adres:port" 4 .IP "\fBsessiond\fR = adres:port" 4
.IX Item "sessiond = adres:port" .IX Item "sessiond = adres:port"
adres sessiond \- servera cache sesji \s-1SSL\s0 adres sessiond \- servera cache sesji \s-1SSL\s0
@ -607,7 +668,7 @@ adres sessiond \- servera cache sesji \s-1SSL\s0
.IX Item "sslVersion = wersja" .IX Item "sslVersion = wersja"
wersja protokołu \s-1SSL\s0 wersja protokołu \s-1SSL\s0
.Sp .Sp
Dozwolone opcje: all, SSLv2, SSLv3, TLSv1 Dozwolone opcje: all, SSLv2, SSLv3, TLSv1, TLSv1.1, TLSv1.2
.IP "\fBstack\fR = liczba_bajtów (z wyjątkiem modelu \s-1FORK\s0)" 4 .IP "\fBstack\fR = liczba_bajtów (z wyjątkiem modelu \s-1FORK\s0)" 4
.IX Item "stack = liczba_bajtów (z wyjątkiem modelu FORK)" .IX Item "stack = liczba_bajtów (z wyjątkiem modelu FORK)"
rozmiar stosu procesora wątku rozmiar stosu procesora wątku
@ -635,7 +696,7 @@ Zablokuj wsparcie dla przezroczystago proxy. Jest to wartość domyślna.
.IP "\fBsource\fR" 4 .IP "\fBsource\fR" 4
.IX Item "source" .IX Item "source"
Przepisz adres, aby nawiązywane połączenie wydawało się pochodzić Przepisz adres, aby nawiązywane połączenie wydawało się pochodzić
bezpośrednio od klienta, a nie od programu \fIstunnel\fR. bezpośrednio od klienta, a nie od programu \fBstunnel\fR.
.Sp .Sp
Opcja jest aktualnie obsługiwana w: Opcja jest aktualnie obsługiwana w:
.RS 4 .RS 4
@ -659,7 +720,7 @@ Konfiguracja ta wymaga, aby \fBstunnel\fR był wykonywany jako root i bez opcji
.IX Item "Trybie zdalnym (opcja connect) w systemie Linux 2.2.x" .IX Item "Trybie zdalnym (opcja connect) w systemie Linux 2.2.x"
Konfiguracja ta wymaga skompilowania jądra z opcją \fItransparent proxy\fR. Konfiguracja ta wymaga skompilowania jądra z opcją \fItransparent proxy\fR.
Docelowa usługa musi być umieszczona na osobnej maszynie, do której routing Docelowa usługa musi być umieszczona na osobnej maszynie, do której routing
kierowany jest poprzez serwer stunnela. kierowany jest poprzez serwer \fBstunnela\fR.
.Sp .Sp
Dodatkowo \fBstunnel\fR powinien być wykonywany jako root i bez opcji \fIsetuid\fR. Dodatkowo \fBstunnel\fR powinien być wykonywany jako root i bez opcji \fIsetuid\fR.
.IP "Trybie zdalnym (opcja \fIconnect\fR) w systemie \fIFreeBSD >=8.0\fR" 4 .IP "Trybie zdalnym (opcja \fIconnect\fR) w systemie \fIFreeBSD >=8.0\fR" 4
@ -717,23 +778,27 @@ Opcja została przemianowana na \fInone\fR.
.IX Item "verify = poziom" .IX Item "verify = poziom"
weryfikuj certyfikat drugiej strony połączenia weryfikuj certyfikat drugiej strony połączenia
.RS 4 .RS 4
.IP "\fIpoziom 0\fR \- zarządaj certyfikatu i zignoruj go" 4 .IP "\fIpoziom 0\fR" 4
.IX Item "poziom 0 - zarządaj certyfikatu i zignoruj go" .IX Item "poziom 0"
.PD 0 zarządaj certyfikatu i zignoruj go
.IP "\fIpoziom 1\fR \- weryfikuj, jeżeli został przedstawiony" 4 .IP "\fIpoziom 1\fR" 4
.IX Item "poziom 1 - weryfikuj, jeżeli został przedstawiony" .IX Item "poziom 1"
.IP "\fIpoziom 2\fR \- weryfikuj z zainstalowanym certyfikatem Centrum Certyfikacji" 4 weryfikuj, jeżeli został przedstawiony
.IX Item "poziom 2 - weryfikuj z zainstalowanym certyfikatem Centrum Certyfikacji" .IP "\fIpoziom 2\fR" 4
.IP "\fIpoziom 3\fR \- weryfikuj z lokalnie zainstalowanym certyfikatem drugiej strony" 4 .IX Item "poziom 2"
.IX Item "poziom 3 - weryfikuj z lokalnie zainstalowanym certyfikatem drugiej strony" weryfikuj z zainstalowanym certyfikatem Centrum Certyfikacji
.IP "\fIpoziom 4\fR \- weryfikuj z certyfikatem drugiej strony ignorując łańcuch \s-1CA\s0" 4 .IP "\fIpoziom 3\fR" 4
.IX Item "poziom 4 - weryfikuj z certyfikatem drugiej strony ignorując łańcuch CA" .IX Item "poziom 3"
.IP "\fIdomyślnie\fR \- nie weryfikuj" 4 weryfikuj z lokalnie zainstalowanym certyfikatem drugiej strony
.IX Item "domyślnie - nie weryfikuj" .IP "\fIpoziom 4\fR" 4
.IX Item "poziom 4"
weryfikuj z certyfikatem drugiej strony ignorując łańcuch \s-1CA\s0
.IP "\fIdomyślnie\fR" 4
.IX Item "domyślnie"
nie weryfikuj
.RE .RE
.RS 4 .RS 4
.RE .RE
.PD
.SH "ZWRACANA WARTOŚĆ" .SH "ZWRACANA WARTOŚĆ"
.IX Header "ZWRACANA WARTOŚĆ" .IX Header "ZWRACANA WARTOŚĆ"
\&\fBstunnel\fR zwraca zero w przypadku sukcesu, lub wartość niezerową \&\fBstunnel\fR zwraca zero w przypadku sukcesu, lub wartość niezerową
@ -760,17 +825,17 @@ setuid
.RE .RE
.RS 4 .RS 4
.Sp .Sp
Jeżeli wykorzystywana jest opcja 'setuid' stunnel nie będzie mógł załadować Jeżeli wykorzystywana jest opcja 'setuid' \fBstunnel\fR nie będzie mógł załadować
ponownie konfiguracji wykorzystującej uprzywilejowane (<1024) porty. ponownie konfiguracji wykorzystującej uprzywilejowane (<1024) porty.
.Sp .Sp
Jeżeli wykorzystywana jest opcja 'chroot' stunnel będzie szukał wszystkich Jeżeli wykorzystywana jest opcja 'chroot' \fBstunnel\fR będzie szukał wszystkich
potrzebnych plików (łącznie z plikiem konfiguracyjnym, certyfikatami, logiem i potrzebnych plików (łącznie z plikiem konfiguracyjnym, certyfikatami, logiem i
plikiem pid) wewnątrz katalogu wskazanego przez 'chroot'. plikiem pid) wewnątrz katalogu wskazanego przez 'chroot'.
.RE .RE
.IP "\s-1SIGUSR1\s0" 4 .IP "\s-1SIGUSR1\s0" 4
.IX Item "SIGUSR1" .IX Item "SIGUSR1"
Zamknij i otwórz ponownie log. Zamknij i otwórz ponownie log.
Funkcja ta może zostać użyta w skrypcie rotującym log programu stunnel. Funkcja ta może zostać użyta w skrypcie rotującym log programu \fBstunnel\fR.
.IP "\s-1SIGTERM\s0, \s-1SIGQUIT\s0, \s-1SIGINT\s0" 4 .IP "\s-1SIGTERM\s0, \s-1SIGQUIT\s0, \s-1SIGINT\s0" 4
.IX Item "SIGTERM, SIGQUIT, SIGINT" .IX Item "SIGTERM, SIGQUIT, SIGINT"
Zakończ działanie programu. Zakończ działanie programu.
@ -819,7 +884,7 @@ konfiguracyjnym nie ma sekcji \fI[nazwa_usługi]\fR.
.IX Header "NOTKI" .IX Header "NOTKI"
.SS "\s-1OGRANICZENIA\s0" .SS "\s-1OGRANICZENIA\s0"
.IX Subsection "OGRANICZENIA" .IX Subsection "OGRANICZENIA"
\&\fIstunnel\fR nie może być używany do szyfrowania protokołu \fI\s-1FTP\s0\fR, \&\fBstunnel\fR nie może być używany do szyfrowania protokołu \fI\s-1FTP\s0\fR,
ponieważ do przesyłania poszczególnych plików używa on dodatkowych ponieważ do przesyłania poszczególnych plików używa on dodatkowych
połączeń otwieranych na portach o dynamicznie przydzielanych numerach. połączeń otwieranych na portach o dynamicznie przydzielanych numerach.
Istnieją jednak specjalne wersje klientów i serwerów \s-1FTP\s0 pozwalające Istnieją jednak specjalne wersje klientów i serwerów \s-1FTP\s0 pozwalające
@ -854,9 +919,9 @@ Protokół \s-1SSL\s0 wymaga, aby każdy serwer przedstawiał się nawiązujące
połączenie klientowi prawidłowym certyfikatem X.509. połączenie klientowi prawidłowym certyfikatem X.509.
Potwierdzenie tożsamości serwera polega na wykazaniu, że posiada on Potwierdzenie tożsamości serwera polega na wykazaniu, że posiada on
odpowiadający certyfikatowi klucz prywatny. odpowiadający certyfikatowi klucz prywatny.
Najprostszą metodą uzyskania certyfikatu jest wygenerowanie Najprostszą metodą uzyskania certyfikatu jest wygenerowanie go przy pomocy
go przy pomocy wolnego pakietu \fIOpenSSL\fR. Więcej informacji na temat wolnego pakietu \fBOpenSSL\fR. Więcej informacji na temat generowania
generowania certyfikatów można znaleźć na umieszczonych poniżej stronach. certyfikatów można znaleźć na umieszczonych poniżej stronach.
.PP .PP
Istotną kwestią jest kolejność zawartości pliku \fI.pem\fR. Istotną kwestią jest kolejność zawartości pliku \fI.pem\fR.
W pierwszej kolejności powinien on zawierać klucz prywatny, W pierwszej kolejności powinien on zawierać klucz prywatny,
@ -902,11 +967,11 @@ programu.
.IP "\(bu" 4 .IP "\(bu" 4
Urządzenie /dev/urandom. Urządzenie /dev/urandom.
.PP .PP
Współczesne (>=0.9.5a) wersje biblioteki \fIOpenSSL\fR automatycznie Współczesne (\fB0.9.5a\fR lub nowsze) wersje biblioteki \fBOpenSSL\fR automatycznie
zaprzestają ładowania kolejnych danych w momencie uzyskania wystarczającej zaprzestają ładowania kolejnych danych w momencie uzyskania wystarczającej
ilości entropii. Wcześniejsze wersje biblioteki wykorzystają wszystkie ilości entropii. Wcześniejsze wersje biblioteki wykorzystają wszystkie
powyższe źródła, gdyż nie istnieje tam funkcja pozwalająca określić, powyższe źródła, gdyż nie istnieje tam funkcja pozwalająca określić, czy
czy uzyskano już wystarczająco dużo danych. uzyskano już wystarczająco dużo danych.
.PP .PP
Warto zwrócić uwagę, że na maszynach z systemem Windows, na których Warto zwrócić uwagę, że na maszynach z systemem Windows, na których
konsoli nie pracuje użytkownik, zawartość ekranu nie jest wystarczająco konsoli nie pracuje użytkownik, zawartość ekranu nie jest wystarczająco
@ -918,17 +983,17 @@ Plik \fIRNDfile\fR powinien zawierać dane losowe \*(-- również w tym sensie,
O ile nie użyta została opcja \fIRNDoverwrite\fR jest to robione O ile nie użyta została opcja \fIRNDoverwrite\fR jest to robione
automatycznie. Do ręcznego uzyskania takiego pliku użyteczna automatycznie. Do ręcznego uzyskania takiego pliku użyteczna
może być komenda \fIopenssl rand\fR dostarczana ze współczesnymi może być komenda \fIopenssl rand\fR dostarczana ze współczesnymi
wersjami pakietu \fIOpenSSL\fR. wersjami pakietu \fBOpenSSL\fR.
.PP .PP
Jeszcze jedna istotna informacja \*(-- jeżeli dostępne jest urządzenie Jeszcze jedna istotna informacja \*(-- jeżeli dostępne jest urządzenie
\&\fI/dev/urandom\fR biblioteka \fIOpenSSL\fR ma zwyczaj zasilania nim \s-1PRNG\s0 w trakcie \&\fI/dev/urandom\fR biblioteka \fBOpenSSL\fR ma zwyczaj zasilania nim \s-1PRNG\s0 w trakcie
sprawdzania stanu generatora. W systemach z \fI/dev/urandom\fR urządzenie sprawdzania stanu generatora. W systemach z \fI/dev/urandom\fR urządzenie
to będzie najprawdopodobniej użyte, pomimo że znajduje się na samym końcu to będzie najprawdopodobniej użyte, pomimo że znajduje się na samym końcu
powyższej listy. Jest to właściwość biblioteki \fIOpenSSL\fR, a nie programu powyższej listy. Jest to właściwość biblioteki \fBOpenSSL\fR, a nie programu
\&\fIstunnel\fR. \&\fBstunnel\fR.
.SS "\s-1PARAMETRY\s0 \s-1DH\s0" .SS "\s-1PARAMETRY\s0 \s-1DH\s0"
.IX Subsection "PARAMETRY DH" .IX Subsection "PARAMETRY DH"
Począwszy od wersji 4.40 stunnel zawiera w kodzie programu 2048\-bitowe Począwszy od wersji 4.40 \fBstunnel\fR zawiera w kodzie programu 2048\-bitowe
parametry \s-1DH\s0. parametry \s-1DH\s0.
.PP .PP
Alternatywnie parametry \s-1DH\s0 można umieścić w pliku razem z certyfikatem: Alternatywnie parametry \s-1DH\s0 można umieścić w pliku razem z certyfikatem:
@ -945,7 +1010,7 @@ Wygenerowanie parametrów \s-1DH\s0 może zająć nawet wiele minut.
plik konfiguracyjny programu plik konfiguracyjny programu
.SH "BŁĘDY" .SH "BŁĘDY"
.IX Header "BŁĘDY" .IX Header "BŁĘDY"
Opcja \fIexecargs\fR nie obsługuje cytowania. Opcja \fIexecargs\fR oraz linia komend Win32 nie obsługuje cytowania.
.SH "ZOBACZ RÓWNIEŻ" .SH "ZOBACZ RÓWNIEŻ"
.IX Header "ZOBACZ RÓWNIEŻ" .IX Header "ZOBACZ RÓWNIEŻ"
.IP "\fItcpd\fR\|(8)" 4 .IP "\fItcpd\fR\|(8)" 4
@ -956,10 +1021,10 @@ biblioteka kontroli dostępu do usług internetowych
\&'super\-serwer' internetowy \&'super\-serwer' internetowy
.IP "\fIhttp://www.stunnel.org/\fR" 4 .IP "\fIhttp://www.stunnel.org/\fR" 4
.IX Item "http://www.stunnel.org/" .IX Item "http://www.stunnel.org/"
strona domowa programu \fIstunnel\fR strona domowa programu \fBstunnel\fR
.IP "\fIhttp://www.openssl.org/\fR" 4 .IP "\fIhttp://www.openssl.org/\fR" 4
.IX Item "http://www.openssl.org/" .IX Item "http://www.openssl.org/"
strona projektu \fIOpenSSL\fR strona projektu \fBOpenSSL\fR
.SH "AUTOR" .SH "AUTOR"
.IX Header "AUTOR" .IX Header "AUTOR"
.IP "Michał Trojnara" 4 .IP "Michał Trojnara" 4

View File

@ -156,29 +156,29 @@ odinstalowaniu</p>
<h1><a name="plik_konfiguracyjny">PLIK KONFIGURACYJNY</a></h1> <h1><a name="plik_konfiguracyjny">PLIK KONFIGURACYJNY</a></h1>
<p>Linia w pliku konfiguracyjnym może być:</p> <p>Linia w pliku konfiguracyjnym może być:</p>
<ul> <ul>
<li><strong><a name="pusta" class="item">pusta (ignorowana)</a></strong> <li>
<p>pusta (ignorowana)</p>
</li> </li>
<li><strong><a name="komentarzem_rozpoczynaj_cym_si_znakiem_ignorowana" class="item">komentarzem rozpoczynającym się znakiem ';' (ignorowana)</a></strong> <li>
<p>komentarzem rozpoczynającym się znakiem ';' (ignorowana)</p>
</li> </li>
<li><strong><a name="par_nazwa_opcji_warto_opcji" class="item">parą 'nazwa_opcji = wartość_opcji'</a></strong> <li>
<p>parą 'nazwa_opcji = wartość_opcji'</p>
</li> </li>
<li><strong><a name="tekstem_nazwa_us_ugi_wskazuj_cym_pocz_tek_definicji_us_ugi" class="item">tekstem '[nazwa_usługi]' wskazującym początek definicji usługi</a></strong> <li>
<p>tekstem '[nazwa_usługi]' wskazującym początek definicji usługi</p>
</li> </li>
</ul> </ul>
<p>Parametr adres może być:</p> <p>Parametr adres może być:</p>
<ul> <ul>
<li><strong><a name="numerem_portu" class="item">numerem portu</a></strong> <li>
<p>numerem portu</p>
</li> </li>
<li><strong><a name="adresu" class="item">oddzieloną średnikiem parą adresu (IPv4, IPv6, lub nazwą domenową) i numeru portu</a></strong> <li>
<p>oddzieloną średnikiem parą adresu (IPv4, IPv6, lub nazwą domenową) i numeru portu</p>
</li> </li>
<li><strong>ścieżką do gniazda Unix (tylko Unix)</strong> <li>
<p>ścieżką do gniazda Unix (tylko Unix)</p>
</li> </li>
</ul> </ul>
<p> <p>
@ -194,6 +194,18 @@ odinstalowaniu</p>
połączeń. Ścieżki podane w opcjach <em>CApath</em>, <em>CRLpath</em>, <em>pid</em> połączeń. Ścieżki podane w opcjach <em>CApath</em>, <em>CRLpath</em>, <em>pid</em>
oraz <em>exec</em> muszą być umieszczone wewnątrz katalogu podanego w opcji oraz <em>exec</em> muszą być umieszczone wewnątrz katalogu podanego w opcji
<em>chroot</em> i określone względem tego katalogu.</p> <em>chroot</em> i określone względem tego katalogu.</p>
<p>Niektóre funkcje systemu operacyjnego mogą wymagać dodatkowych plików umieszczonych w katalogu podanego w parametrze chroot:</p>
<ul>
<li>
<p>opóźnione rozwinięcie adresów DNS typowo wymaga /etc/nsswitch.conf i /etc/resolv.conf</p>
</li>
<li>
<p>lokalizacja strefy czasowej w logach wymaga pliku /etc/timezone</p>
</li>
<li>
<p>niektóre inne pliki mogą potrzebować plików urządzeń, np. /dev/zero lub /dev/null</p>
</li>
</ul>
</dd> </dd>
<dt><strong><a name="compression_deflate_zlib_rle" class="item"><strong>compression</strong> = deflate | zlib | rle</a></strong></dt> <dt><strong><a name="compression_deflate_zlib_rle" class="item"><strong>compression</strong> = deflate | zlib | rle</a></strong></dt>
@ -201,9 +213,9 @@ oraz <em>exec</em> muszą być umieszczone wewnątrz katalogu podanego w opcji
<p>wybór algorytmu kompresji przesyłanych danych</p> <p>wybór algorytmu kompresji przesyłanych danych</p>
<p>domyślnie: bez kompresji</p> <p>domyślnie: bez kompresji</p>
<p>Algorytm deflate jest standardową metodą kompresji zgodnie z <a href="http://www.ietf.org/rfc/rfc1951.txt" class="rfc">RFC 1951</a>.</p> <p>Algorytm deflate jest standardową metodą kompresji zgodnie z <a href="http://www.ietf.org/rfc/rfc1951.txt" class="rfc">RFC 1951</a>.</p>
<p>Kompresja zlib zaimplementowana w OpenSSL 0.9.8 i nowszych nie jest <p>Kompresja zlib zaimplementowana w <strong>OpenSSL 0.9.8</strong> i nowszych nie jest
kompatybilna implementacją OpenSSL 0.9.7.</p> kompatybilna implementacją <strong>OpenSSL 0.9.7</strong>.</p>
<p>Kompresja rle nie jest zaimplementowana w aktualnych wersjach OpenSSL.</p> <p>Kompresja rle nie jest zaimplementowana w aktualnych wersjach <strong>OpenSSL</strong>.</p>
</dd> </dd>
<dt><strong><a name="debug_poziom_podsystem" class="item"><strong>debug</strong> = poziom[.podsystem]</a></strong></dt> <dt><strong><a name="debug_poziom_podsystem" class="item"><strong>debug</strong> = poziom[.podsystem]</a></strong></dt>
@ -225,7 +237,7 @@ Podsystemy nie są wspierane przez platformę Win32.</p>
<p>ścieżka do gniazda programu Entropy Gathering Daemon</p> <p>ścieżka do gniazda programu Entropy Gathering Daemon</p>
<p>Opcja pozwala określić ścieżkę do gniazda programu Entropy Gathering Daemon <p>Opcja pozwala określić ścieżkę do gniazda programu Entropy Gathering Daemon
używanego do zainicjalizowania generatora ciągów pseudolosowych biblioteki używanego do zainicjalizowania generatora ciągów pseudolosowych biblioteki
OpenSSL. Opcja jest dostępna z biblioteką OpenSSL 0.9.5a lub nowszą.</p> <strong>OpenSSL</strong>. Opcja jest dostępna z biblioteką <strong>OpenSSL 0.9.5a</strong> lub nowszą.</p>
</dd> </dd>
<dt><strong><a name="engine_auto_identyfikator_urz_dzenia" class="item"><strong>engine</strong> = auto | &lt;identyfikator urządzenia&gt;</a></strong></dt> <dt><strong><a name="engine_auto_identyfikator_urz_dzenia" class="item"><strong>engine</strong> = auto | &lt;identyfikator urządzenia&gt;</a></strong></dt>
@ -258,15 +270,15 @@ modułu kryptograficznego urządzenia.</p>
<dd> <dd>
<p>Włącz lub wyłącz tryb FIPS 140-2.</p> <p>Włącz lub wyłącz tryb FIPS 140-2.</p>
<p>Opcja pozwala wyłączyć wejście w tryb FIPS, jeśli stunnel został skompilowany <p>Opcja pozwala wyłączyć wejście w tryb FIPS, jeśli <strong>stunnel</strong> został
ze wsparciem dla FIPS 140-2.</p> skompilowany ze wsparciem dla FIPS 140-2.</p>
<p>domyślnie: yes (pracuj w trybie FIPS 140-2)</p> <p>domyślnie: yes (pracuj w trybie FIPS 140-2)</p>
</dd> </dd>
<dt><strong><a name="no" class="item"><strong>foreground</strong> = yes | no (tylko Unix)</a></strong></dt> <dt><strong><a name="no" class="item"><strong>foreground</strong> = yes | no (tylko Unix)</a></strong></dt>
<dd> <dd>
<p>tryb pierwszoplanowy</p> <p>tryb pierwszoplanowy</p>
<p>Użycie tej opcji powoduje, że <em>stunnel</em> nie przechodzi w tło logując <p>Użycie tej opcji powoduje, że <strong>stunnel</strong> nie przechodzi w tło logując
swoje komunikaty na konsolę zamiast przez <em>syslog</em> (o ile nie użyto swoje komunikaty na konsolę zamiast przez <em>syslog</em> (o ile nie użyto
opcji <em>output</em>).</p> opcji <em>output</em>).</p>
</dd> </dd>
@ -291,7 +303,7 @@ względem tego katalogu.</p>
<dd> <dd>
<p>liczba bajtów do zainicjowania generatora pseudolosowego</p> <p>liczba bajtów do zainicjowania generatora pseudolosowego</p>
<p>W wersjach biblioteki OpenSSL starszych niż 0.9.5a opcja ta określa <p>W wersjach biblioteki <strong>OpenSSL</strong> starszych niż <strong>0.9.5a</strong> opcja ta określa
również liczbę bajtów wystarczających do zainicjowania PRNG. również liczbę bajtów wystarczających do zainicjowania PRNG.
Nowsze wersje biblioteki mają wbudowaną funkcję określającą, czy Nowsze wersje biblioteki mają wbudowaną funkcję określającą, czy
dostarczona ilość losowości jest wystarczająca do zainicjowania generatora.</p> dostarczona ilość losowości jest wystarczająca do zainicjowania generatora.</p>
@ -300,7 +312,7 @@ dostarczona ilość losowości jest wystarczająca do zainicjowania generatora.<
<dd> <dd>
<p>ścieżka do pliku zawierającego losowe dane</p> <p>ścieżka do pliku zawierającego losowe dane</p>
<p>Biblioteka OpenSSL użyje danych z tego pliku do zainicjowania <p>Biblioteka <strong>OpenSSL</strong> użyje danych z tego pliku do zainicjowania
generatora pseudolosowego.</p> generatora pseudolosowego.</p>
</dd> </dd>
<dt><strong><a name="rndoverwrite_yes_no" class="item"><strong>RNDoverwrite</strong> = yes | no</a></strong></dt> <dt><strong><a name="rndoverwrite_yes_no" class="item"><strong>RNDoverwrite</strong> = yes | no</a></strong></dt>
@ -318,12 +330,12 @@ generatora pseudolosowego.</p>
<dt><strong><a name="identyfikator_grupy" class="item"><strong>setgid</strong> = identyfikator_grupy (tylko Unix)</a></strong></dt> <dt><strong><a name="identyfikator_grupy" class="item"><strong>setgid</strong> = identyfikator_grupy (tylko Unix)</a></strong></dt>
<dd> <dd>
<p>grupa z której prawami pracował będzie <em>stunnel</em></p> <p>grupa z której prawami pracował będzie <strong>stunnel</strong></p>
</dd> </dd>
<dt><strong><a name="ytkownika" class="item"><strong>setuid</strong> = identyfikator_użytkownika (tylko Unix)</a></strong></dt> <dt><strong><a name="ytkownika" class="item"><strong>setuid</strong> = identyfikator_użytkownika (tylko Unix)</a></strong></dt>
<dd> <dd>
<p>użytkownik, z którego prawami pracował będzie <em>stunnel</em></p> <p>użytkownik, z którego prawami pracował będzie <strong>stunnel</strong></p>
</dd> </dd>
<dt><strong><a name="socket_a_l_r_option_value_value" class="item"><strong>socket</strong> = a|l|r:option=value[:value]</a></strong></dt> <dt><strong><a name="socket_a_l_r_option_value_value" class="item"><strong>socket</strong> = a|l|r:option=value[:value]</a></strong></dt>
@ -375,7 +387,7 @@ lub <em>tcpserver</em>), należy przeczytać sekcję <em>TRYB INETD</em> poniże
<dd> <dd>
<p>nasłuchuje na połączenia na podanym adresie i porcie</p> <p>nasłuchuje na połączenia na podanym adresie i porcie</p>
<p>Jeżeli nie został podany adres, <em>stunnel</em> domyślnie nasłuchuje <p>Jeżeli nie został podany adres, <strong>stunnel</strong> domyślnie nasłuchuje
na wszystkich adresach IPv4 lokalnych interfejsów.</p> na wszystkich adresach IPv4 lokalnych interfejsów.</p>
<p>Aby nasłuchiwać na wszystkich adresach IPv6 należy użyć:</p> <p>Aby nasłuchiwać na wszystkich adresach IPv6 należy użyć:</p>
<pre> <pre>
@ -389,8 +401,8 @@ na wszystkich adresach IPv4 lokalnych interfejsów.</p>
jeżeli użyta została opcja <em>verify</em>. Pliki z certyfikatami muszą jeżeli użyta została opcja <em>verify</em>. Pliki z certyfikatami muszą
posiadać specjalne nazwy XXXXXXXX.0, gdzie XXXXXXXX jest skrótem posiadać specjalne nazwy XXXXXXXX.0, gdzie XXXXXXXX jest skrótem
kryptograficznym reprezentacji DER nazwy podmiotu certyfikatu.</p> kryptograficznym reprezentacji DER nazwy podmiotu certyfikatu.</p>
<p>Funkcja skrótu została zmieniona w wersji 1.0.0 biblioteki OpenSSL. <p>Funkcja skrótu została zmieniona w <strong>OpenSSL 1.0.0</strong>.
Należy wykonać c_rehash przy zmianie OpenSSL 0.x.x na 1.x.x.</p> Należy wykonać c_rehash przy zmianie <strong>OpenSSL 0.x.x</strong> na <strong>1.x.x</strong>.</p>
<p>Jeżeli zdefiniowano katalog <em>chroot</em>, to ścieżka do <em>CApath</em> jest określona <p>Jeżeli zdefiniowano katalog <em>chroot</em>, to ścieżka do <em>CApath</em> jest określona
względem tego katalogu.</p> względem tego katalogu.</p>
</dd> </dd>
@ -427,7 +439,7 @@ otwieraniu nowych połączeń SSL, np.: DES-CBC3-SHA:IDEA-CBC-MD5</p>
<dd> <dd>
<p>połącz się ze zdalnym serwerem na podany port</p> <p>połącz się ze zdalnym serwerem na podany port</p>
<p>Jeżeli nie został podany adres, <em>stunnel</em> domyślnie łączy się <p>Jeżeli nie został podany adres, <strong>stunnel</strong> domyślnie łączy się
z lokalnym serwerem.</p> z lokalnym serwerem.</p>
<p>Komenda może byc użyta wielokrotnie w pojedynczej sekcji <p>Komenda może byc użyta wielokrotnie w pojedynczej sekcji
celem zapewnienia wysokiej niezawodności lub rozłożenia celem zapewnienia wysokiej niezawodności lub rozłożenia
@ -441,8 +453,8 @@ ruchu pomiędzy wiele serwerów.</p>
jeżeli użyta została opcja <em>verify</em>. Pliki z listami CRL muszą jeżeli użyta została opcja <em>verify</em>. Pliki z listami CRL muszą
posiadać specjalne nazwy XXXXXXXX.r0, gdzie XXXXXXXX jest skrótem posiadać specjalne nazwy XXXXXXXX.r0, gdzie XXXXXXXX jest skrótem
listy CRL.</p> listy CRL.</p>
<p>Funkcja skrótu została zmieniona w wersji 1.0.0 biblioteki OpenSSL. <p>Funkcja skrótu została zmieniona <strong>OpenSSL 1.0.0</strong>.
Należy wykonać c_rehash przy zmianie OpenSSL 0.x.x na 1.x.x.</p> Należy wykonać c_rehash przy zmianie <strong>OpenSSL 0.x.x</strong> na <strong>1.x.x</strong>.</p>
<p>Jeżeli zdefiniowano katalog <em>chroot</em>, to ścieżka do <em>CRLpath</em> jest określona <p>Jeżeli zdefiniowano katalog <em>chroot</em>, to ścieżka do <em>CRLpath</em> jest określona
względem tego katalogu.</p> względem tego katalogu.</p>
</dd> </dd>
@ -467,7 +479,7 @@ przez opcję <em>verify</em>.</p>
<dd> <dd>
<p>opóźnij rozwinięcie adresu DNS podanego w opcji <em>connect</em></p> <p>opóźnij rozwinięcie adresu DNS podanego w opcji <em>connect</em></p>
<p>Opcja jest przydatna przy dynamicznym DNS, albo gdy usługa DNS nie jest <p>Opcja jest przydatna przy dynamicznym DNS, albo gdy usługa DNS nie jest
dostępna przy starcie programu stunnel (klient VPN, połączenie wdzwaniane).</p> dostępna przy starcie programu <strong>stunnel</strong> (klient VPN, połączenie wdzwaniane).</p>
</dd> </dd>
<dt><strong><a name="enginenum_numer_urz_dzenia" class="item"><strong>engineNum</strong> = &lt;numer urządzenia&gt;</a></strong></dt> <dt><strong><a name="enginenum_numer_urz_dzenia" class="item"><strong>engineNum</strong> = &lt;numer urządzenia&gt;</a></strong></dt>
@ -528,31 +540,33 @@ komendą:</p>
<p>Domyślnie używane jest IP najbardziej zewnętrznego interfejsu w stronę <p>Domyślnie używane jest IP najbardziej zewnętrznego interfejsu w stronę
serwera, do którego nawiązywane jest połączenie.</p> serwera, do którego nawiązywane jest połączenie.</p>
</dd> </dd>
<dt><strong><a name="nazwa_serwera" class="item"><strong>sni</strong> = nazwa_usługi:nazwa_serwera (tryb serwera)</a></strong></dt> <dt><strong><a name="wzorzec_nazwy_serwera" class="item"><strong>sni</strong> = nazwa_usługi:wzorzec_nazwy_serwera (tryb serwera)</a></strong></dt>
<dd> <dd>
<p>Użyj usługi jako podrzędnej (virtualnego serwera) dla rozszerzenia TLS Server <p>Użyj usługi jako podrzędnej (virtualnego serwera) dla rozszerzenia TLS Server
Name Indication (<a href="http://www.ietf.org/rfc/rfc3546.txt" class="rfc">RFC 3546</a>).</p> Name Indication (<a href="http://www.ietf.org/rfc/rfc3546.txt" class="rfc">RFC 3546</a>).</p>
<p><em>nazwa_usługi</em> wskazuje usługę nadrzędną, która odbiera połączenia od klientów <p><em>nazwa_usługi</em> wskazuje usługę nadrzędną, która odbiera połączenia od klientów
przy pomocy opcji <em>accept</em>. <em>nazwa_serwera</em> wskazuje nazwę serwera przy pomocy opcji <em>accept</em>. <em>wzorzec_nazwy_serwera</em> wskazuje nazwę serwera
wirtualnego. Z pojedyńczą usługą nadrzędną powiązane jest zwykle wiele usług wirtualnego. Wzorzec może zaczynać się znakiem '*', np. '*.example.com&quot;.
podrzędnych. Opcja <em>sni</em> może być rownież użyta wielokrotnie w ramach jednej Z pojedyńczą usługą nadrzędną powiązane jest zwykle wiele usług podrzędnych.
usługi podrzędnej.</p> Opcja <em>sni</em> może być rownież użyta wielokrotnie w ramach jednej usługi
podrzędnej.</p>
<p>Zarówno usługa nadrzędna jak i podrzędna nie może być skonfigurowana w trybie <p>Zarówno usługa nadrzędna jak i podrzędna nie może być skonfigurowana w trybie
klienckim. Opcja <em>connect</em> usługi podrzędnej jest ignorowana w połączeniu z klienckim.</p>
opcją <em>protocol</em>, gdyż połączenie do zdalnego serwera jest w tym wypadku <p>Opcja <em>connect</em> usługi podrzędnej jest ignorowana w połączeniu z opcją
nawiązywane przed negocjacją TLS. Uwierzytelnienie przy pomocy biblioteki <em>protocol</em>, gdyż połączenie do zdalnego serwera jest w tym wypadku nawiązywane
libwrap jest realizowane dwukrotnie: najpierw dla usługi nadrzędnej po przed negocjacją TLS.</p>
odebraniu połączenia TCP, a następnie dla usługi podrzędnej podczas negocjacji <p>Uwierzytelnienie przy pomocy biblioteki libwrap jest realizowane dwukrotnie:
TLS.</p> najpierw dla usługi nadrzędnej po odebraniu połączenia TCP, a następnie dla
<p>Opcja <em>sni</em> jest dostępna począwszy od wersji 1.0.0 biblioteki OpenSSL.</p> usługi podrzędnej podczas negocjacji TLS.</p>
<p>Opcja <em>sni</em> jest dostępna począwszy od <strong>OpenSSL 1.0.0</strong>.</p>
</dd> </dd>
<dt><strong><strong>sni</strong> = nazwa_serwera (tryb klienta)</strong></dt> <dt><strong><a name="nazwa_serwera" class="item"><strong>sni</strong> = nazwa_serwera (tryb klienta)</a></strong></dt>
<dd> <dd>
<p>Użyj parametru jako wartości rozszerzenia TLS Server Name Indication <p>Użyj parametru jako wartości rozszerzenia TLS Server Name Indication
(<a href="http://www.ietf.org/rfc/rfc3546.txt" class="rfc">RFC 3546</a>).</p> (<a href="http://www.ietf.org/rfc/rfc3546.txt" class="rfc">RFC 3546</a>).</p>
<p>Opcja <em>sni</em> jest dostępna począwszy od wersji 1.0.0 biblioteki OpenSSL.</p> <p>Opcja <em>sni</em> jest dostępna począwszy od <strong>OpenSSL 1.0.0</strong>.</p>
</dd> </dd>
<dt><strong><a name="ocsp_url" class="item"><strong>OCSP</strong> = URL</a></strong></dt> <dt><strong><a name="ocsp_url" class="item"><strong>OCSP</strong> = URL</a></strong></dt>
@ -570,7 +584,7 @@ NOEXPLICIT, NOCASIGN, NODELEGATED, NOCHECKS, TRUSTOTHER, RESPID_KEY, NOTIME</p>
<dt><strong><a name="options_opcje_ssl" class="item"><strong>options</strong> = opcje_SSL</a></strong></dt> <dt><strong><a name="options_opcje_ssl" class="item"><strong>options</strong> = opcje_SSL</a></strong></dt>
<dd> <dd>
<p>opcje biblioteki OpenSSL</p> <p>opcje biblioteki <strong>OpenSSL</strong></p>
<p>Parametrem jest nazwa opcji zgodnie z opisem w <em>SSL_CTX_set_options(3ssl)</em>, <p>Parametrem jest nazwa opcji zgodnie z opisem w <em>SSL_CTX_set_options(3ssl)</em>,
ale bez przedrostka <em>SSL_OP_</em>. ale bez przedrostka <em>SSL_OP_</em>.
Aby wyspecyfikować kilka opcji należy użyć <em>options</em> wielokrotnie.</p> Aby wyspecyfikować kilka opcji należy użyć <em>options</em> wielokrotnie.</p>
@ -582,8 +596,10 @@ w programie Eudora można użyć opcji:</p>
<dt><strong><a name="protocol_protok" class="item"><strong>protocol</strong> = protokół</a></strong></dt> <dt><strong><a name="protocol_protok" class="item"><strong>protocol</strong> = protokół</a></strong></dt>
<dd> <dd>
<p>negocjuj SSL podanym protokołem aplikacyjnym (np. <em>starttls</em> lub <em>stls</em>)</p> <p>negocjuj SSL podanym protokołem aplikacyjnym</p>
<p>Opcji <em>protocol</em> nie należy używać z szyfrowaniem SSL na osobnym porcie.</p> <p>Opcja ta włącza wstępną negocjację szyfrowania SSL dla wybranego protokołu
aplikacyjnego.
Opcji <em>protocol</em> nie należy używać z szyfrowaniem SSL na osobnym porcie.</p>
<p>Aktualnie wspierane protokoły:</p> <p>Aktualnie wspierane protokoły:</p>
<dl> <dl>
<dt><strong><a name="cifs" class="item"><em>cifs</em></a></strong></dt> <dt><strong><a name="cifs" class="item"><em>cifs</em></a></strong></dt>
@ -643,6 +659,11 @@ Wsparcie dla tego rozrzeczenia zostało zarzucone w wersji 3.0.0 serwera Samba.<
<dd> <dd>
<p>adres docelowy do negocjacji protokołu</p> <p>adres docelowy do negocjacji protokołu</p>
<p><em>protocolHost</em> określa docelowy serwer SSL, do którego połączyć ma się proxy.
Nie jest to adres serwera proxy, do którego połączenie zestawia <strong>stunnel</strong>.
Adres serwera proxy powinien być określony przy pomocy opcji 'connect'.</p>
<p>W obecnej wersji adres docelowy protokołu ma zastosowanie wyłącznie w protokole
'connect'.</p>
</dd> </dd>
<dt><strong><a name="protocolpassword_has_o" class="item"><strong>protocolPassword</strong> = hasło</a></strong></dt> <dt><strong><a name="protocolpassword_has_o" class="item"><strong>protocolPassword</strong> = hasło</a></strong></dt>
@ -659,16 +680,48 @@ Wsparcie dla tego rozrzeczenia zostało zarzucone w wersji 3.0.0 serwera Samba.<
<dd> <dd>
<p>alokuj pseudoterminal dla programu uruchamianego w opcji 'exec'</p> <p>alokuj pseudoterminal dla programu uruchamianego w opcji 'exec'</p>
</dd> </dd>
<dt><strong><strong>retry</strong> = yes | no (tylko Unix)</strong></dt> <dt><strong><a name="renegotiation_yes_no" class="item"><strong>renegotiation</strong> = yes | no</a></strong></dt>
<dd>
<p>pozwalaj na renegocjację SSL</p>
<p>Wśród zastosowań renegocjacji SSL są niektóre scenariusze uwierzytelnienia,
oraz renegocjacja kluczy dla długotrwałych połączeń.</p>
<p>Z drugiej strony własność na może ułatwić trywialny atak DoS poprzez
wygenerowanie obciążenia procesora:</p>
<p><a href="http://vincent.bernat.im/en/blog/2011-ssl-dos-mitigation.html">http://vincent.bernat.im/en/blog/2011-ssl-dos-mitigation.html</a></p>
<p>Warto zauważyć, że zablokowanie renegocjacji SSL nie zebezpiecza w pełni
przed opisanym problemem.</p>
<p>domyślnie: yes (o ile wspierane przez <strong>OpenSSL</strong>)</p>
</dd>
<dt><strong><a name="reset_yes_no" class="item"><strong>reset</strong> = yes | no</a></strong></dt>
<dd>
<p>sygnalizuj wystąpienie błędu przy pomocy flagi TCP RST</p>
<p>Ta opcja nie jest wspierana na niektórych platformach.</p>
<p>domyślnie: yes</p>
</dd>
<dt><strong><a name="retry_yes_no" class="item"><strong>retry</strong> = yes | no</a></strong></dt>
<dd> <dd>
<p>połącz ponownie sekcję connect+exec po rozłączeniu</p> <p>połącz ponownie sekcję connect+exec po rozłączeniu</p>
<p>domyślnie: no</p> <p>domyślnie: no</p>
</dd> </dd>
<dt><strong><a name="session_przeterminowanie_pami_ci_podr_cznej_sesji" class="item"><strong>session</strong> = przeterminowanie_pamięci_podręcznej_sesji</a></strong></dt> <dt><strong><a name="sessioncachesize_rozmiar" class="item"><strong>sessionCacheSize</strong> = rozmiar</a></strong></dt>
<dd> <dd>
<p>czas w sekundach, po którym sesja SSL zostanie usunięta z pamięci podręcznej</p> <p>rozmiar pamięci podręcznej sesji SSL</p>
<p>Parametr określa maksymalną liczbę pozycji wewnętrznej pamięci podręcznej
sesji.</p>
<p>Wartość 0 oznacza brak ograniczenia rozmiaru. Nie jest to zalecane dla
systemów produkcyjnych z uwagi na ryzyko ataku DoS przez wyczerpanie pamięci
RAM.</p>
</dd>
<dt><strong><a name="sessioncachetimeout_czas" class="item"><strong>sessionCacheTimeout</strong> = czas</a></strong></dt>
<dd>
<p>przeterminowanie pamięci podręcznej sesji SSL</p>
<p>Parametr określa czas w sekundach, po którym sesja SSL zostanie usunięta z
pamięci podręcznej.</p>
</dd> </dd>
<dt><strong><a name="sessiond_adres_port" class="item"><strong>sessiond</strong> = adres:port</a></strong></dt> <dt><strong><a name="sessiond_adres_port" class="item"><strong>sessiond</strong> = adres:port</a></strong></dt>
@ -679,7 +732,7 @@ Wsparcie dla tego rozrzeczenia zostało zarzucone w wersji 3.0.0 serwera Samba.<
<dd> <dd>
<p>wersja protokołu SSL</p> <p>wersja protokołu SSL</p>
<p>Dozwolone opcje: all, SSLv2, SSLv3, TLSv1</p> <p>Dozwolone opcje: all, SSLv2, SSLv3, TLSv1, TLSv1.1, TLSv1.2</p>
</dd> </dd>
<dt><strong><a name="w" class="item"><strong>stack</strong> = liczba_bajtów (z wyjątkiem modelu FORK)</a></strong></dt> <dt><strong><a name="w" class="item"><strong>stack</strong> = liczba_bajtów (z wyjątkiem modelu FORK)</a></strong></dt>
@ -721,7 +774,7 @@ Wsparcie dla tego rozrzeczenia zostało zarzucone w wersji 3.0.0 serwera Samba.<
<dd> <dd>
<p>Przepisz adres, aby nawiązywane połączenie wydawało się pochodzić <p>Przepisz adres, aby nawiązywane połączenie wydawało się pochodzić
bezpośrednio od klienta, a nie od programu <em>stunnel</em>.</p> bezpośrednio od klienta, a nie od programu <strong>stunnel</strong>.</p>
<p>Opcja jest aktualnie obsługiwana w:</p> <p>Opcja jest aktualnie obsługiwana w:</p>
<dl> <dl>
<dt><strong><a name="zdalnym" class="item">Trybie zdalnym (opcja <em>connect</em>) w systemie <em>Linux &gt;=2.6.28</em></a></strong></dt> <dt><strong><a name="zdalnym" class="item">Trybie zdalnym (opcja <em>connect</em>) w systemie <em>Linux &gt;=2.6.28</em></a></strong></dt>
@ -744,7 +797,7 @@ bezpośrednio od klienta, a nie od programu <em>stunnel</em>.</p>
<dd> <dd>
<p>Konfiguracja ta wymaga skompilowania jądra z opcją <em>transparent proxy</em>. <p>Konfiguracja ta wymaga skompilowania jądra z opcją <em>transparent proxy</em>.
Docelowa usługa musi być umieszczona na osobnej maszynie, do której routing Docelowa usługa musi być umieszczona na osobnej maszynie, do której routing
kierowany jest poprzez serwer stunnela.</p> kierowany jest poprzez serwer <strong>stunnela</strong>.</p>
<p>Dodatkowo <strong>stunnel</strong> powinien być wykonywany jako root i bez opcji <em>setuid</em>.</p> <p>Dodatkowo <strong>stunnel</strong> powinien być wykonywany jako root i bez opcji <em>setuid</em>.</p>
</dd> </dd>
<dt><strong>Trybie zdalnym (opcja <em>connect</em>) w systemie <em>FreeBSD &gt;=8.0</em></strong></dt> <dt><strong>Trybie zdalnym (opcja <em>connect</em>) w systemie <em>FreeBSD &gt;=8.0</em></strong></dt>
@ -805,18 +858,36 @@ dodatkowe opcje:</p>
<dd> <dd>
<p>weryfikuj certyfikat drugiej strony połączenia</p> <p>weryfikuj certyfikat drugiej strony połączenia</p>
<dl> <dl>
<dt><strong><a name="poziom_0_zarz_daj_certyfikatu_i_zignoruj_go" class="item"><em>poziom 0</em> - zarządaj certyfikatu i zignoruj go</a></strong></dt> <dt><strong><a name="poziom_0" class="item"><em>poziom 0</em></a></strong></dt>
<dt><strong><a name="poziom_1_weryfikuj_je_eli_zosta_przedstawiony" class="item"><em>poziom 1</em> - weryfikuj, jeżeli został przedstawiony</a></strong></dt> <dd>
<p>zarządaj certyfikatu i zignoruj go</p>
</dd>
<dt><strong><a name="poziom_1" class="item"><em>poziom 1</em></a></strong></dt>
<dt><strong><a name="poziom_2_weryfikuj_z_zainstalowanym_certyfikatem_centrum_certyfikacji" class="item"><em>poziom 2</em> - weryfikuj z zainstalowanym certyfikatem Centrum Certyfikacji</a></strong></dt> <dd>
<p>weryfikuj, jeżeli został przedstawiony</p>
</dd>
<dt><strong><a name="poziom_2" class="item"><em>poziom 2</em></a></strong></dt>
<dt><strong><a name="poziom_3_weryfikuj_z_lokalnie_zainstalowanym_certyfikatem_drugiej_strony" class="item"><em>poziom 3</em> - weryfikuj z lokalnie zainstalowanym certyfikatem drugiej strony</a></strong></dt> <dd>
<p>weryfikuj z zainstalowanym certyfikatem Centrum Certyfikacji</p>
</dd>
<dt><strong><a name="poziom_3" class="item"><em>poziom 3</em></a></strong></dt>
<dt><strong><a name="poziom_4_weryfikuj_z_certyfikatem_drugiej_strony_ignoruj_c_a_cuch_ca" class="item"><em>poziom 4</em> - weryfikuj z certyfikatem drugiej strony ignorując łańcuch CA</a></strong></dt> <dd>
<p>weryfikuj z lokalnie zainstalowanym certyfikatem drugiej strony</p>
</dd>
<dt><strong><a name="poziom_4" class="item"><em>poziom 4</em></a></strong></dt>
<dt><strong><a name="domy_lnie_nie_weryfikuj" class="item"><em>domyślnie</em> - nie weryfikuj</a></strong></dt> <dd>
<p>weryfikuj z certyfikatem drugiej strony ignorując łańcuch CA</p>
</dd>
<dt><strong><a name="domy_lnie" class="item"><em>domyślnie</em></a></strong></dt>
<dd>
<p>nie weryfikuj</p>
</dd>
</dl> </dl>
</dd> </dd>
</dl> </dl>
@ -838,25 +909,25 @@ w przypadku błędu.</p>
<p>Załaduj ponownie plik konfiguracyjny.</p> <p>Załaduj ponownie plik konfiguracyjny.</p>
<p>Niektóre globalne opcje nie będą przeładowane:</p> <p>Niektóre globalne opcje nie będą przeładowane:</p>
<ul> <ul>
<li><strong><a name="chroot" class="item">chroot</a></strong> <li>
<p>chroot</p>
</li> </li>
<li><strong><a name="foreground" class="item">foreground</a></strong> <li>
<p>foreground</p>
</li> </li>
<li><strong><a name="pid" class="item">pid</a></strong> <li>
<p>pid</p>
</li> </li>
<li><strong><a name="setgid" class="item">setgid</a></strong> <li>
<p>setgid</p>
</li> </li>
<li><strong><a name="setuid" class="item">setuid</a></strong> <li>
<p>setuid</p>
</li> </li>
</ul> </ul>
<p>Jeżeli wykorzystywana jest opcja 'setuid' stunnel nie będzie mógł załadować <p>Jeżeli wykorzystywana jest opcja 'setuid' <strong>stunnel</strong> nie będzie mógł załadować
ponownie konfiguracji wykorzystującej uprzywilejowane (&lt;1024) porty.</p> ponownie konfiguracji wykorzystującej uprzywilejowane (&lt;1024) porty.</p>
<p>Jeżeli wykorzystywana jest opcja 'chroot' stunnel będzie szukał wszystkich <p>Jeżeli wykorzystywana jest opcja 'chroot' <strong>stunnel</strong> będzie szukał wszystkich
potrzebnych plików (łącznie z plikiem konfiguracyjnym, certyfikatami, logiem i potrzebnych plików (łącznie z plikiem konfiguracyjnym, certyfikatami, logiem i
plikiem pid) wewnątrz katalogu wskazanego przez 'chroot'.</p> plikiem pid) wewnątrz katalogu wskazanego przez 'chroot'.</p>
</dd> </dd>
@ -864,7 +935,7 @@ plikiem pid) wewnątrz katalogu wskazanego przez 'chroot'.</p>
<dd> <dd>
<p>Zamknij i otwórz ponownie log. <p>Zamknij i otwórz ponownie log.
Funkcja ta może zostać użyta w skrypcie rotującym log programu stunnel.</p> Funkcja ta może zostać użyta w skrypcie rotującym log programu <strong>stunnel</strong>.</p>
</dd> </dd>
<dt><strong><a name="sigterm_sigquit_sigint" class="item">SIGTERM, SIGQUIT, SIGINT</a></strong></dt> <dt><strong><a name="sigterm_sigquit_sigint" class="item">SIGTERM, SIGQUIT, SIGINT</a></strong></dt>
@ -910,7 +981,7 @@ konfiguracyjnym nie ma sekcji <em>[nazwa_usługi]</em>.</p>
<p> <p>
</p> </p>
<h2><a name="ograniczenia">OGRANICZENIA</a></h2> <h2><a name="ograniczenia">OGRANICZENIA</a></h2>
<p><em>stunnel</em> nie może być używany do szyfrowania protokołu <em>FTP</em>, <p><strong>stunnel</strong> nie może być używany do szyfrowania protokołu <em>FTP</em>,
ponieważ do przesyłania poszczególnych plików używa on dodatkowych ponieważ do przesyłania poszczególnych plików używa on dodatkowych
połączeń otwieranych na portach o dynamicznie przydzielanych numerach. połączeń otwieranych na portach o dynamicznie przydzielanych numerach.
Istnieją jednak specjalne wersje klientów i serwerów FTP pozwalające Istnieją jednak specjalne wersje klientów i serwerów FTP pozwalające
@ -943,9 +1014,9 @@ globalnymi. Przykład takiej konfiguracji znajduje się w sekcji
połączenie klientowi prawidłowym certyfikatem X.509. połączenie klientowi prawidłowym certyfikatem X.509.
Potwierdzenie tożsamości serwera polega na wykazaniu, że posiada on Potwierdzenie tożsamości serwera polega na wykazaniu, że posiada on
odpowiadający certyfikatowi klucz prywatny. odpowiadający certyfikatowi klucz prywatny.
Najprostszą metodą uzyskania certyfikatu jest wygenerowanie Najprostszą metodą uzyskania certyfikatu jest wygenerowanie go przy pomocy
go przy pomocy wolnego pakietu <em>OpenSSL</em>. Więcej informacji na temat wolnego pakietu <strong>OpenSSL</strong>. Więcej informacji na temat generowania
generowania certyfikatów można znaleźć na umieszczonych poniżej stronach.</p> certyfikatów można znaleźć na umieszczonych poniżej stronach.</p>
<p>Istotną kwestią jest kolejność zawartości pliku <em>.pem</em>. <p>Istotną kwestią jest kolejność zawartości pliku <em>.pem</em>.
W pierwszej kolejności powinien on zawierać klucz prywatny, W pierwszej kolejności powinien on zawierać klucz prywatny,
a dopiero za nim podpisany certyfikat (nie żądanie certyfikatu). a dopiero za nim podpisany certyfikat (nie żądanie certyfikatu).
@ -970,39 +1041,39 @@ gdyż protokół SSL wymaga do bezpieczeństwa kryptograficznego źródła
dobrej losowości. Następujące źródła są kolejno odczytywane aż do dobrej losowości. Następujące źródła są kolejno odczytywane aż do
uzyskania wystarczającej ilości entropii:</p> uzyskania wystarczającej ilości entropii:</p>
<ul> <ul>
<li><strong><a name="zawarto_pliku_podanego_w_opcji_rndfile" class="item">Zawartość pliku podanego w opcji <em>RNDfile</em>.</a></strong> <li>
<p>Zawartość pliku podanego w opcji <em>RNDfile</em>.</p>
</li> </li>
<li><strong><a name="zawarto_pliku_o_nazwie_okre_lonej_przez_zmienn_rodowiskow_randfile_o_ile_jest_ona_ustawiona" class="item">Zawartość pliku o nazwie określonej przez zmienną środowiskową <li>
RANDFILE, o ile jest ona ustawiona.</a></strong> <p>Zawartość pliku o nazwie określonej przez zmienną środowiskową
RANDFILE, o ile jest ona ustawiona.</p>
</li> </li>
<li><strong><a name="plik_rnd_umieszczony_w_katalogu_domowym_u_ytkownika_je_eli_zmienna_randfile_nie_jest_ustawiona" class="item">Plik .rnd umieszczony w katalogu domowym użytkownika, <li>
jeżeli zmienna RANDFILE nie jest ustawiona.</a></strong> <p>Plik .rnd umieszczony w katalogu domowym użytkownika,
jeżeli zmienna RANDFILE nie jest ustawiona.</p>
</li> </li>
<li><strong><a name="plik_podany_w_opcji_with_random_w_czasie_konfiguracji_programu" class="item">Plik podany w opcji '--with-random' w czasie konfiguracji programu.</a></strong> <li>
<p>Plik podany w opcji '--with-random' w czasie konfiguracji programu.</p>
</li> </li>
<li><strong><a name="zawarto_ekranu_w_systemie_windows" class="item">Zawartość ekranu w systemie Windows.</a></strong> <li>
<p>Zawartość ekranu w systemie Windows.</p>
</li> </li>
<li><strong><a name="gniazdo_egd_je_eli_u_yta_zosta_a_opcja_egd" class="item">Gniazdo egd, jeżeli użyta została opcja <em>EGD</em>.</a></strong> <li>
<p>Gniazdo egd, jeżeli użyta została opcja <em>EGD</em>.</p>
</li> </li>
<li><strong><a name="gniazdo_egd_podane_w_opcji_with_egd_socket_w_czasie_konfiguracji_programu" class="item">Gniazdo egd podane w opcji '--with-egd-socket' w czasie konfiguracji <li>
programu.</a></strong> <p>Gniazdo egd podane w opcji '--with-egd-socket' w czasie konfiguracji
programu.</p>
</li> </li>
<li><strong><a name="urz_dzenie_dev_urandom" class="item">Urządzenie /dev/urandom.</a></strong> <li>
<p>Urządzenie /dev/urandom.</p>
</li> </li>
</ul> </ul>
<p>Współczesne (&gt;=0.9.5a) wersje biblioteki <em>OpenSSL</em> automatycznie <p>Współczesne (<strong>0.9.5a</strong> lub nowsze) wersje biblioteki <strong>OpenSSL</strong> automatycznie
zaprzestają ładowania kolejnych danych w momencie uzyskania wystarczającej zaprzestają ładowania kolejnych danych w momencie uzyskania wystarczającej
ilości entropii. Wcześniejsze wersje biblioteki wykorzystają wszystkie ilości entropii. Wcześniejsze wersje biblioteki wykorzystają wszystkie
powyższe źródła, gdyż nie istnieje tam funkcja pozwalająca określić, powyższe źródła, gdyż nie istnieje tam funkcja pozwalająca określić, czy
czy uzyskano już wystarczająco dużo danych.</p> uzyskano już wystarczająco dużo danych.</p>
<p>Warto zwrócić uwagę, że na maszynach z systemem Windows, na których <p>Warto zwrócić uwagę, że na maszynach z systemem Windows, na których
konsoli nie pracuje użytkownik, zawartość ekranu nie jest wystarczająco konsoli nie pracuje użytkownik, zawartość ekranu nie jest wystarczająco
zmienna, aby zainicjować PRNG. W takim przypadku do zainicjowania zmienna, aby zainicjować PRNG. W takim przypadku do zainicjowania
@ -1012,17 +1083,17 @@ generatora należy użyć opcji <em>RNDfile</em>.</p>
O ile nie użyta została opcja <em>RNDoverwrite</em> jest to robione O ile nie użyta została opcja <em>RNDoverwrite</em> jest to robione
automatycznie. Do ręcznego uzyskania takiego pliku użyteczna automatycznie. Do ręcznego uzyskania takiego pliku użyteczna
może być komenda <em>openssl rand</em> dostarczana ze współczesnymi może być komenda <em>openssl rand</em> dostarczana ze współczesnymi
wersjami pakietu <em>OpenSSL</em>.</p> wersjami pakietu <strong>OpenSSL</strong>.</p>
<p>Jeszcze jedna istotna informacja -- jeżeli dostępne jest urządzenie <p>Jeszcze jedna istotna informacja -- jeżeli dostępne jest urządzenie
<em>/dev/urandom</em> biblioteka <em>OpenSSL</em> ma zwyczaj zasilania nim PRNG w trakcie <em>/dev/urandom</em> biblioteka <strong>OpenSSL</strong> ma zwyczaj zasilania nim PRNG w trakcie
sprawdzania stanu generatora. W systemach z <em>/dev/urandom</em> urządzenie sprawdzania stanu generatora. W systemach z <em>/dev/urandom</em> urządzenie
to będzie najprawdopodobniej użyte, pomimo że znajduje się na samym końcu to będzie najprawdopodobniej użyte, pomimo że znajduje się na samym końcu
powyższej listy. Jest to właściwość biblioteki <em>OpenSSL</em>, a nie programu powyższej listy. Jest to właściwość biblioteki <strong>OpenSSL</strong>, a nie programu
<em>stunnel</em>.</p> <strong>stunnel</strong>.</p>
<p> <p>
</p> </p>
<h2><a name="parametry_dh">PARAMETRY DH</a></h2> <h2><a name="parametry_dh">PARAMETRY DH</a></h2>
<p>Począwszy od wersji 4.40 stunnel zawiera w kodzie programu 2048-bitowe <p>Począwszy od wersji 4.40 <strong>stunnel</strong> zawiera w kodzie programu 2048-bitowe
parametry DH.</p> parametry DH.</p>
<p>Alternatywnie parametry DH można umieścić w pliku razem z certyfikatem:</p> <p>Alternatywnie parametry DH można umieścić w pliku razem z certyfikatem:</p>
<pre> <pre>
@ -1043,7 +1114,7 @@ parametry DH.</p>
</p> </p>
<hr /> <hr />
<h1><a name="b____dy">BŁĘDY</a></h1> <h1><a name="b____dy">BŁĘDY</a></h1>
<p>Opcja <em>execargs</em> nie obsługuje cytowania.</p> <p>Opcja <em>execargs</em> oraz linia komend Win32 nie obsługuje cytowania.</p>
<p> <p>
</p> </p>
<hr /> <hr />
@ -1062,12 +1133,12 @@ parametry DH.</p>
<dt><strong><a name="http_www_stunnel_org" class="item"><em class="file"><a href="http://www.stunnel.org/">http://www.stunnel.org/</a></em></a></strong></dt> <dt><strong><a name="http_www_stunnel_org" class="item"><em class="file"><a href="http://www.stunnel.org/">http://www.stunnel.org/</a></em></a></strong></dt>
<dd> <dd>
<p>strona domowa programu <em>stunnel</em></p> <p>strona domowa programu <strong>stunnel</strong></p>
</dd> </dd>
<dt><strong><a name="http_www_openssl_org" class="item"><em class="file"><a href="http://www.openssl.org/">http://www.openssl.org/</a></em></a></strong></dt> <dt><strong><a name="http_www_openssl_org" class="item"><em class="file"><a href="http://www.openssl.org/">http://www.openssl.org/</a></em></a></strong></dt>
<dd> <dd>
<p>strona projektu <em>OpenSSL</em></p> <p>strona projektu <strong>OpenSSL</strong></p>
</dd> </dd>
</dl> </dl>
<p> <p>

View File

@ -94,13 +94,21 @@ Linia w pliku konfiguracyjnym może być:
=over 4 =over 4
=item * pusta (ignorowana) =item *
=item * komentarzem rozpoczynającym się znakiem ';' (ignorowana) pusta (ignorowana)
=item * parą 'nazwa_opcji = wartość_opcji' =item *
=item * tekstem '[nazwa_usługi]' wskazującym początek definicji usługi komentarzem rozpoczynającym się znakiem ';' (ignorowana)
=item *
parą 'nazwa_opcji = wartość_opcji'
=item *
tekstem '[nazwa_usługi]' wskazującym początek definicji usługi
=back =back
@ -108,11 +116,17 @@ Parametr adres może być:
=over 4 =over 4
=item * numerem portu =item *
=item * oddzieloną średnikiem parą adresu (IPv4, IPv6, lub nazwą domenową) i numeru portu numerem portu
=item * ścieżką do gniazda Unix (tylko Unix) =item *
oddzieloną średnikiem parą adresu (IPv4, IPv6, lub nazwą domenową) i numeru portu
=item *
ścieżką do gniazda Unix (tylko Unix)
=back =back
@ -130,6 +144,24 @@ połączeń. Ścieżki podane w opcjach I<CApath>, I<CRLpath>, I<pid>
oraz I<exec> muszą być umieszczone wewnątrz katalogu podanego w opcji oraz I<exec> muszą być umieszczone wewnątrz katalogu podanego w opcji
I<chroot> i określone względem tego katalogu. I<chroot> i określone względem tego katalogu.
Niektóre funkcje systemu operacyjnego mogą wymagać dodatkowych plików umieszczonych w katalogu podanego w parametrze chroot:
=over 4
=item *
opóźnione rozwinięcie adresów DNS typowo wymaga /etc/nsswitch.conf i /etc/resolv.conf
=item *
lokalizacja strefy czasowej w logach wymaga pliku /etc/timezone
=item *
niektóre inne pliki mogą potrzebować plików urządzeń, np. /dev/zero lub /dev/null
=back
=item B<compression> = deflate | zlib | rle =item B<compression> = deflate | zlib | rle
wybór algorytmu kompresji przesyłanych danych wybór algorytmu kompresji przesyłanych danych
@ -138,10 +170,10 @@ domyślnie: bez kompresji
Algorytm deflate jest standardową metodą kompresji zgodnie z RFC 1951. Algorytm deflate jest standardową metodą kompresji zgodnie z RFC 1951.
Kompresja zlib zaimplementowana w OpenSSL 0.9.8 i nowszych nie jest Kompresja zlib zaimplementowana w B<OpenSSL 0.9.8> i nowszych nie jest
kompatybilna implementacją OpenSSL 0.9.7. kompatybilna implementacją B<OpenSSL 0.9.7>.
Kompresja rle nie jest zaimplementowana w aktualnych wersjach OpenSSL. Kompresja rle nie jest zaimplementowana w aktualnych wersjach B<OpenSSL>.
=item B<debug> = poziom[.podsystem] =item B<debug> = poziom[.podsystem]
@ -165,7 +197,7 @@ Wielkość liter jest ignorowana zarówno dla poziomu jak podsystemu.
Opcja pozwala określić ścieżkę do gniazda programu Entropy Gathering Daemon Opcja pozwala określić ścieżkę do gniazda programu Entropy Gathering Daemon
używanego do zainicjalizowania generatora ciągów pseudolosowych biblioteki używanego do zainicjalizowania generatora ciągów pseudolosowych biblioteki
OpenSSL. Opcja jest dostępna z biblioteką OpenSSL 0.9.5a lub nowszą. B<OpenSSL>. Opcja jest dostępna z biblioteką B<OpenSSL 0.9.5a> lub nowszą.
=item B<engine> = auto | <identyfikator urządzenia> =item B<engine> = auto | <identyfikator urządzenia>
@ -199,8 +231,8 @@ modułu kryptograficznego urządzenia.
Włącz lub wyłącz tryb FIPS 140-2. Włącz lub wyłącz tryb FIPS 140-2.
Opcja pozwala wyłączyć wejście w tryb FIPS, jeśli stunnel został skompilowany Opcja pozwala wyłączyć wejście w tryb FIPS, jeśli B<stunnel> został
ze wsparciem dla FIPS 140-2. skompilowany ze wsparciem dla FIPS 140-2.
domyślnie: yes (pracuj w trybie FIPS 140-2) domyślnie: yes (pracuj w trybie FIPS 140-2)
@ -208,7 +240,7 @@ domyślnie: yes (pracuj w trybie FIPS 140-2)
tryb pierwszoplanowy tryb pierwszoplanowy
Użycie tej opcji powoduje, że I<stunnel> nie przechodzi w tło logując Użycie tej opcji powoduje, że B<stunnel> nie przechodzi w tło logując
swoje komunikaty na konsolę zamiast przez I<syslog> (o ile nie użyto swoje komunikaty na konsolę zamiast przez I<syslog> (o ile nie użyto
opcji I<output>). opcji I<output>).
@ -235,7 +267,7 @@ względem tego katalogu.
liczba bajtów do zainicjowania generatora pseudolosowego liczba bajtów do zainicjowania generatora pseudolosowego
W wersjach biblioteki OpenSSL starszych niż 0.9.5a opcja ta określa W wersjach biblioteki B<OpenSSL> starszych niż B<0.9.5a> opcja ta określa
również liczbę bajtów wystarczających do zainicjowania PRNG. również liczbę bajtów wystarczających do zainicjowania PRNG.
Nowsze wersje biblioteki mają wbudowaną funkcję określającą, czy Nowsze wersje biblioteki mają wbudowaną funkcję określającą, czy
dostarczona ilość losowości jest wystarczająca do zainicjowania generatora. dostarczona ilość losowości jest wystarczająca do zainicjowania generatora.
@ -244,7 +276,7 @@ dostarczona ilość losowości jest wystarczająca do zainicjowania generatora.
ścieżka do pliku zawierającego losowe dane ścieżka do pliku zawierającego losowe dane
Biblioteka OpenSSL użyje danych z tego pliku do zainicjowania Biblioteka B<OpenSSL> użyje danych z tego pliku do zainicjowania
generatora pseudolosowego. generatora pseudolosowego.
=item B<RNDoverwrite> = yes | no =item B<RNDoverwrite> = yes | no
@ -261,11 +293,11 @@ domyślnie: stunnel
=item B<setgid> = identyfikator_grupy (tylko Unix) =item B<setgid> = identyfikator_grupy (tylko Unix)
grupa z której prawami pracował będzie I<stunnel> grupa z której prawami pracował będzie B<stunnel>
=item B<setuid> = identyfikator_użytkownika (tylko Unix) =item B<setuid> = identyfikator_użytkownika (tylko Unix)
użytkownik, z którego prawami pracował będzie I<stunnel> użytkownik, z którego prawami pracował będzie B<stunnel>
=item B<socket> = a|l|r:option=value[:value] =item B<socket> = a|l|r:option=value[:value]
@ -322,7 +354,7 @@ lub I<tcpserver>), należy przeczytać sekcję I<TRYB INETD> poniżej.
nasłuchuje na połączenia na podanym adresie i porcie nasłuchuje na połączenia na podanym adresie i porcie
Jeżeli nie został podany adres, I<stunnel> domyślnie nasłuchuje Jeżeli nie został podany adres, B<stunnel> domyślnie nasłuchuje
na wszystkich adresach IPv4 lokalnych interfejsów. na wszystkich adresach IPv4 lokalnych interfejsów.
Aby nasłuchiwać na wszystkich adresach IPv6 należy użyć: Aby nasłuchiwać na wszystkich adresach IPv6 należy użyć:
@ -338,8 +370,8 @@ jeżeli użyta została opcja I<verify>. Pliki z certyfikatami muszą
posiadać specjalne nazwy XXXXXXXX.0, gdzie XXXXXXXX jest skrótem posiadać specjalne nazwy XXXXXXXX.0, gdzie XXXXXXXX jest skrótem
kryptograficznym reprezentacji DER nazwy podmiotu certyfikatu. kryptograficznym reprezentacji DER nazwy podmiotu certyfikatu.
Funkcja skrótu została zmieniona w wersji 1.0.0 biblioteki OpenSSL. Funkcja skrótu została zmieniona w B<OpenSSL 1.0.0>.
Należy wykonać c_rehash przy zmianie OpenSSL 0.x.x na 1.x.x. Należy wykonać c_rehash przy zmianie B<OpenSSL 0.x.x> na B<1.x.x>.
Jeżeli zdefiniowano katalog I<chroot>, to ścieżka do I<CApath> jest określona Jeżeli zdefiniowano katalog I<chroot>, to ścieżka do I<CApath> jest określona
względem tego katalogu. względem tego katalogu.
@ -377,7 +409,7 @@ domyślnie: no (tryb serwerowy)
połącz się ze zdalnym serwerem na podany port połącz się ze zdalnym serwerem na podany port
Jeżeli nie został podany adres, I<stunnel> domyślnie łączy się Jeżeli nie został podany adres, B<stunnel> domyślnie łączy się
z lokalnym serwerem. z lokalnym serwerem.
Komenda może byc użyta wielokrotnie w pojedynczej sekcji Komenda może byc użyta wielokrotnie w pojedynczej sekcji
@ -393,8 +425,8 @@ jeżeli użyta została opcja I<verify>. Pliki z listami CRL muszą
posiadać specjalne nazwy XXXXXXXX.r0, gdzie XXXXXXXX jest skrótem posiadać specjalne nazwy XXXXXXXX.r0, gdzie XXXXXXXX jest skrótem
listy CRL. listy CRL.
Funkcja skrótu została zmieniona w wersji 1.0.0 biblioteki OpenSSL. Funkcja skrótu została zmieniona B<OpenSSL 1.0.0>.
Należy wykonać c_rehash przy zmianie OpenSSL 0.x.x na 1.x.x. Należy wykonać c_rehash przy zmianie B<OpenSSL 0.x.x> na B<1.x.x>.
Jeżeli zdefiniowano katalog I<chroot>, to ścieżka do I<CRLpath> jest określona Jeżeli zdefiniowano katalog I<chroot>, to ścieżka do I<CRLpath> jest określona
względem tego katalogu. względem tego katalogu.
@ -421,7 +453,7 @@ domyślnie: prime256v1
opóźnij rozwinięcie adresu DNS podanego w opcji I<connect> opóźnij rozwinięcie adresu DNS podanego w opcji I<connect>
Opcja jest przydatna przy dynamicznym DNS, albo gdy usługa DNS nie jest Opcja jest przydatna przy dynamicznym DNS, albo gdy usługa DNS nie jest
dostępna przy starcie programu stunnel (klient VPN, połączenie wdzwaniane). dostępna przy starcie programu B<stunnel> (klient VPN, połączenie wdzwaniane).
=item B<engineNum> = <numer urządzenia> =item B<engineNum> = <numer urządzenia>
@ -482,33 +514,37 @@ IP źródła do nawiązywania zdalnych połączeń
Domyślnie używane jest IP najbardziej zewnętrznego interfejsu w stronę Domyślnie używane jest IP najbardziej zewnętrznego interfejsu w stronę
serwera, do którego nawiązywane jest połączenie. serwera, do którego nawiązywane jest połączenie.
=item B<sni> = nazwa_usługi:nazwa_serwera (tryb serwera) =item B<sni> = nazwa_usługi:wzorzec_nazwy_serwera (tryb serwera)
Użyj usługi jako podrzędnej (virtualnego serwera) dla rozszerzenia TLS Server Użyj usługi jako podrzędnej (virtualnego serwera) dla rozszerzenia TLS Server
Name Indication (RFC 3546). Name Indication (RFC 3546).
I<nazwa_usługi> wskazuje usługę nadrzędną, która odbiera połączenia od klientów I<nazwa_usługi> wskazuje usługę nadrzędną, która odbiera połączenia od klientów
przy pomocy opcji I<accept>. I<nazwa_serwera> wskazuje nazwę serwera przy pomocy opcji I<accept>. I<wzorzec_nazwy_serwera> wskazuje nazwę serwera
wirtualnego. Z pojedyńczą usługą nadrzędną powiązane jest zwykle wiele usług wirtualnego. Wzorzec może zaczynać się znakiem '*', np. '*.example.com".
podrzędnych. Opcja I<sni> może być rownież użyta wielokrotnie w ramach jednej Z pojedyńczą usługą nadrzędną powiązane jest zwykle wiele usług podrzędnych.
usługi podrzędnej. Opcja I<sni> może być rownież użyta wielokrotnie w ramach jednej usługi
podrzędnej.
Zarówno usługa nadrzędna jak i podrzędna nie może być skonfigurowana w trybie Zarówno usługa nadrzędna jak i podrzędna nie może być skonfigurowana w trybie
klienckim. Opcja I<connect> usługi podrzędnej jest ignorowana w połączeniu z klienckim.
opcją I<protocol>, gdyż połączenie do zdalnego serwera jest w tym wypadku
nawiązywane przed negocjacją TLS. Uwierzytelnienie przy pomocy biblioteki
libwrap jest realizowane dwukrotnie: najpierw dla usługi nadrzędnej po
odebraniu połączenia TCP, a następnie dla usługi podrzędnej podczas negocjacji
TLS.
Opcja I<sni> jest dostępna począwszy od wersji 1.0.0 biblioteki OpenSSL. Opcja I<connect> usługi podrzędnej jest ignorowana w połączeniu z opcją
I<protocol>, gdyż połączenie do zdalnego serwera jest w tym wypadku nawiązywane
przed negocjacją TLS.
Uwierzytelnienie przy pomocy biblioteki libwrap jest realizowane dwukrotnie:
najpierw dla usługi nadrzędnej po odebraniu połączenia TCP, a następnie dla
usługi podrzędnej podczas negocjacji TLS.
Opcja I<sni> jest dostępna począwszy od B<OpenSSL 1.0.0>.
=item B<sni> = nazwa_serwera (tryb klienta) =item B<sni> = nazwa_serwera (tryb klienta)
Użyj parametru jako wartości rozszerzenia TLS Server Name Indication Użyj parametru jako wartości rozszerzenia TLS Server Name Indication
(RFC 3546). (RFC 3546).
Opcja I<sni> jest dostępna począwszy od wersji 1.0.0 biblioteki OpenSSL. Opcja I<sni> jest dostępna począwszy od B<OpenSSL 1.0.0>.
=item B<OCSP> = URL =item B<OCSP> = URL
@ -525,7 +561,7 @@ Aby wyspecyfikować kilka flag należy użyć I<OCSPflag> wielokrotnie.
=item B<options> = opcje_SSL =item B<options> = opcje_SSL
opcje biblioteki OpenSSL opcje biblioteki B<OpenSSL>
Parametrem jest nazwa opcji zgodnie z opisem w I<SSL_CTX_set_options(3ssl)>, Parametrem jest nazwa opcji zgodnie z opisem w I<SSL_CTX_set_options(3ssl)>,
ale bez przedrostka I<SSL_OP_>. ale bez przedrostka I<SSL_OP_>.
@ -538,8 +574,10 @@ w programie Eudora można użyć opcji:
=item B<protocol> = protokół =item B<protocol> = protokół
negocjuj SSL podanym protokołem aplikacyjnym (np. I<starttls> lub I<stls>) negocjuj SSL podanym protokołem aplikacyjnym
Opcja ta włącza wstępną negocjację szyfrowania SSL dla wybranego protokołu
aplikacyjnego.
Opcji I<protocol> nie należy używać z szyfrowaniem SSL na osobnym porcie. Opcji I<protocol> nie należy używać z szyfrowaniem SSL na osobnym porcie.
Aktualnie wspierane protokoły: Aktualnie wspierane protokoły:
@ -599,6 +637,13 @@ domyślnie: basic
adres docelowy do negocjacji protokołu adres docelowy do negocjacji protokołu
I<protocolHost> określa docelowy serwer SSL, do którego połączyć ma się proxy.
Nie jest to adres serwera proxy, do którego połączenie zestawia B<stunnel>.
Adres serwera proxy powinien być określony przy pomocy opcji 'connect'.
W obecnej wersji adres docelowy protokołu ma zastosowanie wyłącznie w protokole
'connect'.
=item B<protocolPassword> = hasło =item B<protocolPassword> = hasło
hasło do negocjacji protokołu hasło do negocjacji protokołu
@ -611,15 +656,54 @@ nazwa użytkownika do negocjacji protokołu
alokuj pseudoterminal dla programu uruchamianego w opcji 'exec' alokuj pseudoterminal dla programu uruchamianego w opcji 'exec'
=item B<retry> = yes | no (tylko Unix) =item B<renegotiation> = yes | no
pozwalaj na renegocjację SSL
Wśród zastosowań renegocjacji SSL są niektóre scenariusze uwierzytelnienia,
oraz renegocjacja kluczy dla długotrwałych połączeń.
Z drugiej strony własność na może ułatwić trywialny atak DoS poprzez
wygenerowanie obciążenia procesora:
http://vincent.bernat.im/en/blog/2011-ssl-dos-mitigation.html
Warto zauważyć, że zablokowanie renegocjacji SSL nie zebezpiecza w pełni
przed opisanym problemem.
domyślnie: yes (o ile wspierane przez B<OpenSSL>)
=item B<reset> = yes | no
sygnalizuj wystąpienie błędu przy pomocy flagi TCP RST
Ta opcja nie jest wspierana na niektórych platformach.
domyślnie: yes
=item B<retry> = yes | no
połącz ponownie sekcję connect+exec po rozłączeniu połącz ponownie sekcję connect+exec po rozłączeniu
domyślnie: no domyślnie: no
=item B<session> = przeterminowanie_pamięci_podręcznej_sesji =item B<sessionCacheSize> = rozmiar
czas w sekundach, po którym sesja SSL zostanie usunięta z pamięci podręcznej rozmiar pamięci podręcznej sesji SSL
Parametr określa maksymalną liczbę pozycji wewnętrznej pamięci podręcznej
sesji.
Wartość 0 oznacza brak ograniczenia rozmiaru. Nie jest to zalecane dla
systemów produkcyjnych z uwagi na ryzyko ataku DoS przez wyczerpanie pamięci
RAM.
=item B<sessionCacheTimeout> = czas
przeterminowanie pamięci podręcznej sesji SSL
Parametr określa czas w sekundach, po którym sesja SSL zostanie usunięta z
pamięci podręcznej.
=item B<sessiond> = adres:port =item B<sessiond> = adres:port
@ -629,7 +713,7 @@ adres sessiond - servera cache sesji SSL
wersja protokołu SSL wersja protokołu SSL
Dozwolone opcje: all, SSLv2, SSLv3, TLSv1 Dozwolone opcje: all, SSLv2, SSLv3, TLSv1, TLSv1.1, TLSv1.2
=item B<stack> = liczba_bajtów (z wyjątkiem modelu FORK) =item B<stack> = liczba_bajtów (z wyjątkiem modelu FORK)
@ -666,7 +750,7 @@ Zablokuj wsparcie dla przezroczystago proxy. Jest to wartość domyślna.
=item B<source> =item B<source>
Przepisz adres, aby nawiązywane połączenie wydawało się pochodzić Przepisz adres, aby nawiązywane połączenie wydawało się pochodzić
bezpośrednio od klienta, a nie od programu I<stunnel>. bezpośrednio od klienta, a nie od programu B<stunnel>.
Opcja jest aktualnie obsługiwana w: Opcja jest aktualnie obsługiwana w:
@ -691,7 +775,7 @@ Konfiguracja ta wymaga, aby B<stunnel> był wykonywany jako root i bez opcji I<s
Konfiguracja ta wymaga skompilowania jądra z opcją I<transparent proxy>. Konfiguracja ta wymaga skompilowania jądra z opcją I<transparent proxy>.
Docelowa usługa musi być umieszczona na osobnej maszynie, do której routing Docelowa usługa musi być umieszczona na osobnej maszynie, do której routing
kierowany jest poprzez serwer stunnela. kierowany jest poprzez serwer B<stunnela>.
Dodatkowo B<stunnel> powinien być wykonywany jako root i bez opcji I<setuid>. Dodatkowo B<stunnel> powinien być wykonywany jako root i bez opcji I<setuid>.
@ -754,17 +838,29 @@ weryfikuj certyfikat drugiej strony połączenia
=over 4 =over 4
=item I<poziom 0> - zarządaj certyfikatu i zignoruj go =item I<poziom 0>
=item I<poziom 1> - weryfikuj, jeżeli został przedstawiony zarządaj certyfikatu i zignoruj go
=item I<poziom 2> - weryfikuj z zainstalowanym certyfikatem Centrum Certyfikacji =item I<poziom 1>
=item I<poziom 3> - weryfikuj z lokalnie zainstalowanym certyfikatem drugiej strony weryfikuj, jeżeli został przedstawiony
=item I<poziom 4> - weryfikuj z certyfikatem drugiej strony ignorując łańcuch CA =item I<poziom 2>
=item I<domyślnie> - nie weryfikuj weryfikuj z zainstalowanym certyfikatem Centrum Certyfikacji
=item I<poziom 3>
weryfikuj z lokalnie zainstalowanym certyfikatem drugiej strony
=item I<poziom 4>
weryfikuj z certyfikatem drugiej strony ignorując łańcuch CA
=item I<domyślnie>
nie weryfikuj
=back =back
@ -791,29 +887,39 @@ Niektóre globalne opcje nie będą przeładowane:
=over 4 =over 4
=item * chroot =item *
=item * foreground chroot
=item * pid =item *
=item * setgid foreground
=item * setuid =item *
pid
=item *
setgid
=item *
setuid
=back =back
Jeżeli wykorzystywana jest opcja 'setuid' stunnel nie będzie mógł załadować Jeżeli wykorzystywana jest opcja 'setuid' B<stunnel> nie będzie mógł załadować
ponownie konfiguracji wykorzystującej uprzywilejowane (<1024) porty. ponownie konfiguracji wykorzystującej uprzywilejowane (<1024) porty.
Jeżeli wykorzystywana jest opcja 'chroot' stunnel będzie szukał wszystkich Jeżeli wykorzystywana jest opcja 'chroot' B<stunnel> będzie szukał wszystkich
potrzebnych plików (łącznie z plikiem konfiguracyjnym, certyfikatami, logiem i potrzebnych plików (łącznie z plikiem konfiguracyjnym, certyfikatami, logiem i
plikiem pid) wewnątrz katalogu wskazanego przez 'chroot'. plikiem pid) wewnątrz katalogu wskazanego przez 'chroot'.
=item SIGUSR1 =item SIGUSR1
Zamknij i otwórz ponownie log. Zamknij i otwórz ponownie log.
Funkcja ta może zostać użyta w skrypcie rotującym log programu stunnel. Funkcja ta może zostać użyta w skrypcie rotującym log programu B<stunnel>.
=item SIGTERM, SIGQUIT, SIGINT =item SIGTERM, SIGQUIT, SIGINT
@ -861,7 +967,7 @@ konfiguracyjnym nie ma sekcji I<[nazwa_usługi]>.
=head2 OGRANICZENIA =head2 OGRANICZENIA
I<stunnel> nie może być używany do szyfrowania protokołu I<FTP>, B<stunnel> nie może być używany do szyfrowania protokołu I<FTP>,
ponieważ do przesyłania poszczególnych plików używa on dodatkowych ponieważ do przesyłania poszczególnych plików używa on dodatkowych
połączeń otwieranych na portach o dynamicznie przydzielanych numerach. połączeń otwieranych na portach o dynamicznie przydzielanych numerach.
Istnieją jednak specjalne wersje klientów i serwerów FTP pozwalające Istnieją jednak specjalne wersje klientów i serwerów FTP pozwalające
@ -896,9 +1002,9 @@ Protokół SSL wymaga, aby każdy serwer przedstawiał się nawiązującemu
połączenie klientowi prawidłowym certyfikatem X.509. połączenie klientowi prawidłowym certyfikatem X.509.
Potwierdzenie tożsamości serwera polega na wykazaniu, że posiada on Potwierdzenie tożsamości serwera polega na wykazaniu, że posiada on
odpowiadający certyfikatowi klucz prywatny. odpowiadający certyfikatowi klucz prywatny.
Najprostszą metodą uzyskania certyfikatu jest wygenerowanie Najprostszą metodą uzyskania certyfikatu jest wygenerowanie go przy pomocy
go przy pomocy wolnego pakietu I<OpenSSL>. Więcej informacji na temat wolnego pakietu B<OpenSSL>. Więcej informacji na temat generowania
generowania certyfikatów można znaleźć na umieszczonych poniżej stronach. certyfikatów można znaleźć na umieszczonych poniżej stronach.
Istotną kwestią jest kolejność zawartości pliku I<.pem>. Istotną kwestią jest kolejność zawartości pliku I<.pem>.
W pierwszej kolejności powinien on zawierać klucz prywatny, W pierwszej kolejności powinien on zawierać klucz prywatny,
@ -926,32 +1032,48 @@ uzyskania wystarczającej ilości entropii:
=over 4 =over 4
=item * Zawartość pliku podanego w opcji I<RNDfile>. =item *
=item * Zawartość pliku o nazwie określonej przez zmienną środowiskową Zawartość pliku podanego w opcji I<RNDfile>.
=item *
Zawartość pliku o nazwie określonej przez zmienną środowiskową
RANDFILE, o ile jest ona ustawiona. RANDFILE, o ile jest ona ustawiona.
=item * Plik .rnd umieszczony w katalogu domowym użytkownika, =item *
Plik .rnd umieszczony w katalogu domowym użytkownika,
jeżeli zmienna RANDFILE nie jest ustawiona. jeżeli zmienna RANDFILE nie jest ustawiona.
=item * Plik podany w opcji '--with-random' w czasie konfiguracji programu. =item *
=item * Zawartość ekranu w systemie Windows. Plik podany w opcji '--with-random' w czasie konfiguracji programu.
=item * Gniazdo egd, jeżeli użyta została opcja I<EGD>. =item *
=item * Gniazdo egd podane w opcji '--with-egd-socket' w czasie konfiguracji Zawartość ekranu w systemie Windows.
=item *
Gniazdo egd, jeżeli użyta została opcja I<EGD>.
=item *
Gniazdo egd podane w opcji '--with-egd-socket' w czasie konfiguracji
programu. programu.
=item * Urządzenie /dev/urandom. =item *
Urządzenie /dev/urandom.
=back =back
Współczesne (>=0.9.5a) wersje biblioteki I<OpenSSL> automatycznie Współczesne (B<0.9.5a> lub nowsze) wersje biblioteki B<OpenSSL> automatycznie
zaprzestają ładowania kolejnych danych w momencie uzyskania wystarczającej zaprzestają ładowania kolejnych danych w momencie uzyskania wystarczającej
ilości entropii. Wcześniejsze wersje biblioteki wykorzystają wszystkie ilości entropii. Wcześniejsze wersje biblioteki wykorzystają wszystkie
powyższe źródła, gdyż nie istnieje tam funkcja pozwalająca określić, powyższe źródła, gdyż nie istnieje tam funkcja pozwalająca określić, czy
czy uzyskano już wystarczająco dużo danych. uzyskano już wystarczająco dużo danych.
Warto zwrócić uwagę, że na maszynach z systemem Windows, na których Warto zwrócić uwagę, że na maszynach z systemem Windows, na których
konsoli nie pracuje użytkownik, zawartość ekranu nie jest wystarczająco konsoli nie pracuje użytkownik, zawartość ekranu nie jest wystarczająco
@ -963,18 +1085,18 @@ Plik I<RNDfile> powinien zawierać dane losowe -- również w tym sensie,
O ile nie użyta została opcja I<RNDoverwrite> jest to robione O ile nie użyta została opcja I<RNDoverwrite> jest to robione
automatycznie. Do ręcznego uzyskania takiego pliku użyteczna automatycznie. Do ręcznego uzyskania takiego pliku użyteczna
może być komenda I<openssl rand> dostarczana ze współczesnymi może być komenda I<openssl rand> dostarczana ze współczesnymi
wersjami pakietu I<OpenSSL>. wersjami pakietu B<OpenSSL>.
Jeszcze jedna istotna informacja -- jeżeli dostępne jest urządzenie Jeszcze jedna istotna informacja -- jeżeli dostępne jest urządzenie
I</dev/urandom> biblioteka I<OpenSSL> ma zwyczaj zasilania nim PRNG w trakcie I</dev/urandom> biblioteka B<OpenSSL> ma zwyczaj zasilania nim PRNG w trakcie
sprawdzania stanu generatora. W systemach z I</dev/urandom> urządzenie sprawdzania stanu generatora. W systemach z I</dev/urandom> urządzenie
to będzie najprawdopodobniej użyte, pomimo że znajduje się na samym końcu to będzie najprawdopodobniej użyte, pomimo że znajduje się na samym końcu
powyższej listy. Jest to właściwość biblioteki I<OpenSSL>, a nie programu powyższej listy. Jest to właściwość biblioteki B<OpenSSL>, a nie programu
I<stunnel>. B<stunnel>.
=head2 PARAMETRY DH =head2 PARAMETRY DH
Począwszy od wersji 4.40 stunnel zawiera w kodzie programu 2048-bitowe Począwszy od wersji 4.40 B<stunnel> zawiera w kodzie programu 2048-bitowe
parametry DH. parametry DH.
Alternatywnie parametry DH można umieścić w pliku razem z certyfikatem: Alternatywnie parametry DH można umieścić w pliku razem z certyfikatem:
@ -997,7 +1119,7 @@ plik konfiguracyjny programu
=head1 BŁĘDY =head1 BŁĘDY
Opcja I<execargs> nie obsługuje cytowania. Opcja I<execargs> oraz linia komend Win32 nie obsługuje cytowania.
=head1 ZOBACZ RÓWNIEŻ =head1 ZOBACZ RÓWNIEŻ
@ -1014,11 +1136,11 @@ biblioteka kontroli dostępu do usług internetowych
=item F<http://www.stunnel.org/> =item F<http://www.stunnel.org/>
strona domowa programu I<stunnel> strona domowa programu B<stunnel>
=item F<http://www.openssl.org/> =item F<http://www.openssl.org/>
strona projektu I<OpenSSL> strona projektu B<OpenSSL>
=back =back

View File

@ -95,13 +95,21 @@ Each line of the configuration file can be either:
=over 4 =over 4
=item * an empty line (ignored) =item *
=item * a comment starting with ';' (ignored) An empty line (ignored).
=item * an 'option_name = option_value' pair =item *
=item * '[service_name]' indicating a start of a service definition A comment starting with ';' (ignored).
=item *
An 'option_name = option_value' pair.
=item *
'[service_name]' indicating a start of a service definition.
=back =back
@ -109,11 +117,17 @@ An address parameter of an option may be either:
=over 4 =over 4
=item * a port number =item *
=item * a colon-separated pair of IP address (either IPv4, IPv6, or domain name) and port number A port number.
=item * a Unix socket path (Unix only) =item *
A colon-separated pair of IP address (either IPv4, IPv6, or domain name) and port number.
=item *
A Unix socket path (Unix only).
=back =back
@ -129,6 +143,24 @@ B<chroot> keeps B<stunnel> in chrooted jail. I<CApath>, I<CRLpath>, I<pid>
and I<exec> are located inside the jail and the patches have to be relative and I<exec> are located inside the jail and the patches have to be relative
to the directory specified with B<chroot>. to the directory specified with B<chroot>.
Several functions of the operating system also need their files to be located within chroot jail, e.g.:
=over 4
=item *
Delayed resolver typically needs /etc/nsswitch.conf and /etc/resolv.conf.
=item *
Local time in log files needs /etc/timezone.
=item *
Some other functions may need devices, e.g. /dev/zero or /dev/null.
=back
=item B<compression> = deflate | zlib | rle =item B<compression> = deflate | zlib | rle
select data compression algorithm select data compression algorithm
@ -137,10 +169,10 @@ default: no compression
deflate is the standard compression method as described in RFC 1951. deflate is the standard compression method as described in RFC 1951.
zlib compression of OpenSSL 0.9.8 or above is not backward compatible with zlib compression of B<OpenSSL 0.9.8> or above is not backward compatible with
OpenSSL 0.9.7. B<OpenSSL 0.9.7>.
rle compression is currently not implemented by the OpenSSL library. rle compression is currently not implemented by the B<OpenSSL> library.
=item B<debug> = [facility.]level =item B<debug> = [facility.]level
@ -161,8 +193,8 @@ Case is ignored for both facilities and levels.
path to Entropy Gathering Daemon socket path to Entropy Gathering Daemon socket
Entropy Gathering Daemon socket to use to feed OpenSSL random number Entropy Gathering Daemon socket to use to feed B<OpenSSL> random number
generator. (Available only if compiled with OpenSSL 0.9.5a or higher) generator. (Available only if compiled with B<OpenSSL 0.9.5a> or higher)
=item B<engine> = auto | <engine id> =item B<engine> = auto | <engine id>
@ -196,8 +228,8 @@ engine cryptogaphic module.
Enable or disable FIPS 140-2 mode. Enable or disable FIPS 140-2 mode.
This option allows to disable entering FIPS mode if stunnel was compiled with This option allows to disable entering FIPS mode if B<stunnel> was compiled
FIPS 140-2 support. with FIPS 140-2 support.
default: yes default: yes
@ -229,9 +261,9 @@ I<pid> path is relative to I<chroot> directory if specified.
bytes to read from random seed files bytes to read from random seed files
Number of bytes of data read from random seed files. With SSL versions Number of bytes of data read from random seed files. With SSL versions less
less than 0.9.5a, also determines how many bytes of data are considered than B<0.9.5a>, also determines how many bytes of data are considered
sufficient to seed the PRNG. More recent OpenSSL versions have a builtin sufficient to seed the PRNG. More recent B<OpenSSL> versions have a builtin
function to determine when sufficient randomness is available. function to determine when sufficient randomness is available.
=item B<RNDfile> = file =item B<RNDfile> = file
@ -328,8 +360,8 @@ the I<verify>. 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 XXXXXXXX.0 where XXXXXXXX is the hash value of the DER encoded subject of the
cert. cert.
The hash algorithm has been changed in OpenSSL 1.0.0. It is required to The hash algorithm has been changed in B<OpenSSL 1.0.0>. It is required to
c_rehash the directory on upgrade from OpenSSL 0.x.x to OpenSSL 1.x.x. c_rehash the directory on upgrade from B<OpenSSL 0.x.x> to B<OpenSSL 1.x.x>.
I<CApath> path is relative to I<chroot> directory if specified. I<CApath> path is relative to I<chroot> directory if specified.
@ -382,8 +414,8 @@ This is the directory in which B<stunnel> will look for CRLs when
using the I<verify>. Note that the CRLs in this directory should using the I<verify>. Note that the CRLs in this directory should
be named XXXXXXXX.r0 where XXXXXXXX is the hash value of the CRL. be named XXXXXXXX.r0 where XXXXXXXX is the hash value of the CRL.
The hash algorithm has been changed in OpenSSL 1.0.0. It is required to The hash algorithm has been changed in B<OpenSSL 1.0.0>. It is required to
c_rehash the directory on upgrade from OpenSSL 0.x.x to OpenSSL 1.x.x. c_rehash the directory on upgrade from B<OpenSSL 0.x.x> to B<OpenSSL 1.x.x>.
I<CRLpath> path is relative to I<chroot> directory if specified. I<CRLpath> path is relative to I<chroot> directory if specified.
@ -408,7 +440,7 @@ default: prime256v1
delay DNS lookup for 'connect' option delay DNS lookup for 'connect' option
This option is useful for dynamic DNS, or when DNS is not available during This option is useful for dynamic DNS, or when DNS is not available during
stunnel startup (road warrior VPN, dial-up configurations). B<stunnel> startup (road warrior VPN, dial-up configurations).
=item B<engineNum> = engine number =item B<engineNum> = engine number
@ -465,30 +497,35 @@ default: yes
IP of the outgoing interface is used as source for remote connections. IP of the outgoing interface is used as source for remote connections.
Use this option to bind a static local IP address, instead. Use this option to bind a static local IP address, instead.
=item B<sni> = service_name:server_name (server mode) =item B<sni> = service_name:server_name_pattern (server mode)
Use the service as a slave service (a name-based virtual server) for Server Use the service as a slave service (a name-based virtual server) for Server
Name Indication TLS extension (RFC 3546). Name Indication TLS extension (RFC 3546).
I<service_name> specifies the master service that accepts client connections I<service_name> specifies the master service that accepts client connections
with I<accept> option. I<server_name> specifies the host name to be redirected. with I<accept> option. I<server_name_pattern> specifies the host name to be
redirected. The pattern may start with '*' character, e.g. '*.example.com'.
Multiple slave services are normally specified for a single master service. Multiple slave services are normally specified for a single master service.
I<sni> option can also be specified more than once within a single slave service. I<sni> option can also be specified more than once within a single slave
service.
This service, as well as the master service, may not be configured in client
mode.
This service, as well as the master service, may not be configured in client mode.
I<connect> option of the slave service is ignored when I<protocol> option is I<connect> option of the slave service is ignored when I<protocol> option is
specified, as I<protocol> connects remote host before TLS handshake. specified, as I<protocol> connects remote host before TLS handshake.
Libwrap checks (Unix only) are performed twice: with master service name after Libwrap checks (Unix only) are performed twice: with master service name after
TCP connection is accepted, and with slave service name during TLS handshake. TCP connection is accepted, and with slave service name during TLS handshake.
Option I<sni> is only available when compiled with OpenSSL 1.0.0 and later. Option I<sni> is only available when compiled with B<OpenSSL 1.0.0> and later.
=item B<sni> = server_name (client mode) =item B<sni> = server_name (client mode)
Use the parameter as the value of TLS Server Name Indication (RFC 3546) Use the parameter as the value of TLS Server Name Indication (RFC 3546)
extension. extension.
Option I<sni> is only available when compiled with OpenSSL 1.0.0 and later. Option I<sni> is only available when compiled with B<OpenSSL 1.0.0> and later.
=item B<OCSP> = url =item B<OCSP> = url
@ -505,9 +542,9 @@ NOEXPLICIT, NOCASIGN, NODELEGATED, NOCHECKS, TRUSTOTHER, RESPID_KEY, NOTIME
=item B<options> = SSL_options =item B<options> = SSL_options
OpenSSL library options B<OpenSSL> library options
The parameter is the OpenSSL option name as described in the The parameter is the B<OpenSSL> option name as described in the
I<SSL_CTX_set_options(3ssl)> manual, but without I<SSL_OP_> prefix. I<SSL_CTX_set_options(3ssl)> manual, but without I<SSL_OP_> prefix.
Several I<options> can be used to specify multiple options. Several I<options> can be used to specify multiple options.
@ -518,8 +555,10 @@ the following option can be used:
=item B<protocol> = proto =item B<protocol> = proto
application protocol to negotiate SSL (e.g. I<starttls> or I<stls>) application protocol to negotiate SSL
This option enables initial, protocol-specific negotiation of the SSL/TLS
encryption.
I<protocol> option should not be used with SSL encryption on a separate port. I<protocol> option should not be used with SSL encryption on a separate port.
Currently supported protocols: Currently supported protocols:
@ -571,7 +610,7 @@ authentication type for protocol negotiations
currently supported: basic, NTLM currently supported: basic, NTLM
Currently authentication type only applies to 'connect' protocol. Currently authentication type only applies to the 'connect' protocol.
default: basic default: basic
@ -579,6 +618,12 @@ default: basic
destination address for protocol negotiations destination address for protocol negotiations
I<protocolHost> specifies the final SSL server to be connected by the proxy,
and not the proxy server directly connected by B<stunnel>.
The proxy server should be specified with the 'connect' option.
Currently protocol destination address only applies to 'connect' protocol.
=item B<protocolPassword> = password =item B<protocolPassword> = password
password for protocol negotiations password for protocol negotiations
@ -591,16 +636,53 @@ username for protocol negotiations
allocate pseudo terminal for 'exec' option allocate pseudo terminal for 'exec' option
=item B<retry> = yes | no (Unix only) =item B<renegotiation> = yes | no
support SSL renegotiation
Applications of the SSL renegotiation include some authentication scenarios,
or re-keying long lasting connections.
On the other hand this feature can facilitate a trivial CPU-exhaustion
DoS attack:
http://vincent.bernat.im/en/blog/2011-ssl-dos-mitigation.html
Please note that disabling SSL renegotiation does not fully mitigate
this issue.
default: yes (if supported by B<OpenSSL>)
=item B<reset> = yes | no
attempt to use TCP RST flag to indicate an error
This option is not supported on some platforms.
default: yes
=item B<retry> = yes | no
reconnect a connect+exec section after it's disconnected reconnect a connect+exec section after it's disconnected
default: no default: no
=item B<session> = timeout =item B<sessionCacheSize> = size
session cache size
I<sessionCacheSize> specifies the maximum number of the internal session cache
entries.
The value of 0 can be used for unlimited size. It is not recommended
for production use due to the risk of memory exhaustion DoS attack.
=item B<sessionCacheTimeout> = timeout
session cache timeout session cache timeout
This is the number of seconds to keep cached SSL sessions.
=item B<sessiond> = host:port =item B<sessiond> = host:port
address of sessiond SSL cache server address of sessiond SSL cache server
@ -609,7 +691,7 @@ address of sessiond SSL cache server
select version of SSL protocol select version of SSL protocol
Allowed options: all, SSLv2, SSLv3, TLSv1 Allowed options: all, SSLv2, SSLv3, TLSv1, TLSv1.1, TLSv1.2
=item B<stack> = bytes (except for FORK model) =item B<stack> = bytes (except for FORK model)
@ -654,7 +736,7 @@ This option is currently available in:
=item Remote mode (I<connect> option) on I<Linux E<gt>=2.6.28> =item Remote mode (I<connect> option) on I<Linux E<gt>=2.6.28>
This configuration requires stunnel to be executed as root and without This configuration requires B<stunnel> to be executed as root and without
I<setuid> option. I<setuid> option.
This configuration requires the following setup for iptables and routing This configuration requires the following setup for iptables and routing
@ -672,9 +754,10 @@ B<stunnel> must also to be executed as root and without I<setuid> option.
=item Remote mode (I<connect> option) on I<Linux 2.2.x> =item Remote mode (I<connect> option) on I<Linux 2.2.x>
This configuration requires kernel to be compiled with I<transparent proxy> option. This configuration requires kernel to be compiled with I<transparent proxy>
option.
Connected service must be installed on a separate host. Connected service must be installed on a separate host.
Routing towards the clients has to go through the stunnel box. Routing towards the clients has to go through the B<stunnel> box.
B<stunnel> must also to be executed as root and without I<setuid> option. B<stunnel> must also to be executed as root and without I<setuid> option.
@ -737,17 +820,29 @@ verify peer certificate
=over 4 =over 4
=item I<level 0> - request and ignore peer certificate =item level 0
=item I<level 1> - verify peer certificate if present Request and ignore peer certificate.
=item I<level 2> - verify peer certificate =item level 1
=item I<level 3> - verify peer with locally installed certificate Verify peer certificate if present.
=item I<level 4> - ignore CA chain and only verify peer certificate =item level 2
=item I<default> - no verify Verify peer certificate.
=item level 3
Verify peer with locally installed certificate.
=item level 4
Ignore CA chain and only verify peer certificate.
=item default
No verify.
=back =back
@ -767,7 +862,7 @@ B<stunnel> returns zero on success, non-zero on error.
=head1 SIGNALS =head1 SIGNALS
The following signals can be used to control stunnel in Unix environment: The following signals can be used to control B<stunnel> in Unix environment:
=over 4 =over 4
@ -779,33 +874,43 @@ Some global options will not be reloaded:
=over 4 =over 4
=item * chroot =item *
=item * foreground chroot
=item * pid =item *
=item * setgid foreground
=item * setuid =item *
pid
=item *
setgid
=item *
setuid
=back =back
The use of 'setuid' option will also prevent stunnel from binding privileged The use of 'setuid' option will also prevent B<stunnel> from binding privileged
(<1024) ports during configuration reloading. (<1024) ports during configuration reloading.
When 'chroot' option is used, stunnel will look for all its files (including When 'chroot' option is used, B<stunnel> will look for all its files (including
configuration file, certificates, log file and pid file) within the chroot configuration file, certificates, log file and pid file) within the chroot
jail. jail.
=item SIGUSR1 =item SIGUSR1
Close and reopen stunnel log file. Close and reopen B<stunnel> log file.
This function can be used for log rotation. This function can be used for log rotation.
=item SIGTERM, SIGQUIT, SIGINT =item SIGTERM, SIGQUIT, SIGINT
Shut stunnel down. Shut B<stunnel> down.
=back =back
@ -875,7 +980,7 @@ configurations.
Each SSL enabled daemon needs to present a valid X.509 certificate Each SSL enabled daemon needs to present a valid X.509 certificate
to the peer. It also needs a private key to decrypt the incoming 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 data. The easiest way to obtain a certificate and a key is to
generate them with the free I<OpenSSL> package. You can find more generate them with the free B<OpenSSL> package. You can find more
information on certificates generation on pages listed below. information on certificates generation on pages listed below.
The order of contents of the I<.pem> file is important. It should contain the The order of contents of the I<.pem> file is important. It should contain the
@ -901,28 +1006,44 @@ in order until sufficient random data has been gathered:
=over 4 =over 4
=item * The file specified with the I<RNDfile> flag. =item *
=item * The file specified by the RANDFILE environment variable, if set. The file specified with the I<RNDfile> flag.
=item * The file .rnd in your home directory, if RANDFILE not set. =item *
=item * The file specified with '--with-random' at compile time. The file specified by the RANDFILE environment variable, if set.
=item * The contents of the screen if running on Windows. =item *
=item * The egd socket specified with the I<EGD> flag. The file .rnd in your home directory, if RANDFILE not set.
=item * The egd socket specified with '--with-egd-sock' at compile time. =item *
=item * The /dev/urandom device. The file specified with '--with-random' at compile time.
=item *
The contents of the screen if running on Windows.
=item *
The egd socket specified with the I<EGD> flag.
=item *
The egd socket specified with '--with-egd-sock' at compile time.
=item *
The /dev/urandom device.
=back =back
With recent (>=OpenSSL 0.9.5a) version of SSL it will stop loading With recent (B<OpenSSL 0.9.5a> or later) version of SSL it will stop loading
random data automatically when sufficient entropy has been gathered. random data automatically when sufficient entropy has been gathered. With
With previous versions it will continue to gather from all the above previous versions it will continue to gather from all the above sources since
sources since no SSL function exists to tell when enough data is available. no SSL function exists to tell when enough data is available.
Note that on Windows machines that do not have console user interaction Note that on Windows machines that do not have console user interaction
(mouse movements, creating windows, etc.) the screen contents are not (mouse movements, creating windows, etc.) the screen contents are not
@ -933,14 +1054,13 @@ Note that the file specified with the I<RNDfile> flag should contain
random data -- that means it should contain different information random data -- that means it should contain different information
each time B<stunnel> is run. This is handled automatically each time B<stunnel> is run. This is handled automatically
unless the I<RNDoverwrite> flag is used. If you wish to update this file unless the I<RNDoverwrite> flag is used. If you wish to update this file
manually, the I<openssl rand> command in recent versions of OpenSSL, manually, the I<openssl rand> command in recent versions of B<OpenSSL>,
would be useful. would be useful.
One important note -- if /dev/urandom is available, OpenSSL has a habit of Important note: If /dev/urandom is available, B<OpenSSL> often seeds the PRNG
seeding the PRNG with it even when checking the random state, so on with it while checking the random state. On systems with /dev/urandom
systems with /dev/urandom you're likely to use it even though it's listed B<OpenSSL> is likely to use it even though it is listed at the very bottom of
at the very bottom of the list above. This isn't B<stunnel's> behaviour, it's the list above. This is the behaviour of B<OpenSSL> and not B<stunnel>.
OpenSSLs.
=head2 DH PARAMETERS =head2 DH PARAMETERS
@ -966,7 +1086,7 @@ B<stunnel> configuration file
=head1 BUGS =head1 BUGS
Option I<execargs> does not support quoting. Option I<execargs> and Win32 command line does not support quoting.
=head1 SEE ALSO =head1 SEE ALSO
@ -987,7 +1107,7 @@ B<stunnel> homepage
=item F<http://www.openssl.org/> =item F<http://www.openssl.org/>
OpenSSL project website B<OpenSSL> project website
=back =back

View File

@ -31,36 +31,42 @@ stunnel_CPPFLAGS += -DPIDFILE='"$(localstatedir)/run/stunnel/stunnel.pid"'
stunnel_LDFLAGS = -L$(SSLDIR)/lib64 -L$(SSLDIR)/lib -lssl -lcrypto stunnel_LDFLAGS = -L$(SSLDIR)/lib64 -L$(SSLDIR)/lib -lssl -lcrypto
# Win32 executable # Win32 executable
EXTRA_DIST = nogui.c make.bat makece.bat makew32.bat EXTRA_DIST = make.bat makece.bat makew32.bat
EXTRA_DIST += mingw.mak evc.mak vc.mak os2.mak EXTRA_DIST += mingw.mak evc.mak vc.mak os2.mak
EXTRA_PROGRAMS = stunnel.exe EXTRA_PROGRAMS = stunnel.exe tstunnel.exe
stunnel_exe_SOURCES = $(common_headers) $(common_sources) $(win32_sources) stunnel_exe_SOURCES = $(common_headers) $(common_sources) $(win32_sources)
tstunnel_exe_SOURCES = $(common_headers) $(common_sources) nogui.c
OPENSSLDIR = /usr/src/openssl-0.9.8s-fips # OPENSSLDIR = /usr/src/openssl-0.9.8u-fips
WINCPPFLAGS = -I$(OPENSSLDIR)/inc32 # WINCPPFLAGS = -I$(OPENSSLDIR)/inc32
# OPENSSLDIR = /usr/src/openssl-1.0.0f-i586 OPENSSLDIR = /usr/src/openssl-1.0.2a-i686
# WINCPPFLAGS = -I$(OPENSSLDIR)/include WINCPPFLAGS = -I$(OPENSSLDIR)/include
WINCFLAGS = -mthreads -fstack-protector -O2 -Wall -Wextra -Wno-long-long -pedantic WINCFLAGS = -mthreads -fstack-protector -O2 -Wall -Wextra -Wno-long-long -pedantic
WINLDFLAGS = -mthreads -fstack-protector -mwindows -s WINLDFLAGS = -mthreads -fstack-protector -s
WINLIBS = -L$(OPENSSLDIR) -lcrypto -lssl -lpsapi -lws2_32 -lgdi32 WINLIBS = -L$(OPENSSLDIR) -lcrypto -lssl -lpsapi -lws2_32 -lgdi32
# WINLIBS = -L$(OPENSSLDIR) -lzdll -lcrypto.dll -lssl.dll -lpsapi -lws2_32 -lgdi32 # WINLIBS = -L$(OPENSSLDIR) -lzdll -lcrypto.dll -lssl.dll -lpsapi -lws2_32 -lgdi32
# WINLIBS = -L$(OPENSSLDIR) -lzdll -lcrypto -lssl -lpsapi -lws2_32 -lgdi32 # WINLIBS = -L$(OPENSSLDIR) -lzdll -lcrypto -lssl -lpsapi -lws2_32 -lgdi32
WINOBJ = str.obj file.obj client.obj log.obj options.obj protocol.obj WINOBJ = str.obj file.obj client.obj log.obj options.obj protocol.obj
WINOBJ += network.obj resolver.obj ssl.obj ctx.obj verify.obj sthreads.obj WINOBJ += network.obj resolver.obj ssl.obj ctx.obj verify.obj sthreads.obj
WINOBJ += fd.obj stunnel.obj gui.obj resources.obj WINOBJ += fd.obj stunnel.obj
WINPREFIX = i586-mingw32msvc- WINGUIOBJ = $(WINOBJ) gui.obj resources.obj
WINNOGUIOBJ = $(WINOBJ) nogui.obj
WINPREFIX = i686-w64-mingw32-
WINGCC = $(WINPREFIX)gcc WINGCC = $(WINPREFIX)gcc
WINDRES = $(WINPREFIX)windres WINDRES = $(WINPREFIX)windres
dist-hook: stunnel.exe dist-hook: stunnel.exe tstunnel.exe
distclean-local: distclean-local:
rm -f stunnel.exe rm -f stunnel.exe tstunnel.exe
# SUFFIXES = .c .rc .obj # SUFFIXES = .c .rc .obj
stunnel.exe: $(WINOBJ) stunnel.exe: $(WINGUIOBJ)
$(WINGCC) $(WINLDFLAGS) -o stunnel.exe $(WINOBJ) $(WINLIBS) $(WINGCC) -mwindows $(WINLDFLAGS) -o stunnel.exe $(WINGUIOBJ) $(WINLIBS)
tstunnel.exe: $(WINNOGUIOBJ)
$(WINGCC) $(WINLDFLAGS) -o tstunnel.exe $(WINNOGUIOBJ) $(WINLIBS)
%.obj: %.c $(common_headers) %.obj: %.c $(common_headers)
$(WINGCC) -c $(WINCPPFLAGS) $(WINCFLAGS) -o $@ $< $(WINGCC) -c $(WINCPPFLAGS) $(WINCFLAGS) -o $@ $<

View File

@ -37,7 +37,7 @@ POST_UNINSTALL = :
build_triplet = @build@ build_triplet = @build@
host_triplet = @host@ host_triplet = @host@
bin_PROGRAMS = stunnel$(EXEEXT) bin_PROGRAMS = stunnel$(EXEEXT)
EXTRA_PROGRAMS = stunnel.exe$(EXEEXT) EXTRA_PROGRAMS = stunnel.exe$(EXEEXT) tstunnel.exe$(EXEEXT)
subdir = src subdir = src
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/config.h.in $(srcdir)/stunnel3.in $(srcdir)/config.h.in $(srcdir)/stunnel3.in
@ -110,6 +110,10 @@ am_stunnel_exe_OBJECTS = $(am__objects_2) $(am__objects_5) \
$(am__objects_6) $(am__objects_6)
stunnel_exe_OBJECTS = $(am_stunnel_exe_OBJECTS) stunnel_exe_OBJECTS = $(am_stunnel_exe_OBJECTS)
stunnel_exe_LDADD = $(LDADD) stunnel_exe_LDADD = $(LDADD)
am_tstunnel_exe_OBJECTS = $(am__objects_2) $(am__objects_5) \
nogui.$(OBJEXT)
tstunnel_exe_OBJECTS = $(am_tstunnel_exe_OBJECTS)
tstunnel_exe_LDADD = $(LDADD)
SCRIPTS = $(bin_SCRIPTS) SCRIPTS = $(bin_SCRIPTS)
DEFAULT_INCLUDES = -I.@am__isrc@ DEFAULT_INCLUDES = -I.@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/auto/depcomp depcomp = $(SHELL) $(top_srcdir)/auto/depcomp
@ -125,9 +129,9 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@ $(LDFLAGS) -o $@
SOURCES = $(libstunnel_la_SOURCES) $(stunnel_SOURCES) \ SOURCES = $(libstunnel_la_SOURCES) $(stunnel_SOURCES) \
$(stunnel_exe_SOURCES) $(stunnel_exe_SOURCES) $(tstunnel_exe_SOURCES)
DIST_SOURCES = $(libstunnel_la_SOURCES) $(stunnel_SOURCES) \ DIST_SOURCES = $(libstunnel_la_SOURCES) $(stunnel_SOURCES) \
$(stunnel_exe_SOURCES) $(stunnel_exe_SOURCES) $(tstunnel_exe_SOURCES)
ETAGS = etags ETAGS = etags
CTAGS = ctags CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@ -276,22 +280,26 @@ stunnel_CPPFLAGS = -I/usr/kerberos/include -I$(SSLDIR)/include \
-DPIDFILE='"$(localstatedir)/run/stunnel/stunnel.pid"' -DPIDFILE='"$(localstatedir)/run/stunnel/stunnel.pid"'
# Win32 executable # Win32 executable
EXTRA_DIST = nogui.c make.bat makece.bat makew32.bat mingw.mak evc.mak \ EXTRA_DIST = make.bat makece.bat makew32.bat mingw.mak evc.mak vc.mak \
vc.mak os2.mak os2.mak
stunnel_exe_SOURCES = $(common_headers) $(common_sources) $(win32_sources) stunnel_exe_SOURCES = $(common_headers) $(common_sources) $(win32_sources)
OPENSSLDIR = /usr/src/openssl-0.9.8s-fips tstunnel_exe_SOURCES = $(common_headers) $(common_sources) nogui.c
WINCPPFLAGS = -I$(OPENSSLDIR)/inc32
# OPENSSLDIR = /usr/src/openssl-1.0.0f-i586 # OPENSSLDIR = /usr/src/openssl-0.9.8u-fips
# WINCPPFLAGS = -I$(OPENSSLDIR)/include # WINCPPFLAGS = -I$(OPENSSLDIR)/inc32
OPENSSLDIR = /usr/src/openssl-1.0.1e-i586
WINCPPFLAGS = -I$(OPENSSLDIR)/include
WINCFLAGS = -mthreads -fstack-protector -O2 -Wall -Wextra -Wno-long-long -pedantic WINCFLAGS = -mthreads -fstack-protector -O2 -Wall -Wextra -Wno-long-long -pedantic
WINLDFLAGS = -mthreads -fstack-protector -mwindows -s WINLDFLAGS = -mthreads -fstack-protector -s
WINLIBS = -L$(OPENSSLDIR) -lcrypto -lssl -lpsapi -lws2_32 -lgdi32 WINLIBS = -L$(OPENSSLDIR) -lcrypto -lssl -lpsapi -lws2_32 -lgdi32
# WINLIBS = -L$(OPENSSLDIR) -lzdll -lcrypto.dll -lssl.dll -lpsapi -lws2_32 -lgdi32 # WINLIBS = -L$(OPENSSLDIR) -lzdll -lcrypto.dll -lssl.dll -lpsapi -lws2_32 -lgdi32
# WINLIBS = -L$(OPENSSLDIR) -lzdll -lcrypto -lssl -lpsapi -lws2_32 -lgdi32 # WINLIBS = -L$(OPENSSLDIR) -lzdll -lcrypto -lssl -lpsapi -lws2_32 -lgdi32
WINOBJ = str.obj file.obj client.obj log.obj options.obj protocol.obj \ WINOBJ = str.obj file.obj client.obj log.obj options.obj protocol.obj \
network.obj resolver.obj ssl.obj ctx.obj verify.obj \ network.obj resolver.obj ssl.obj ctx.obj verify.obj \
sthreads.obj fd.obj stunnel.obj gui.obj resources.obj sthreads.obj fd.obj stunnel.obj
WINPREFIX = i586-mingw32msvc- WINGUIOBJ = $(WINOBJ) gui.obj resources.obj
WINNOGUIOBJ = $(WINOBJ) nogui.obj
WINPREFIX = i686-w64-mingw32-
WINGCC = $(WINPREFIX)gcc WINGCC = $(WINPREFIX)gcc
WINDRES = $(WINPREFIX)windres WINDRES = $(WINPREFIX)windres
all: config.h all: config.h
@ -476,6 +484,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gui.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gui.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/network.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/network.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nogui.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/options.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/options.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/resolver.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/resolver.Po@am__quote@
@ -962,15 +971,18 @@ uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS \
uninstall-pkglibLTLIBRARIES uninstall-pkglibLTLIBRARIES
dist-hook: stunnel.exe dist-hook: stunnel.exe tstunnel.exe
distclean-local: distclean-local:
rm -f stunnel.exe rm -f stunnel.exe tstunnel.exe
# SUFFIXES = .c .rc .obj # SUFFIXES = .c .rc .obj
stunnel.exe: $(WINOBJ) stunnel.exe: $(WINGUIOBJ)
$(WINGCC) $(WINLDFLAGS) -o stunnel.exe $(WINOBJ) $(WINLIBS) $(WINGCC) -mwindows $(WINLDFLAGS) -o stunnel.exe $(WINGUIOBJ) $(WINLIBS)
tstunnel.exe: $(WINNOGUIOBJ)
$(WINGCC) $(WINLDFLAGS) -o tstunnel.exe $(WINNOGUIOBJ) $(WINLIBS)
%.obj: %.c $(common_headers) %.obj: %.c $(common_headers)
$(WINGCC) -c $(WINCPPFLAGS) $(WINCFLAGS) -o $@ $< $(WINGCC) -c $(WINCPPFLAGS) $(WINCFLAGS) -o $@ $<

View File

@ -1,24 +1,24 @@
/* /*
* stunnel Universal SSL tunnel * stunnel Universal SSL tunnel
* Copyright (C) 1998-2012 Michal Trojnara <Michal.Trojnara@mirt.net> * Copyright (C) 1998-2013 Michal Trojnara <Michal.Trojnara@mirt.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your * Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with this program; if not, see <http://www.gnu.org/licenses>. * with this program; if not, see <http://www.gnu.org/licenses>.
* *
* Linking stunnel statically or dynamically with other modules is making * Linking stunnel statically or dynamically with other modules is making
* a combined work based on stunnel. Thus, the terms and conditions of * a combined work based on stunnel. Thus, the terms and conditions of
* the GNU General Public License cover the whole combination. * the GNU General Public License cover the whole combination.
* *
* In addition, as a special exception, the copyright holder of stunnel * In addition, as a special exception, the copyright holder of stunnel
* gives you permission to combine stunnel with free software programs or * gives you permission to combine stunnel with free software programs or
* libraries that are released under the GNU LGPL and with code included * libraries that are released under the GNU LGPL and with code included
@ -26,7 +26,7 @@
* modified versions of such code, with unchanged license). You may copy * modified versions of such code, with unchanged license). You may copy
* and distribute such a system following the terms of the GNU GPL for * and distribute such a system following the terms of the GNU GPL for
* stunnel and the licenses of the other code concerned. * stunnel and the licenses of the other code concerned.
* *
* Note that people who make modified versions of stunnel are not obligated * Note that people who make modified versions of stunnel are not obligated
* to grant this special exception for their modified versions; it is their * to grant this special exception for their modified versions; it is their
* choice whether to do so. The GNU General Public License gives permission * choice whether to do so. The GNU General Public License gives permission
@ -54,7 +54,7 @@ static void init_local(CLI *);
static void init_remote(CLI *); static void init_remote(CLI *);
static void init_ssl(CLI *); static void init_ssl(CLI *);
#ifdef USE_WIN32 #ifdef USE_WIN32
static void win_new_chain(CLI *); static void new_chain(CLI *);
#endif #endif
static void transfer(CLI *); static void transfer(CLI *);
static int parse_socket_error(CLI *, const char *); static int parse_socket_error(CLI *, const char *);
@ -129,7 +129,7 @@ void client_main(CLI *c) {
} }
static void client_run(CLI *c) { static void client_run(CLI *c) {
int error; int err, rst;
#ifndef USE_FORK #ifndef USE_FORK
enter_critical_section(CRIT_CLIENTS); /* for multi-cpu machines */ enter_critical_section(CRIT_CLIENTS); /* for multi-cpu machines */
@ -145,13 +145,13 @@ static void client_run(CLI *c) {
c->connect_addr.num=0; c->connect_addr.num=0;
c->connect_addr.addr=NULL; c->connect_addr.addr=NULL;
error=setjmp(c->err); err=setjmp(c->err);
if(!error) if(!err)
client_try(c); client_try(c);
rst=err==1 && c->opt->option.reset;
s_log(LOG_NOTICE, s_log(LOG_NOTICE,
"Connection %s: %d byte(s) sent to SSL, %d byte(s) sent to socket", "Connection %s: %d byte(s) sent to SSL, %d byte(s) sent to socket",
error==1 ? "reset" : "closed", c->ssl_bytes, c->sock_bytes); rst ? "reset" : "closed", c->ssl_bytes, c->sock_bytes);
/* cleanup temporary (e.g. IDENT) socket */ /* cleanup temporary (e.g. IDENT) socket */
if(c->fd>=0) if(c->fd>=0)
@ -168,7 +168,7 @@ static void client_run(CLI *c) {
/* cleanup remote socket */ /* cleanup remote socket */
if(c->remote_fd.fd>=0) { /* remote socket initialized */ if(c->remote_fd.fd>=0) { /* remote socket initialized */
if(error==1 && c->remote_fd.is_socket) /* reset */ if(rst && c->remote_fd.is_socket) /* reset */
reset(c->remote_fd.fd, "linger (remote)"); reset(c->remote_fd.fd, "linger (remote)");
closesocket(c->remote_fd.fd); closesocket(c->remote_fd.fd);
s_log(LOG_DEBUG, "Remote socket (FD=%d) closed", c->remote_fd.fd); s_log(LOG_DEBUG, "Remote socket (FD=%d) closed", c->remote_fd.fd);
@ -178,14 +178,14 @@ static void client_run(CLI *c) {
/* cleanup local socket */ /* cleanup local socket */
if(c->local_rfd.fd>=0) { /* local socket initialized */ if(c->local_rfd.fd>=0) { /* local socket initialized */
if(c->local_rfd.fd==c->local_wfd.fd) { if(c->local_rfd.fd==c->local_wfd.fd) {
if(error==1 && c->local_rfd.is_socket) if(rst && c->local_rfd.is_socket)
reset(c->local_rfd.fd, "linger (local)"); reset(c->local_rfd.fd, "linger (local)");
closesocket(c->local_rfd.fd); closesocket(c->local_rfd.fd);
s_log(LOG_DEBUG, "Local socket (FD=%d) closed", c->local_rfd.fd); s_log(LOG_DEBUG, "Local socket (FD=%d) closed", c->local_rfd.fd);
} else { /* stdin/stdout */ } else { /* stdin/stdout */
if(error==1 && c->local_rfd.is_socket) if(rst && c->local_rfd.is_socket)
reset(c->local_rfd.fd, "linger (local_rfd)"); reset(c->local_rfd.fd, "linger (local_rfd)");
if(error==1 && c->local_wfd.is_socket) if(rst && c->local_wfd.is_socket)
reset(c->local_wfd.fd, "linger (local_wfd)"); reset(c->local_wfd.fd, "linger (local_wfd)");
} }
c->local_rfd.fd=c->local_wfd.fd=-1; c->local_rfd.fd=c->local_wfd.fd=-1;
@ -217,7 +217,7 @@ static void client_try(CLI *c) {
/* server mode and no protocol negotiation needed */ /* server mode and no protocol negotiation needed */
init_ssl(c); init_ssl(c);
init_remote(c); init_remote(c);
} else { } else { /* client mode or protocol negotiation enabled */
protocol(c, PROTOCOL_PRE_CONNECT); protocol(c, PROTOCOL_PRE_CONNECT);
init_remote(c); init_remote(c);
protocol(c, PROTOCOL_PRE_SSL); protocol(c, PROTOCOL_PRE_SSL);
@ -269,7 +269,7 @@ static void init_local(CLI *c) {
} }
/* neither of local descriptors is a socket */ /* neither of local descriptors is a socket */
if(!c->local_rfd.is_socket && !c->local_rfd.is_socket) { if(!c->local_rfd.is_socket && !c->local_wfd.is_socket) {
#ifndef USE_WIN32 #ifndef USE_WIN32
if(c->opt->option.transparent_src) { if(c->opt->option.transparent_src) {
s_log(LOG_ERR, "Transparent source needs a socket"); s_log(LOG_ERR, "Transparent source needs a socket");
@ -303,7 +303,12 @@ static void init_remote(CLI *c) {
c->bind_addr=NULL; /* don't bind */ c->bind_addr=NULL; /* don't bind */
/* setup c->remote_fd, now */ /* setup c->remote_fd, now */
if(c->opt->option.remote) { /* try remote first for exec+connect targets */ if(c->opt->option.remote
#ifndef USE_WIN32
|| c->opt->option.transparent_dst
#endif
) {
/* try remote first for exec+connect targets */
c->remote_fd.fd=connect_remote(c); c->remote_fd.fd=connect_remote(c);
} else if(c->opt->option.program) { /* exec+connect uses local fd */ } else if(c->opt->option.program) { /* exec+connect uses local fd */
c->remote_fd.fd=connect_local(c); c->remote_fd.fd=connect_local(c);
@ -332,7 +337,7 @@ static void init_ssl(CLI *c) {
if(c->opt->option.client) { if(c->opt->option.client) {
#ifndef OPENSSL_NO_TLSEXT #ifndef OPENSSL_NO_TLSEXT
if(c->opt->sni) { if(c->opt->sni) {
s_log(LOG_DEBUG, "SNI: host name: %s", c->opt->sni); s_log(LOG_DEBUG, "SNI: sending servername: %s", c->opt->sni);
if(!SSL_set_tlsext_host_name(c->ssl, c->opt->sni)) { if(!SSL_set_tlsext_host_name(c->ssl, c->opt->sni)) {
sslerror("SSL_set_tlsext_host_name"); sslerror("SSL_set_tlsext_host_name");
longjmp(c->err, 1); longjmp(c->err, 1);
@ -432,7 +437,7 @@ static void init_ssl(CLI *c) {
c->opt->option.client ? "connected" : "accepted"); c->opt->option.client ? "connected" : "accepted");
} else { /* a new session was negotiated */ } else { /* a new session was negotiated */
#ifdef USE_WIN32 #ifdef USE_WIN32
win_new_chain(c); new_chain(c);
#endif #endif
if(c->opt->option.client) { if(c->opt->option.client) {
s_log(LOG_INFO, "SSL connected: new session negotiated"); s_log(LOG_INFO, "SSL connected: new session negotiated");
@ -449,7 +454,7 @@ static void init_ssl(CLI *c) {
} }
#ifdef USE_WIN32 #ifdef USE_WIN32
static void win_new_chain(CLI *c) { static void new_chain(CLI *c) {
BIO *bio; BIO *bio;
int i, len; int i, len;
X509 *peer=NULL; X509 *peer=NULL;
@ -491,7 +496,7 @@ static void win_new_chain(CLI *c) {
BIO_free(bio); BIO_free(bio);
str_detach(chain); /* to prevent automatic deallocation of cached value */ str_detach(chain); /* to prevent automatic deallocation of cached value */
c->opt->chain=chain; /* this race condition is safe to ignore */ c->opt->chain=chain; /* this race condition is safe to ignore */
PostMessage(hwnd, WM_NEW_CHAIN, c->opt->section_number, 0); win_new_chain(c->opt->section_number);
s_log(LOG_DEBUG, "Peer certificate was cached (%d bytes)", len); s_log(LOG_DEBUG, "Peer certificate was cached (%d bytes)", len);
} }
#endif #endif
@ -522,15 +527,18 @@ static void transfer(CLI *c) {
s_poll_init(c->fds); /* initialize the structure */ s_poll_init(c->fds); /* initialize the structure */
/* for plain socket open data strem = open file descriptor */ /* for plain socket open data strem = open file descriptor */
/* make sure to add each open socket to receive exceptions! */ /* make sure to add each open socket to receive exceptions! */
if(sock_open_rd) if(sock_open_rd) /* only poll if the read file descriptor is open */
s_poll_add(c->fds, c->sock_rfd->fd, c->sock_ptr<BUFFSIZE, 0); s_poll_add(c->fds, c->sock_rfd->fd, c->sock_ptr<BUFFSIZE, 0);
if(sock_open_wr) if(sock_open_wr) /* only poll if the write file descriptor is open */
s_poll_add(c->fds, c->sock_wfd->fd, 0, c->ssl_ptr); s_poll_add(c->fds, c->sock_wfd->fd, 0, c->ssl_ptr);
/* for SSL assume that sockets are open if there any pending requests */ /* poll SSL file descriptors unless SSL shutdown was completed */
if(read_wants_read || write_wants_read || shutdown_wants_read) if(SSL_get_shutdown(c->ssl)!=
s_poll_add(c->fds, c->ssl_rfd->fd, 1, 0); (SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN)) {
if(read_wants_write || write_wants_write || shutdown_wants_write) s_poll_add(c->fds, c->ssl_rfd->fd,
s_poll_add(c->fds, c->ssl_wfd->fd, 0, 1); read_wants_read || write_wants_read || shutdown_wants_read, 0);
s_poll_add(c->fds, c->ssl_wfd->fd, 0,
read_wants_write || write_wants_write || shutdown_wants_write);
}
/****************************** wait for an event */ /****************************** wait for an event */
err=s_poll_wait(c->fds, err=s_poll_wait(c->fds,
@ -558,39 +566,64 @@ static void transfer(CLI *c) {
} }
/****************************** check for errors on sockets */ /****************************** check for errors on sockets */
err=s_poll_error(c->fds, c->sock_rfd); err=s_poll_error(c->fds, c->sock_rfd->fd);
if(err) { if(err && err!=S_EWOULDBLOCK && err!=S_EAGAIN) {
s_log(LOG_NOTICE, s_log(LOG_NOTICE, "Read socket error: %s (%d)",
"Error detected on socket (read) file descriptor: %s (%d)",
s_strerror(err), err); s_strerror(err), err);
longjmp(c->err, 1); longjmp(c->err, 1);
} }
if(c->sock_wfd->fd != c->sock_rfd->fd) { /* performance optimization */ if(c->sock_wfd->fd!=c->sock_rfd->fd) { /* performance optimization */
err=s_poll_error(c->fds, c->sock_wfd); err=s_poll_error(c->fds, c->sock_wfd->fd);
if(err) { if(err && err!=S_EWOULDBLOCK && err!=S_EAGAIN) {
s_log(LOG_NOTICE, s_log(LOG_NOTICE, "Write socket error: %s (%d)",
"Error detected on socket write file descriptor: %s (%d)",
s_strerror(err), err); s_strerror(err), err);
longjmp(c->err, 1); longjmp(c->err, 1);
} }
} }
err=s_poll_error(c->fds, c->ssl_rfd); err=s_poll_error(c->fds, c->ssl_rfd->fd);
if(err) { if(err && err!=S_EWOULDBLOCK && err!=S_EAGAIN) {
s_log(LOG_NOTICE, s_log(LOG_NOTICE, "SSL socket error: %s (%d)",
"Error detected on SSL (read) file descriptor: %s (%d)",
s_strerror(err), err); s_strerror(err), err);
longjmp(c->err, 1); longjmp(c->err, 1);
} }
if(c->ssl_wfd->fd != c->ssl_rfd->fd) { /* performance optimization */ if(c->ssl_wfd->fd!=c->ssl_rfd->fd) { /* performance optimization */
err=s_poll_error(c->fds, c->ssl_wfd); err=s_poll_error(c->fds, c->ssl_wfd->fd);
if(err) { if(err && err!=S_EWOULDBLOCK && err!=S_EAGAIN) {
s_log(LOG_NOTICE, s_log(LOG_NOTICE, "SSL socket error: %s (%d)",
"Error detected on SSL write file descriptor: %s (%d)",
s_strerror(err), err); s_strerror(err), err);
longjmp(c->err, 1); longjmp(c->err, 1);
} }
} }
/****************************** check for hangup conditions */
if(s_poll_hup(c->fds, c->sock_rfd->fd)) {
s_log(LOG_INFO, "Read socket closed (hangup)");
sock_open_rd=0;
}
if(s_poll_hup(c->fds, c->sock_wfd->fd)) {
if(c->ssl_ptr) {
s_log(LOG_ERR,
"Write socket closed (hangup) with %d unsent byte(s)",
c->ssl_ptr);
longjmp(c->err, 1); /* reset the socket */
}
s_log(LOG_INFO, "Write socket closed (hangup)");
sock_open_wr=0;
}
if(s_poll_hup(c->fds, c->ssl_rfd->fd) ||
s_poll_hup(c->fds, c->ssl_wfd->fd)) {
/* hangup -> buggy (e.g. Microsoft) peer:
* SSL socket closed without close_notify alert */
if(c->sock_ptr) {
s_log(LOG_ERR,
"SSL socket closed (hangup) with %d unsent byte(s)",
c->sock_ptr);
longjmp(c->err, 1); /* reset the socket */
}
s_log(LOG_INFO, "SSL socket closed (hangup)");
SSL_set_shutdown(c->ssl, SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
}
/****************************** retrieve results from c->fds */ /****************************** retrieve results from c->fds */
sock_can_rd=s_poll_canread(c->fds, c->sock_rfd->fd); sock_can_rd=s_poll_canread(c->fds, c->sock_rfd->fd);
sock_can_wr=s_poll_canwrite(c->fds, c->sock_wfd->fd); sock_can_wr=s_poll_canwrite(c->fds, c->sock_wfd->fd);
@ -605,6 +638,11 @@ static void transfer(CLI *c) {
longjmp(c->err, 1); longjmp(c->err, 1);
} }
if(c->reneg_state==RENEG_DETECTED && !c->opt->option.renegotiation) {
s_log(LOG_ERR, "Aborting due to renegotiation request");
longjmp(c->err, 1);
}
/****************************** send SSL close_notify alert */ /****************************** send SSL close_notify alert */
if(shutdown_wants_read || shutdown_wants_write) { if(shutdown_wants_read || shutdown_wants_write) {
num=SSL_shutdown(c->ssl); /* send close_notify alert */ num=SSL_shutdown(c->ssl); /* send close_notify alert */
@ -650,8 +688,10 @@ static void transfer(CLI *c) {
case -1: case -1:
if(parse_socket_error(c, "readsocket")) if(parse_socket_error(c, "readsocket"))
break; /* a non-critical error: retry */ break; /* a non-critical error: retry */
sock_open_rd=sock_open_wr=0;
break;
case 0: /* close */ case 0: /* close */
s_log(LOG_DEBUG, "Socket closed on read"); s_log(LOG_INFO, "Read socket closed (readsocket)");
sock_open_rd=0; sock_open_rd=0;
break; break;
default: default:
@ -667,8 +707,6 @@ static void transfer(CLI *c) {
case -1: /* error */ case -1: /* error */
if(parse_socket_error(c, "writesocket")) if(parse_socket_error(c, "writesocket"))
break; /* a non-critical error: retry */ break; /* a non-critical error: retry */
case 0:
s_log(LOG_DEBUG, "Socket closed on write");
sock_open_rd=sock_open_wr=0; sock_open_rd=sock_open_wr=0;
break; break;
default: default:
@ -717,15 +755,15 @@ static void transfer(CLI *c) {
* SSL socket closed without close_notify alert */ * SSL socket closed without close_notify alert */
if(c->sock_ptr) { if(c->sock_ptr) {
s_log(LOG_ERR, s_log(LOG_ERR,
"SSL socket closed on SSL_read with %d unsent byte(s)", "SSL socket closed (SSL_read) with %d unsent byte(s)",
c->sock_ptr); c->sock_ptr);
longjmp(c->err, 1); /* reset the socket */ longjmp(c->err, 1); /* reset the socket */
} }
s_log(LOG_DEBUG, "SSL socket closed on SSL_read"); s_log(LOG_INFO, "SSL socket closed (SSL_read)");
SSL_set_shutdown(c->ssl, SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN); SSL_set_shutdown(c->ssl, SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
break; break;
case SSL_ERROR_ZERO_RETURN: /* close_notify alert received */ case SSL_ERROR_ZERO_RETURN: /* close_notify alert received */
s_log(LOG_DEBUG, "SSL closed on SSL_read"); s_log(LOG_INFO, "SSL closed (SSL_read)");
if(SSL_version(c->ssl)==SSL2_VERSION) if(SSL_version(c->ssl)==SSL2_VERSION)
SSL_set_shutdown(c->ssl, SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN); SSL_set_shutdown(c->ssl, SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
break; break;
@ -769,15 +807,15 @@ static void transfer(CLI *c) {
* SSL socket closed without close_notify alert */ * SSL socket closed without close_notify alert */
if(c->sock_ptr) { if(c->sock_ptr) {
s_log(LOG_ERR, s_log(LOG_ERR,
"SSL socket closed on SSL_write with %d unsent byte(s)", "SSL socket closed (SSL_write) with %d unsent byte(s)",
c->sock_ptr); c->sock_ptr);
longjmp(c->err, 1); /* reset the socket */ longjmp(c->err, 1); /* reset the socket */
} }
s_log(LOG_DEBUG, "SSL socket closed on SSL_write"); s_log(LOG_INFO, "SSL socket closed (SSL_write)");
SSL_set_shutdown(c->ssl, SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN); SSL_set_shutdown(c->ssl, SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
break; break;
case SSL_ERROR_ZERO_RETURN: /* close_notify alert received */ case SSL_ERROR_ZERO_RETURN: /* close_notify alert received */
s_log(LOG_DEBUG, "SSL closed on SSL_write"); s_log(LOG_INFO, "SSL closed (SSL_write)");
if(SSL_version(c->ssl)==SSL2_VERSION) if(SSL_version(c->ssl)==SSL2_VERSION)
SSL_set_shutdown(c->ssl, SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN); SSL_set_shutdown(c->ssl, SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
break; break;
@ -794,7 +832,7 @@ static void transfer(CLI *c) {
if(sock_open_wr && SSL_get_shutdown(c->ssl)&SSL_RECEIVED_SHUTDOWN && !c->ssl_ptr) { if(sock_open_wr && SSL_get_shutdown(c->ssl)&SSL_RECEIVED_SHUTDOWN && !c->ssl_ptr) {
sock_open_wr=0; /* no further write allowed */ sock_open_wr=0; /* no further write allowed */
if(!c->sock_wfd->is_socket) { if(!c->sock_wfd->is_socket) {
s_log(LOG_DEBUG, "Closing the socket file descriptor"); s_log(LOG_DEBUG, "Closing the file descriptor");
sock_open_rd=0; /* file descriptor is ready to be closed */ sock_open_rd=0; /* file descriptor is ready to be closed */
} else if(!shutdown(c->sock_wfd->fd, SHUT_WR)) { /* send TCP FIN */ } else if(!shutdown(c->sock_wfd->fd, SHUT_WR)) { /* send TCP FIN */
s_log(LOG_DEBUG, "Sent socket write shutdown"); s_log(LOG_DEBUG, "Sent socket write shutdown");
@ -1084,8 +1122,15 @@ static int connect_local(CLI *c) { /* spawn local process */
sigemptyset(&newmask); sigemptyset(&newmask);
sigprocmask(SIG_SETMASK, &newmask, NULL); sigprocmask(SIG_SETMASK, &newmask, NULL);
#endif #endif
signal(SIGCHLD, SIG_DFL);
signal(SIGHUP, SIG_DFL);
signal(SIGUSR1, SIG_DFL);
signal(SIGPIPE, SIG_DFL);
signal(SIGTERM, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
signal(SIGINT, SIG_DFL);
execvp(c->opt->execname, c->opt->execargs); execvp(c->opt->execname, c->opt->execargs);
ioerror(c->opt->execname); /* execv failed */ ioerror(c->opt->execname); /* execvp failed */
_exit(1); _exit(1);
default: /* parent */ default: /* parent */
s_log(LOG_INFO, "Local mode child started (PID=%lu)", c->pid); s_log(LOG_INFO, "Local mode child started (PID=%lu)", c->pid);
@ -1159,8 +1204,8 @@ static SOCKADDR_LIST *dynamic_remote_addr(CLI *c) {
#endif /* SO_ORIGINAL_DST */ #endif /* SO_ORIGINAL_DST */
if(c->opt->option.delayed_lookup) { if(c->opt->option.delayed_lookup) {
if(!name2addrlist(&c->connect_addr, if(!namelist2addrlist(&c->connect_addr,
c->opt->connect_name, DEFAULT_LOOPBACK)) { c->opt->connect_list, DEFAULT_LOOPBACK)) {
s_log(LOG_ERR, "No host resolved"); s_log(LOG_ERR, "No host resolved");
longjmp(c->err, 1); longjmp(c->err, 1);
} }

View File

@ -1,6 +1,6 @@
/* /*
* stunnel Universal SSL tunnel * stunnel Universal SSL tunnel
* Copyright (C) 1998-2012 Michal Trojnara <Michal.Trojnara@mirt.net> * Copyright (C) 1998-2013 Michal Trojnara <Michal.Trojnara@mirt.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
@ -431,10 +431,10 @@ extern char *sys_errlist[];
#include <openssl/ocsp.h> #include <openssl/ocsp.h>
#endif /* HAVE_OSSL_OCSP_H */ #endif /* HAVE_OSSL_OCSP_H */
#ifdef USE_FIPS #ifdef HAVE_OSSL_FIPS_H
#include <openssl/fips.h> #include <openssl/fips.h>
#include <openssl/fips_rand.h> #include <openssl/fips_rand.h>
#endif /* USE_FIPS */ #endif /* HAVE_OSSL_FIPS_H */
#if OPENSSL_VERSION_NUMBER<0x0090800fL #if OPENSSL_VERSION_NUMBER<0x0090800fL
#define OPENSSL_NO_ECDH #define OPENSSL_NO_ECDH

View File

@ -27,6 +27,9 @@
/* Define to 1 if you have the `endhostent' function. */ /* Define to 1 if you have the `endhostent' function. */
#undef HAVE_ENDHOSTENT #undef HAVE_ENDHOSTENT
/* Define to 1 if you have the `FIPS_mode_set' function. */
#undef HAVE_FIPS_MODE_SET
/* Define to 1 if you have 'getaddrinfo' function. */ /* Define to 1 if you have 'getaddrinfo' function. */
#undef HAVE_GETADDRINFO #undef HAVE_GETADDRINFO
@ -78,6 +81,9 @@
/* Define to 1 if you have <engine.h> header file. */ /* Define to 1 if you have <engine.h> header file. */
#undef HAVE_OSSL_ENGINE_H #undef HAVE_OSSL_ENGINE_H
/* Define to 1 if you have <fips.h> header file. */
#undef HAVE_OSSL_FIPS_H
/* Define to 1 if you have <ocsp.h> header file. */ /* Define to 1 if you have <ocsp.h> header file. */
#undef HAVE_OSSL_OCSP_H #undef HAVE_OSSL_OCSP_H

View File

@ -1,6 +1,6 @@
/* /*
* stunnel Universal SSL tunnel * stunnel Universal SSL tunnel
* Copyright (C) 1998-2012 Michal Trojnara <Michal.Trojnara@mirt.net> * Copyright (C) 1998-2013 Michal Trojnara <Michal.Trojnara@mirt.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
@ -43,6 +43,7 @@
/* SNI */ /* SNI */
#ifndef OPENSSL_NO_TLSEXT #ifndef OPENSSL_NO_TLSEXT
static int servername_cb(SSL *, int *, void *); static int servername_cb(SSL *, int *, void *);
static int matches_wildcard(char *, char *);
#endif #endif
/* DH/ECDH initialization */ /* DH/ECDH initialization */
@ -126,6 +127,7 @@ int context_init(SERVICE_OPTIONS *section) { /* init SSL context */
} }
} }
SSL_CTX_set_session_cache_mode(section->ctx, SSL_SESS_CACHE_BOTH); SSL_CTX_set_session_cache_mode(section->ctx, SSL_SESS_CACHE_BOTH);
SSL_CTX_sess_set_cache_size(section->ctx, section->session_size);
SSL_CTX_set_timeout(section->ctx, section->session_timeout); SSL_CTX_set_timeout(section->ctx, section->session_timeout);
if(section->option.sessiond) { if(section->option.sessiond) {
SSL_CTX_sess_set_new_cb(section->ctx, sess_new_cb); SSL_CTX_sess_set_new_cb(section->ctx, sess_new_cb);
@ -134,8 +136,7 @@ int context_init(SERVICE_OPTIONS *section) { /* init SSL context */
} }
/* set info callback */ /* set info callback */
if(global_options.debug_level==LOG_DEBUG) /* performance optimization */ SSL_CTX_set_info_callback(section->ctx, info_callback);
SSL_CTX_set_info_callback(section->ctx, info_callback);
/* ciphers, options, mode */ /* ciphers, options, mode */
if(section->cipher_list) if(section->cipher_list)
@ -173,20 +174,25 @@ static int servername_cb(SSL *ssl, int *ad, void *arg) {
/* leave the alert type at SSL_AD_UNRECOGNIZED_NAME */ /* leave the alert type at SSL_AD_UNRECOGNIZED_NAME */
(void)ad; /* skip warning about unused parameter */ (void)ad; /* skip warning about unused parameter */
if(!section->servername_list_head) /* no virtual services defined */ if(!section->servername_list_head) { /* no virtual services defined */
s_log(LOG_DEBUG, "SNI: no virtual services defined");
return SSL_TLSEXT_ERR_OK; return SSL_TLSEXT_ERR_OK;
if(!servername) /* no SNI extension received from the client */ }
if(!servername) { /* no SNI extension received from the client */
s_log(LOG_NOTICE, "SNI: extension not received from the client");
return SSL_TLSEXT_ERR_NOACK; return SSL_TLSEXT_ERR_NOACK;
}
s_log(LOG_DEBUG, "SNI: searching service for servername: %s", servername);
for(list=section->servername_list_head; list; list=list->next) for(list=section->servername_list_head; list; list=list->next)
if(!strcasecmp(servername, list->servername)) { if(matches_wildcard((char *)servername, list->servername)) {
s_log(LOG_DEBUG, "SNI: matched pattern: %s", list->servername);
c=SSL_get_ex_data(ssl, cli_index); c=SSL_get_ex_data(ssl, cli_index);
c->opt=list->opt; c->opt=list->opt;
SSL_set_SSL_CTX(ssl, c->opt->ctx); SSL_set_SSL_CTX(ssl, c->opt->ctx);
SSL_set_verify(ssl, SSL_CTX_get_verify_mode(c->opt->ctx), SSL_set_verify(ssl, SSL_CTX_get_verify_mode(c->opt->ctx),
SSL_CTX_get_verify_callback(c->opt->ctx)); SSL_CTX_get_verify_callback(c->opt->ctx));
s_log(LOG_NOTICE, "SNI: switched to section %s", s_log(LOG_INFO, "SNI: switched to service [%s]", c->opt->servname);
c->opt->servname);
#ifdef USE_LIBWRAP #ifdef USE_LIBWRAP
accepted_address=s_ntop(&c->peer_addr, c->peer_addr_len); accepted_address=s_ntop(&c->peer_addr, c->peer_addr_len);
libwrap_auth(c, accepted_address); /* retry on a service switch */ libwrap_auth(c, accepted_address); /* retry on a service switch */
@ -194,7 +200,7 @@ static int servername_cb(SSL *ssl, int *ad, void *arg) {
#endif /* USE_LIBWRAP */ #endif /* USE_LIBWRAP */
return SSL_TLSEXT_ERR_OK; return SSL_TLSEXT_ERR_OK;
} }
s_log(LOG_ERR, "SNI: no service defined for server %s", servername); s_log(LOG_ERR, "SNI: no pattern matched servername: %s", servername);
return SSL_TLSEXT_ERR_ALERT_FATAL; return SSL_TLSEXT_ERR_ALERT_FATAL;
} }
/* TLSEXT callback return codes: /* TLSEXT callback return codes:
@ -203,6 +209,20 @@ static int servername_cb(SSL *ssl, int *ad, void *arg) {
* - SSL_TLSEXT_ERR_ALERT_FATAL * - SSL_TLSEXT_ERR_ALERT_FATAL
* - SSL_TLSEXT_ERR_NOACK */ * - SSL_TLSEXT_ERR_NOACK */
static int matches_wildcard(char *servername, char *pattern) {
int diff;
if(!servername || !pattern)
return 0;
if(*pattern=='*') { /* wildcard comparison */
diff=strlen(servername)-strlen(++pattern);
if(diff<0) /* pattern longer than servername */
return 0;
servername+=diff;
}
return !strcasecmp(servername, pattern);
}
#endif /* OPENSSL_NO_TLSEXT */ #endif /* OPENSSL_NO_TLSEXT */
/**************************************** DH initialization */ /**************************************** DH initialization */
@ -300,7 +320,8 @@ static int init_ecdh(SERVICE_OPTIONS *section) {
ecdh=EC_KEY_new_by_curve_name(section->curve); ecdh=EC_KEY_new_by_curve_name(section->curve);
if(!ecdh) { if(!ecdh) {
s_log(LOG_ERR, "Unable to create curve %s", sslerror("EC_KEY_new_by_curve_name");
s_log(LOG_ERR, "Cannot create curve %s",
OBJ_nid2ln(section->curve)); OBJ_nid2ln(section->curve));
return 1; /* FAILED */ return 1; /* FAILED */
} }
@ -615,6 +636,31 @@ static void info_callback(
const const
#endif #endif
SSL *ssl, int where, int ret) { SSL *ssl, int where, int ret) {
CLI *c;
c=SSL_get_ex_data(ssl, cli_index);
if(c) {
if((where&SSL_CB_HANDSHAKE_DONE)
&& c->reneg_state==RENEG_INIT) {
/* first (initial) handshake was completed, remember this,
* so that further renegotiation attempts can be detected */
c->reneg_state=RENEG_ESTABLISHED;
} else if((where&SSL_CB_ACCEPT_LOOP)
&& c->reneg_state==RENEG_ESTABLISHED) {
int state=SSL_get_state(ssl);
if(state==SSL3_ST_SR_CLNT_HELLO_A
|| state==SSL23_ST_SR_CLNT_HELLO_A) {
/* client hello received after initial handshake,
* this means renegotiation -> mark it */
c->reneg_state=RENEG_DETECTED;
}
}
}
if(global_options.debug_level<LOG_DEBUG)
return; /* performance optimization */
if(where & SSL_CB_LOOP) { if(where & SSL_CB_LOOP) {
s_log(LOG_DEBUG, "SSL state (%s): %s", s_log(LOG_DEBUG, "SSL state (%s): %s",
where & SSL_ST_CONNECT ? "connect" : where & SSL_ST_CONNECT ? "connect" :

View File

@ -1,24 +1,24 @@
/* /*
* stunnel Universal SSL tunnel * stunnel Universal SSL tunnel
* Copyright (C) 1998-2012 Michal Trojnara <Michal.Trojnara@mirt.net> * Copyright (C) 1998-2013 Michal Trojnara <Michal.Trojnara@mirt.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your * Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with this program; if not, see <http://www.gnu.org/licenses>. * with this program; if not, see <http://www.gnu.org/licenses>.
* *
* Linking stunnel statically or dynamically with other modules is making * Linking stunnel statically or dynamically with other modules is making
* a combined work based on stunnel. Thus, the terms and conditions of * a combined work based on stunnel. Thus, the terms and conditions of
* the GNU General Public License cover the whole combination. * the GNU General Public License cover the whole combination.
* *
* In addition, as a special exception, the copyright holder of stunnel * In addition, as a special exception, the copyright holder of stunnel
* gives you permission to combine stunnel with free software programs or * gives you permission to combine stunnel with free software programs or
* libraries that are released under the GNU LGPL and with code included * libraries that are released under the GNU LGPL and with code included
@ -26,7 +26,7 @@
* modified versions of such code, with unchanged license). You may copy * modified versions of such code, with unchanged license). You may copy
* and distribute such a system following the terms of the GNU GPL for * and distribute such a system following the terms of the GNU GPL for
* stunnel and the licenses of the other code concerned. * stunnel and the licenses of the other code concerned.
* *
* Note that people who make modified versions of stunnel are not obligated * Note that people who make modified versions of stunnel are not obligated
* to grant this special exception for their modified versions; it is their * to grant this special exception for their modified versions; it is their
* choice whether to do so. The GNU General Public License gives permission * choice whether to do so. The GNU General Public License gives permission

View File

@ -65,7 +65,7 @@ SDKDIR=$(SDKROOT)\$(OSVERSION)\$(PLATFORM)
INCLUDES=-I$(SSLDIR)\inc32 -I$(COMPATDIR)\include -I"$(SDKDIR)\include\$(TARGETCPU)" INCLUDES=-I$(SSLDIR)\inc32 -I$(COMPATDIR)\include -I"$(SDKDIR)\include\$(TARGETCPU)"
# for X86 and other it appears that /MC or /ML flags are absurd, # for X86 and other it appears that /MC or /ML flags are absurd,
# we always have to override runtime lib list to coredll and corelibc # we always have to override runtime lib list to coredll and corelibc
LIBS=/NODEFAULTLIB coredll.lib corelibc.lib winsock.lib wcecompatex.lib libeay32.lib ssleay32.lib LIBS=/NODEFAULTLIB winsock.lib wcecompatex.lib libeay32.lib ssleay32.lib coredll.lib corelibc.lib
DEFINES=/DHOST=\"$(TARGETCPU)-WCE-eVC-$(WCEVER)\" DEFINES=/DHOST=\"$(TARGETCPU)-WCE-eVC-$(WCEVER)\"
# /O1 /Oi more correct vs MS doc # /O1 /Oi more correct vs MS doc

View File

@ -1,6 +1,6 @@
/* /*
* stunnel Universal SSL tunnel * stunnel Universal SSL tunnel
* Copyright (C) 1998-2012 Michal Trojnara <Michal.Trojnara@mirt.net> * Copyright (C) 1998-2013 Michal Trojnara <Michal.Trojnara@mirt.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the

View File

@ -1,24 +1,24 @@
/* /*
* stunnel Universal SSL tunnel * stunnel Universal SSL tunnel
* Copyright (C) 1998-2012 Michal Trojnara <Michal.Trojnara@mirt.net> * Copyright (C) 1998-2013 Michal Trojnara <Michal.Trojnara@mirt.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your * Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with this program; if not, see <http://www.gnu.org/licenses>. * with this program; if not, see <http://www.gnu.org/licenses>.
* *
* Linking stunnel statically or dynamically with other modules is making * Linking stunnel statically or dynamically with other modules is making
* a combined work based on stunnel. Thus, the terms and conditions of * a combined work based on stunnel. Thus, the terms and conditions of
* the GNU General Public License cover the whole combination. * the GNU General Public License cover the whole combination.
* *
* In addition, as a special exception, the copyright holder of stunnel * In addition, as a special exception, the copyright holder of stunnel
* gives you permission to combine stunnel with free software programs or * gives you permission to combine stunnel with free software programs or
* libraries that are released under the GNU LGPL and with code included * libraries that are released under the GNU LGPL and with code included
@ -26,7 +26,7 @@
* modified versions of such code, with unchanged license). You may copy * modified versions of such code, with unchanged license). You may copy
* and distribute such a system following the terms of the GNU GPL for * and distribute such a system following the terms of the GNU GPL for
* stunnel and the licenses of the other code concerned. * stunnel and the licenses of the other code concerned.
* *
* Note that people who make modified versions of stunnel are not obligated * Note that people who make modified versions of stunnel are not obligated
* to grant this special exception for their modified versions; it is their * to grant this special exception for their modified versions; it is their
* choice whether to do so. The GNU General Public License gives permission * choice whether to do so. The GNU General Public License gives permission
@ -50,11 +50,9 @@ DISK_FILE *file_open(char *name, int wr) {
fh=CreateFile(tstr, wr ? GENERIC_WRITE : GENERIC_READ, fh=CreateFile(tstr, wr ? GENERIC_WRITE : GENERIC_READ,
FILE_SHARE_READ, NULL, wr ? OPEN_ALWAYS : OPEN_EXISTING, FILE_SHARE_READ, NULL, wr ? OPEN_ALWAYS : OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, (HANDLE)NULL); FILE_ATTRIBUTE_NORMAL, (HANDLE)NULL);
str_free(tstr); str_free(tstr); /* str_free() overwrites GetLastError() value */
if(fh==INVALID_HANDLE_VALUE) { if(fh==INVALID_HANDLE_VALUE)
ioerror(name);
return NULL; return NULL;
}
if(wr) /* append */ if(wr) /* append */
SetFilePointer(fh, 0, NULL, FILE_END); SetFilePointer(fh, 0, NULL, FILE_END);
@ -92,10 +90,8 @@ DISK_FILE *file_open(char *name, int wr) {
flags|=O_CLOEXEC; flags|=O_CLOEXEC;
#endif /* O_CLOEXEC */ #endif /* O_CLOEXEC */
fd=open(name, flags, 0640); fd=open(name, flags, 0640);
if(fd<0) { if(fd<0)
ioerror(name);
return NULL; return NULL;
}
/* setup df structure */ /* setup df structure */
df=str_alloc(sizeof df); df=str_alloc(sizeof df);

119
src/gui.c
View File

@ -1,24 +1,24 @@
/* /*
* stunnel Universal SSL tunnel * stunnel Universal SSL tunnel
* Copyright (C) 1998-2012 Michal Trojnara <Michal.Trojnara@mirt.net> * Copyright (C) 1998-2013 Michal Trojnara <Michal.Trojnara@mirt.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your * Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with this program; if not, see <http://www.gnu.org/licenses>. * with this program; if not, see <http://www.gnu.org/licenses>.
* *
* Linking stunnel statically or dynamically with other modules is making * Linking stunnel statically or dynamically with other modules is making
* a combined work based on stunnel. Thus, the terms and conditions of * a combined work based on stunnel. Thus, the terms and conditions of
* the GNU General Public License cover the whole combination. * the GNU General Public License cover the whole combination.
* *
* In addition, as a special exception, the copyright holder of stunnel * In addition, as a special exception, the copyright holder of stunnel
* gives you permission to combine stunnel with free software programs or * gives you permission to combine stunnel with free software programs or
* libraries that are released under the GNU LGPL and with code included * libraries that are released under the GNU LGPL and with code included
@ -26,7 +26,7 @@
* modified versions of such code, with unchanged license). You may copy * modified versions of such code, with unchanged license). You may copy
* and distribute such a system following the terms of the GNU GPL for * and distribute such a system following the terms of the GNU GPL for
* stunnel and the licenses of the other code concerned. * stunnel and the licenses of the other code concerned.
* *
* Note that people who make modified versions of stunnel are not obligated * Note that people who make modified versions of stunnel are not obligated
* to grant this special exception for their modified versions; it is their * to grant this special exception for their modified versions; it is their
* choice whether to do so. The GNU General Public License gives permission * choice whether to do so. The GNU General Public License gives permission
@ -79,7 +79,6 @@ static void invalid_config(void);
static void update_peer_menu(void); static void update_peer_menu(void);
static void update_tray_icon(void); static void update_tray_icon(void);
static void error_box(const LPSTR); static void error_box(const LPSTR);
static void message_box(const LPSTR, const UINT);
static void edit_config(HWND); static void edit_config(HWND);
static BOOL is_admin(void); static BOOL is_admin(void);
@ -109,13 +108,15 @@ static HMENU tray_menu_handle=NULL;
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
static HMENU main_menu_handle=NULL; static HMENU main_menu_handle=NULL;
#endif #endif
HWND hwnd=NULL; /* main window handle */ static HWND hwnd=NULL; /* main window handle */
#ifdef _WIN32_WCE #ifdef _WIN32_WCE
static HWND command_bar_handle; /* command bar handle */ static HWND command_bar_handle; /* command bar handle */
#endif #endif
static HANDLE small_icon; /* 16x16 icon */ static HANDLE small_icon; /* 16x16 icon */
static TCHAR *win32_name; /* win32_name is needed for any error_box(), message_box(),
static HANDLE daemon_handle=NULL; * and the initial main window title */
static TCHAR *win32_name=TEXT("stunnel ") TEXT(STUNNEL_VERSION)
TEXT(" on ") TEXT(STUNNEL_PLATFORM) TEXT(" (not configured)");
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
static SERVICE_STATUS serviceStatus; static SERVICE_STATUS serviceStatus;
@ -129,15 +130,9 @@ static LONG new_logs=0;
static UI_DATA *ui_data=NULL; static UI_DATA *ui_data=NULL;
#ifndef _WIN32_WCE
GETADDRINFO s_getaddrinfo;
FREEADDRINFO s_freeaddrinfo;
GETNAMEINFO s_getnameinfo;
#endif
static struct { static struct {
char *config_file; char *config_file;
unsigned int install:1, uninstall:1, start:1, stop:1, service:1, unsigned int service:1, install:1, uninstall:1, start:1, stop:1,
quiet:1, exit:1; quiet:1, exit:1;
} cmdline; } cmdline;
@ -167,18 +162,18 @@ int WINAPI WinMain(HINSTANCE this_instance, HINSTANCE prev_instance,
command_line=lpCmdLine; command_line=lpCmdLine;
#endif #endif
/* win32_name is needed for any error_box(), message_box(),
* and the initial main window title */
win32_name=TEXT("stunnel ") TEXT(STUNNEL_VERSION) TEXT(" on ")
TEXT(STUNNEL_PLATFORM) TEXT(" (not configured)");
parse_cmdline(command_line); /* setup global cmdline structure */ parse_cmdline(command_line); /* setup global cmdline structure */
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
GetModuleFileName(0, stunnel_exe_path, MAX_PATH); GetModuleFileName(0, stunnel_exe_path, MAX_PATH);
/* find previous instances of the same executable */ /* find previous instances of the same executable */
EnumWindows(enum_windows, (LPARAM)stunnel_exe_path); if(!cmdline.service && !cmdline.install && !cmdline.uninstall &&
!cmdline.start && !cmdline.stop) {
EnumWindows(enum_windows, (LPARAM)stunnel_exe_path);
if(cmdline.exit)
return 0; /* in case EnumWindows didn't find a previous instance */
}
/* change current working directory */ /* change current working directory */
c=strrchr(stunnel_exe_path, '\\'); /* last backslash */ c=strrchr(stunnel_exe_path, '\\'); /* last backslash */
@ -190,16 +185,13 @@ int WINAPI WinMain(HINSTANCE this_instance, HINSTANCE prev_instance,
str_free(errmsg); str_free(errmsg);
return 1; return 1;
} }
if(cmdline.exit)
return 0; /* in case EnumWindows didn't find a previous instance */
#endif #endif
if(initialize_winsock()) if(initialize_winsock())
return 1; return 1;
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
if(cmdline.service) /* it must be checked before "-install" */ if(cmdline.service) /* "-service" must be processed before "-install" */
return service_initialize(); return service_initialize();
if(cmdline.install) if(cmdline.install)
return service_install(command_line); return service_install(command_line);
@ -216,7 +208,7 @@ int WINAPI WinMain(HINSTANCE this_instance, HINSTANCE prev_instance,
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
static BOOL CALLBACK enum_windows(HWND other_window_handle, LPARAM lParam) { static BOOL CALLBACK enum_windows(HWND other_window_handle, LPARAM lParam) {
DWORD pid; DWORD pid, exit_code;
HINSTANCE hInstance; HINSTANCE hInstance;
char window_exe_path[MAX_PATH]; char window_exe_path[MAX_PATH];
HANDLE process_handle; HANDLE process_handle;
@ -226,9 +218,14 @@ static BOOL CALLBACK enum_windows(HWND other_window_handle, LPARAM lParam) {
return TRUE; return TRUE;
hInstance=(HINSTANCE)GetWindowLong(other_window_handle, GWL_HINSTANCE); hInstance=(HINSTANCE)GetWindowLong(other_window_handle, GWL_HINSTANCE);
GetWindowThreadProcessId(other_window_handle, &pid); GetWindowThreadProcessId(other_window_handle, &pid);
process_handle=OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ, process_handle=OpenProcess(SYNCHRONIZE /* WaitForSingleObject() */ |
PROCESS_TERMINATE /* TerminateProcess() */ |
PROCESS_QUERY_INFORMATION|PROCESS_VM_READ /* GetModuleFileNameEx() */,
FALSE, pid); FALSE, pid);
if(!GetModuleFileNameEx(process_handle, hInstance, window_exe_path, MAX_PATH)) { if(!process_handle)
return TRUE;
if(!GetModuleFileNameEx(process_handle,
hInstance, window_exe_path, MAX_PATH)) {
CloseHandle(process_handle); CloseHandle(process_handle);
return TRUE; return TRUE;
} }
@ -237,8 +234,11 @@ static BOOL CALLBACK enum_windows(HWND other_window_handle, LPARAM lParam) {
return TRUE; return TRUE;
} }
if(cmdline.exit) { if(cmdline.exit) {
SendMessage(other_window_handle, WM_COMMAND, IDM_EXIT, 0); PostMessage(other_window_handle, WM_COMMAND, IDM_EXIT, 0);
WaitForSingleObject(process_handle, 3000); if(WaitForSingleObject(process_handle, 3000)==WAIT_TIMEOUT) {
TerminateProcess(process_handle, 0);
WaitForSingleObject(process_handle, 3000);
}
} else { } else {
ShowWindow(other_window_handle, SW_SHOWNORMAL); /* show window */ ShowWindow(other_window_handle, SW_SHOWNORMAL); /* show window */
SetForegroundWindow(other_window_handle); /* bring on top */ SetForegroundWindow(other_window_handle); /* bring on top */
@ -289,37 +289,12 @@ static void parse_cmdline(LPSTR command_line) {
/* try to load winsock2 resolver functions from a specified dll name */ /* try to load winsock2 resolver functions from a specified dll name */
static int initialize_winsock() { static int initialize_winsock() {
static struct WSAData wsa_state; static struct WSAData wsa_state;
#ifndef _WIN32_WCE
HINSTANCE handle;
#endif
if(WSAStartup(MAKEWORD( 2, 2 ), &wsa_state)) { if(WSAStartup(MAKEWORD( 2, 2 ), &wsa_state)) {
message_box("Failed to initialize winsock", MB_ICONERROR); message_box("Failed to initialize winsock", MB_ICONERROR);
return 1; /* error */ return 1; /* error */
} }
#ifndef _WIN32_WCE resolver_init();
handle=LoadLibrary("ws2_32.dll"); /* IPv6 in Windows XP or higher */
if(handle) {
s_getaddrinfo=(GETADDRINFO)GetProcAddress(handle, "getaddrinfo");
s_freeaddrinfo=(FREEADDRINFO)GetProcAddress(handle, "freeaddrinfo");
s_getnameinfo=(GETNAMEINFO)GetProcAddress(handle, "getnameinfo");
if(s_getaddrinfo && s_freeaddrinfo && s_getnameinfo)
return 0; /* IPv6 detected -> OK */
FreeLibrary(handle);
}
handle=LoadLibrary("wship6.dll"); /* experimental IPv6 for Windows 2000 */
if(handle) {
s_getaddrinfo=(GETADDRINFO)GetProcAddress(handle, "getaddrinfo");
s_freeaddrinfo=(FREEADDRINFO)GetProcAddress(handle, "freeaddrinfo");
s_getnameinfo=(GETNAMEINFO)GetProcAddress(handle, "getnameinfo");
if(s_getaddrinfo && s_freeaddrinfo && s_getnameinfo)
return 0; /* IPv6 detected -> OK */
FreeLibrary(handle);
}
s_getaddrinfo=NULL;
s_freeaddrinfo=NULL;
s_getnameinfo=NULL;
#endif
return 0; /* IPv4 detected -> OK */ return 0; /* IPv4 detected -> OK */
} }
@ -379,7 +354,7 @@ static int gui_loop() {
#endif #endif
/* auto-reset, non-signaled */ /* auto-reset, non-signaled */
config_ready=CreateEvent(NULL, FALSE, FALSE, NULL); config_ready=CreateEvent(NULL, FALSE, FALSE, NULL);
daemon_handle=(HANDLE)_beginthread(daemon_thread, DEFAULT_STACK_SIZE, NULL); _beginthread(daemon_thread, DEFAULT_STACK_SIZE, NULL);
while(GetMessage(&msg, NULL, 0, 0)) { while(GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg); TranslateMessage(&msg);
@ -517,10 +492,8 @@ static LRESULT CALLBACK window_proc(HWND main_window_handle,
ShowWindow(main_window_handle, SW_HIDE); /* hide window */ ShowWindow(main_window_handle, SW_HIDE); /* hide window */
break; break;
case IDM_EXIT: case IDM_EXIT:
if(!error_mode) { /* signal_pipe is active */ if(!error_mode) /* signal_pipe is active */
signal_post(SIGNAL_TERMINATE); signal_post(SIGNAL_TERMINATE);
WaitForSingleObject(daemon_handle, 3000);
}
DestroyWindow(main_window_handle); DestroyWindow(main_window_handle);
break; break;
case IDM_SAVE_LOG: case IDM_SAVE_LOG:
@ -937,11 +910,13 @@ static void update_peer_menu(void) {
section->file=str2tstr(str); section->file=str2tstr(str);
str_free(str); str_free(str);
/* setup section->help */ /* setup LPTSTR section->file */
str=str_printf("peer-%s.pem", section->servname); str=str_printf("peer-%s.pem", section->servname);
section->file=str2tstr(str); section->file=str2tstr(str);
str_free(str); str_free(str);
str=str_printf(
/* setup (char *) section->help */
section->help=str_printf(
"Peer certificate chain has been saved.\n" "Peer certificate chain has been saved.\n"
"Add the following lines to section [%s]:\n" "Add the following lines to section [%s]:\n"
"\tCAfile = peer-%s.pem\n" "\tCAfile = peer-%s.pem\n"
@ -949,8 +924,6 @@ static void update_peer_menu(void) {
"to enable cryptographic authentication.\n" "to enable cryptographic authentication.\n"
"Then reload stunnel configuration file.", "Then reload stunnel configuration file.",
section->servname, section->servname); section->servname, section->servname);
section->help=str2tstr(str);
str_free(str);
/* setup section->chain */ /* setup section->chain */
section->chain=NULL; section->chain=NULL;
@ -1021,7 +994,7 @@ static void error_box(const LPSTR text) {
str_free(fullmsg); str_free(fullmsg);
} }
static void message_box(const LPSTR text, const UINT type) { void message_box(const LPSTR text, const UINT type) {
LPTSTR tstr; LPTSTR tstr;
if(cmdline.quiet) if(cmdline.quiet)
@ -1031,6 +1004,18 @@ static void message_box(const LPSTR text, const UINT type) {
str_free(tstr); str_free(tstr);
} }
void win_new_chain(int section_number) {
PostMessage(hwnd, WM_NEW_CHAIN, section_number, 0);
}
void win_new_log(char *line) {
SendMessage(hwnd, WM_LOG, (WPARAM)line, 0);
}
void win_new_config(void) {
PostMessage(hwnd, WM_VALID_CONFIG, 0, 0);
}
static void edit_config(HWND main_window_handle) { static void edit_config(HWND main_window_handle) {
char cwd[MAX_PATH], *conf_path; char cwd[MAX_PATH], *conf_path;

View File

@ -1,24 +1,24 @@
/* /*
* stunnel Universal SSL tunnel * stunnel Universal SSL tunnel
* Copyright (C) 1998-2012 Michal Trojnara <Michal.Trojnara@mirt.net> * Copyright (C) 1998-2013 Michal Trojnara <Michal.Trojnara@mirt.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your * Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with this program; if not, see <http://www.gnu.org/licenses>. * with this program; if not, see <http://www.gnu.org/licenses>.
* *
* Linking stunnel statically or dynamically with other modules is making * Linking stunnel statically or dynamically with other modules is making
* a combined work based on stunnel. Thus, the terms and conditions of * a combined work based on stunnel. Thus, the terms and conditions of
* the GNU General Public License cover the whole combination. * the GNU General Public License cover the whole combination.
* *
* In addition, as a special exception, the copyright holder of stunnel * In addition, as a special exception, the copyright holder of stunnel
* gives you permission to combine stunnel with free software programs or * gives you permission to combine stunnel with free software programs or
* libraries that are released under the GNU LGPL and with code included * libraries that are released under the GNU LGPL and with code included
@ -26,7 +26,7 @@
* modified versions of such code, with unchanged license). You may copy * modified versions of such code, with unchanged license). You may copy
* and distribute such a system following the terms of the GNU GPL for * and distribute such a system following the terms of the GNU GPL for
* stunnel and the licenses of the other code concerned. * stunnel and the licenses of the other code concerned.
* *
* Note that people who make modified versions of stunnel are not obligated * Note that people who make modified versions of stunnel are not obligated
* to grant this special exception for their modified versions; it is their * to grant this special exception for their modified versions; it is their
* choice whether to do so. The GNU General Public License gives permission * choice whether to do so. The GNU General Public License gives permission
@ -168,13 +168,11 @@ void libwrap_auth(CLI *c, char *accepted_address) {
} }
busy[my_process]=0; /* mark the child process as free */ busy[my_process]=0; /* mark the child process as free */
--num_busy; /* the child process has been released */ --num_busy; /* the child process has been released */
if(num_busy==num_processes-1) { /* need to wake up a thread */ retval=pthread_cond_signal(&cond); /* signal a waiting thread */
retval=pthread_cond_signal(&cond); /* signal waiting threads */ if(retval) {
if(retval) { errno=retval;
errno=retval; ioerror("pthread_cond_signal");
ioerror("pthread_cond_signal"); longjmp(c->err, 1);
longjmp(c->err, 1);
}
} }
retval=pthread_mutex_unlock(&mutex); retval=pthread_mutex_unlock(&mutex);
if(retval) { if(retval) {

View File

@ -1,24 +1,24 @@
/* /*
* stunnel Universal SSL tunnel * stunnel Universal SSL tunnel
* Copyright (C) 1998-2012 Michal Trojnara <Michal.Trojnara@mirt.net> * Copyright (C) 1998-2013 Michal Trojnara <Michal.Trojnara@mirt.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your * Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with this program; if not, see <http://www.gnu.org/licenses>. * with this program; if not, see <http://www.gnu.org/licenses>.
* *
* Linking stunnel statically or dynamically with other modules is making * Linking stunnel statically or dynamically with other modules is making
* a combined work based on stunnel. Thus, the terms and conditions of * a combined work based on stunnel. Thus, the terms and conditions of
* the GNU General Public License cover the whole combination. * the GNU General Public License cover the whole combination.
* *
* In addition, as a special exception, the copyright holder of stunnel * In addition, as a special exception, the copyright holder of stunnel
* gives you permission to combine stunnel with free software programs or * gives you permission to combine stunnel with free software programs or
* libraries that are released under the GNU LGPL and with code included * libraries that are released under the GNU LGPL and with code included
@ -26,7 +26,7 @@
* modified versions of such code, with unchanged license). You may copy * modified versions of such code, with unchanged license). You may copy
* and distribute such a system following the terms of the GNU GPL for * and distribute such a system following the terms of the GNU GPL for
* stunnel and the licenses of the other code concerned. * stunnel and the licenses of the other code concerned.
* *
* Note that people who make modified versions of stunnel are not obligated * Note that people who make modified versions of stunnel are not obligated
* to grant this special exception for their modified versions; it is their * to grant this special exception for their modified versions; it is their
* choice whether to do so. The GNU General Public License gives permission * choice whether to do so. The GNU General Public License gives permission
@ -73,14 +73,17 @@ void syslog_close(void) {
#endif /* !defined(USE_WIN32) && !defined(__vms) */ #endif /* !defined(USE_WIN32) && !defined(__vms) */
void log_open(void) { int log_open(void) {
if(global_options.output_file) { /* 'output' option specified */ if(global_options.output_file) { /* 'output' option specified */
outfile=file_open(global_options.output_file, 1); outfile=file_open(global_options.output_file, 1);
if(!outfile) if(!outfile) {
s_log(LOG_ERR, "Unable to open output file: %s", s_log(LOG_ERR, "Cannot open log file: %s",
global_options.output_file); global_options.output_file);
return 1;
}
} }
log_flush(LOG_MODE_CONFIGURED); log_flush(LOG_MODE_CONFIGURED);
return 0;
} }
void log_close(void) { void log_close(void) {
@ -198,15 +201,7 @@ static void log_raw(const int level, const char *stamp,
if(mode==LOG_MODE_ERROR || /* always log to the GUI window */ if(mode==LOG_MODE_ERROR || /* always log to the GUI window */
(mode==LOG_MODE_INFO && level<LOG_DEBUG) || (mode==LOG_MODE_INFO && level<LOG_DEBUG) ||
level<=global_options.debug_level) level<=global_options.debug_level)
SendMessage(hwnd, WM_LOG, (WPARAM)line, 0); win_new_log(line);
#if 0
/* logging to Windows console for nogui.c */
LPTSTR tstr;
tstr=str2tstr(line);
RETAILMSG(TRUE, (TEXT("%s\r\n"), tstr));
str_free(tstr);
#endif
#else /* Unix */ #else /* Unix */
if(mode==LOG_MODE_ERROR || /* always log LOG_MODE_ERROR to stderr */ if(mode==LOG_MODE_ERROR || /* always log LOG_MODE_ERROR to stderr */
(mode==LOG_MODE_INFO && level<LOG_DEBUG) || (mode==LOG_MODE_INFO && level<LOG_DEBUG) ||
@ -251,12 +246,7 @@ void fatal_debug(char *error, char *file, int line) {
#endif /* USE_WIN32, __vms */ #endif /* USE_WIN32, __vms */
#ifdef USE_WIN32 #ifdef USE_WIN32
#ifdef _WIN32_WCE message_box(text, MB_ICONERROR);
MessageBox(hwnd, TEXT("INTERNAL ERROR"),
TEXT("stunnel"), MB_ICONERROR);
#else /* _WIN32_WCE */
MessageBox(hwnd, text, "stunnel", MB_ICONERROR);
#endif /* _WIN32_WCE */
#endif /* USE_WIN32 */ #endif /* USE_WIN32 */
abort(); abort();

View File

@ -1,24 +1,24 @@
/* /*
* stunnel Universal SSL tunnel * stunnel Universal SSL tunnel
* Copyright (C) 1998-2012 Michal Trojnara <Michal.Trojnara@mirt.net> * Copyright (C) 1998-2013 Michal Trojnara <Michal.Trojnara@mirt.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your * Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with this program; if not, see <http://www.gnu.org/licenses>. * with this program; if not, see <http://www.gnu.org/licenses>.
* *
* Linking stunnel statically or dynamically with other modules is making * Linking stunnel statically or dynamically with other modules is making
* a combined work based on stunnel. Thus, the terms and conditions of * a combined work based on stunnel. Thus, the terms and conditions of
* the GNU General Public License cover the whole combination. * the GNU General Public License cover the whole combination.
* *
* In addition, as a special exception, the copyright holder of stunnel * In addition, as a special exception, the copyright holder of stunnel
* gives you permission to combine stunnel with free software programs or * gives you permission to combine stunnel with free software programs or
* libraries that are released under the GNU LGPL and with code included * libraries that are released under the GNU LGPL and with code included
@ -26,7 +26,7 @@
* modified versions of such code, with unchanged license). You may copy * modified versions of such code, with unchanged license). You may copy
* and distribute such a system following the terms of the GNU GPL for * and distribute such a system following the terms of the GNU GPL for
* stunnel and the licenses of the other code concerned. * stunnel and the licenses of the other code concerned.
* *
* Note that people who make modified versions of stunnel are not obligated * Note that people who make modified versions of stunnel are not obligated
* to grant this special exception for their modified versions; it is their * to grant this special exception for their modified versions; it is their
* choice whether to do so. The GNU General Public License gives permission * choice whether to do so. The GNU General Public License gives permission
@ -40,6 +40,8 @@
/* #define DEBUG_UCONTEXT */ /* #define DEBUG_UCONTEXT */
static int get_socket_error(const int);
/**************************************** s_poll functions */ /**************************************** s_poll functions */
#ifdef USE_POLL #ifdef USE_POLL
@ -88,8 +90,8 @@ int s_poll_canread(s_poll_set *fds, int fd) {
for(i=0; i<fds->nfds; i++) for(i=0; i<fds->nfds; i++)
if(fds->ufds[i].fd==fd) if(fds->ufds[i].fd==fd)
return fds->ufds[i].revents&(POLLIN|POLLHUP); /* read or closed */ return fds->ufds[i].revents&POLLIN;
return 0; return 0; /* not listed in fds */
} }
int s_poll_canwrite(s_poll_set *fds, int fd) { int s_poll_canwrite(s_poll_set *fds, int fd) {
@ -97,20 +99,27 @@ int s_poll_canwrite(s_poll_set *fds, int fd) {
for(i=0; i<fds->nfds; i++) for(i=0; i<fds->nfds; i++)
if(fds->ufds[i].fd==fd) if(fds->ufds[i].fd==fd)
return fds->ufds[i].revents&POLLOUT; /* it is possible to write */ return fds->ufds[i].revents&POLLOUT;
return 0; return 0; /* not listed in fds */
} }
int s_poll_error(s_poll_set *fds, FD *s) { int s_poll_hup(s_poll_set *fds, int fd) {
unsigned int i; unsigned int i;
if(!s->is_socket)
return 0;
for(i=0; i<fds->nfds; i++) for(i=0; i<fds->nfds; i++)
if(fds->ufds[i].fd==s->fd) if(fds->ufds[i].fd==fd)
return fds->ufds[i].revents&POLLHUP;
return 0; /* not listed in fds */
}
int s_poll_error(s_poll_set *fds, int fd) {
unsigned int i;
for(i=0; i<fds->nfds; i++)
if(fds->ufds[i].fd==fd)
return fds->ufds[i].revents&(POLLERR|POLLNVAL) ? return fds->ufds[i].revents&(POLLERR|POLLNVAL) ?
get_socket_error(s->fd) : 0; get_socket_error(fd) : 0;
return 0; return 0; /* not listed in fds */
} }
#ifdef USE_UCONTEXT #ifdef USE_UCONTEXT
@ -321,14 +330,18 @@ int s_poll_canwrite(s_poll_set *fds, int fd) {
return FD_ISSET(fd, &fds->owfds); return FD_ISSET(fd, &fds->owfds);
} }
int s_poll_error(s_poll_set *fds, FD *s) { int s_poll_hup(s_poll_set *fds, int fd) {
if(!s->is_socket) (void)fds; /* skip warning about unused parameter */
return 0; /* getsockopt is only available on sockets */ (void)fd; /* skip warning about unused parameter */
return 0; /* FIXME: how to detect HUP condition with select()? */
}
int s_poll_error(s_poll_set *fds, int fd) {
/* error conditions are signaled as read, but apparently *not* in Winsock: /* error conditions are signaled as read, but apparently *not* in Winsock:
* http://msdn.microsoft.com/en-us/library/windows/desktop/ms737625%28v=vs.85%29.aspx */ * http://msdn.microsoft.com/en-us/library/windows/desktop/ms737625%28v=vs.85%29.aspx */
if(!(FD_ISSET(s->fd, &fds->orfds) || FD_ISSET(s->fd, &fds->oxfds))) if(!FD_ISSET(fd, &fds->orfds) && !FD_ISSET(fd, &fds->oxfds))
return 0; return 0;
return get_socket_error(s->fd); /* check if it's really an error */ return get_socket_error(fd); /* check if it's really an error */
} }
int s_poll_wait(s_poll_set *fds, int sec, int msec) { int s_poll_wait(s_poll_set *fds, int sec, int msec) {
@ -400,13 +413,13 @@ int set_socket_options(int s, int type) {
return retval; /* returns 0 when all options succeeded */ return retval; /* returns 0 when all options succeeded */
} }
int get_socket_error(const int fd) { static int get_socket_error(const int fd) {
int err; int err;
socklen_t optlen=sizeof err; socklen_t optlen=sizeof err;
if(getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&err, &optlen)) if(getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&err, &optlen))
err=get_last_socket_error(); /* failed -> ask why */ err=get_last_socket_error(); /* failed -> ask why */
return err; return err==S_ENOTSOCK ? 0 : err;
} }
/**************************************** simulate blocking I/O */ /**************************************** simulate blocking I/O */
@ -550,9 +563,10 @@ void fd_putline(CLI *c, int fd, const char *line) {
} }
char *fd_getline(CLI *c, int fd) { char *fd_getline(CLI *c, int fd) {
char *line=NULL, *tmpline; char *line, *tmpline;
int ptr=0; int ptr=0, allocated=32;
line=str_alloc(allocated);
for(;;) { for(;;) {
s_poll_init(c->fds); s_poll_init(c->fds);
s_poll_add(c->fds, fd, 1, 0); /* read */ s_poll_add(c->fds, fd, 1, 0); /* read */
@ -573,7 +587,10 @@ char *fd_getline(CLI *c, int fd) {
str_free(line); str_free(line);
longjmp(c->err, 1); /* error */ longjmp(c->err, 1); /* error */
} }
line=str_realloc(line, ptr+1); if(allocated<ptr+1) {
allocated*=2;
line=str_realloc(line, allocated);
}
switch(readsocket(fd, line+ptr, 1)) { switch(readsocket(fd, line+ptr, 1)) {
case -1: /* error */ case -1: /* error */
sockerror("fd_getline: readsocket"); sockerror("fd_getline: readsocket");

View File

@ -1,24 +1,24 @@
/* /*
* stunnel Universal SSL tunnel * stunnel Universal SSL tunnel
* Copyright (C) 1998-2012 Michal Trojnara <Michal.Trojnara@mirt.net> * Copyright (C) 1998-2013 Michal Trojnara <Michal.Trojnara@mirt.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your * Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with this program; if not, see <http://www.gnu.org/licenses>. * with this program; if not, see <http://www.gnu.org/licenses>.
* *
* Linking stunnel statically or dynamically with other modules is making * Linking stunnel statically or dynamically with other modules is making
* a combined work based on stunnel. Thus, the terms and conditions of * a combined work based on stunnel. Thus, the terms and conditions of
* the GNU General Public License cover the whole combination. * the GNU General Public License cover the whole combination.
* *
* In addition, as a special exception, the copyright holder of stunnel * In addition, as a special exception, the copyright holder of stunnel
* gives you permission to combine stunnel with free software programs or * gives you permission to combine stunnel with free software programs or
* libraries that are released under the GNU LGPL and with code included * libraries that are released under the GNU LGPL and with code included
@ -26,7 +26,7 @@
* modified versions of such code, with unchanged license). You may copy * modified versions of such code, with unchanged license). You may copy
* and distribute such a system following the terms of the GNU GPL for * and distribute such a system following the terms of the GNU GPL for
* stunnel and the licenses of the other code concerned. * stunnel and the licenses of the other code concerned.
* *
* Note that people who make modified versions of stunnel are not obligated * Note that people who make modified versions of stunnel are not obligated
* to grant this special exception for their modified versions; it is their * to grant this special exception for their modified versions; it is their
* choice whether to do so. The GNU General Public License gives permission * choice whether to do so. The GNU General Public License gives permission
@ -41,21 +41,59 @@
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
static struct WSAData wsa_state; static struct WSAData wsa_state;
str_init(); /* initialize per-thread string management */
if(WSAStartup(MAKEWORD(1, 1), &wsa_state)) if(WSAStartup(MAKEWORD(1, 1), &wsa_state))
return 1; return 1;
resolver_init();
main_initialize(); main_initialize();
if(main_configure(argc>1 ? argv[1] : NULL, argc>2 ? argv[2] : NULL)) if(!main_configure(argc>1 ? argv[1] : NULL, argc>2 ? argv[2] : NULL))
return 1; daemon_loop();
main_execute(); unbind_ports();
log_flush(LOG_MODE_ERROR);
return 0; return 0;
} }
void message_box(const LPSTR text, const UINT type) {
LPTSTR tstr;
tstr=str2tstr(text);
MessageBox(NULL, tstr, TEXT("stunnel"), type);
str_free(tstr);
}
void win_new_chain(int section_number) {
(void)section_number; /* skip warning about unused parameter */
}
void win_new_log(char *line) {
#ifdef _WIN32_WCE
/* log to Windows CE debug output stream */
LPTSTR tstr;
tstr=str2tstr(line);
RETAILMSG(TRUE, (TEXT("%s\r\n"), tstr));
str_free(tstr);
#else
printf("%s\n", line);
#endif
}
void win_new_config(void) {
/* no action */
}
int passwd_cb(char *buf, int size, int rwflag, void *userdata) { int passwd_cb(char *buf, int size, int rwflag, void *userdata) {
(void)buf; /* skip warning about unused parameter */
(void)size; /* skip warning about unused parameter */
(void)rwflag; /* skip warning about unused parameter */
(void)userdata; /* skip warning about unused parameter */
return 0; /* not implemented */ return 0; /* not implemented */
} }
#ifdef HAVE_OSSL_ENGINE_H #ifdef HAVE_OSSL_ENGINE_H
int pin_cb(UI *ui, UI_STRING *uis) { int pin_cb(UI *ui, UI_STRING *uis) {
(void)ui; /* skip warning about unused parameter */
(void)uis; /* skip warning about unused parameter */
return 0; /* not implemented */ return 0; /* not implemented */
} }
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,11 @@
prefix=. prefix=.
DEFS = -DPACKAGE_NAME=\"stunnel\" \ DEFS = -DPACKAGE_NAME=\"stunnel\" \
-DPACKAGE_TARNAME=\"stunnel\" \ -DPACKAGE_TARNAME=\"stunnel\" \
-DPACKAGE_VERSION=\"4.53\" \ -DPACKAGE_VERSION=\"4.57\" \
-DPACKAGE_STRING=\"stunnel\ 4.53\" \ -DPACKAGE_STRING=\"stunnel\ 4.57\" \
-DPACKAGE_BUGREPORT=\"\" \ -DPACKAGE_BUGREPORT=\"\" \
-DPACKAGE=\"stunnel\" \ -DPACKAGE=\"stunnel\" \
-DVERSION=\"4.53\" \ -DVERSION=\"4.57\" \
-DSTDC_HEADERS=1 \ -DSTDC_HEADERS=1 \
-DHAVE_SYS_TYPES_H=1 \ -DHAVE_SYS_TYPES_H=1 \
-DHAVE_SYS_STAT_H=1 \ -DHAVE_SYS_STAT_H=1 \

View File

@ -1,24 +1,24 @@
/* /*
* stunnel Universal SSL tunnel * stunnel Universal SSL tunnel
* Copyright (C) 1998-2012 Michal Trojnara <Michal.Trojnara@mirt.net> * Copyright (C) 1998-2013 Michal Trojnara <Michal.Trojnara@mirt.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your * Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with this program; if not, see <http://www.gnu.org/licenses>. * with this program; if not, see <http://www.gnu.org/licenses>.
* *
* Linking stunnel statically or dynamically with other modules is making * Linking stunnel statically or dynamically with other modules is making
* a combined work based on stunnel. Thus, the terms and conditions of * a combined work based on stunnel. Thus, the terms and conditions of
* the GNU General Public License cover the whole combination. * the GNU General Public License cover the whole combination.
* *
* In addition, as a special exception, the copyright holder of stunnel * In addition, as a special exception, the copyright holder of stunnel
* gives you permission to combine stunnel with free software programs or * gives you permission to combine stunnel with free software programs or
* libraries that are released under the GNU LGPL and with code included * libraries that are released under the GNU LGPL and with code included
@ -26,7 +26,7 @@
* modified versions of such code, with unchanged license). You may copy * modified versions of such code, with unchanged license). You may copy
* and distribute such a system following the terms of the GNU GPL for * and distribute such a system following the terms of the GNU GPL for
* stunnel and the licenses of the other code concerned. * stunnel and the licenses of the other code concerned.
* *
* Note that people who make modified versions of stunnel are not obligated * Note that people who make modified versions of stunnel are not obligated
* to grant this special exception for their modified versions; it is their * to grant this special exception for their modified versions; it is their
* choice whether to do so. The GNU General Public License gives permission * choice whether to do so. The GNU General Public License gives permission
@ -38,7 +38,7 @@
#include "common.h" #include "common.h"
#include "prototypes.h" #include "prototypes.h"
#define isprefix(a, b) (strncasecmp((a), (b), strlen(b))==0) #define is_prefix(a, b) (strncasecmp((a), (b), strlen(b))==0)
/* protocol-specific function prototypes */ /* protocol-specific function prototypes */
static void proxy_server(CLI *c); static void proxy_server(CLI *c);
@ -71,7 +71,7 @@ typedef void (*FUNCTION)(CLI *);
static const struct { static const struct {
char *name; char *name;
struct { struct {
PROTOCOL_TYPE type; PROTOCOL_PHASE type;
FUNCTION func; FUNCTION func;
} handlers[2]; } handlers[2];
} protocols[]={ } protocols[]={
@ -95,7 +95,7 @@ int find_protocol_id(const char *name) {
return -1; return -1;
} }
void protocol(CLI *c, const PROTOCOL_TYPE type) { void protocol(CLI *c, const PROTOCOL_PHASE type) {
const int id=c->opt->protocol, mode=(unsigned int)c->opt->option.client; const int id=c->opt->protocol, mode=(unsigned int)c->opt->option.client;
if(id<0 || type!=protocols[id].handlers[mode].type || if(id<0 || type!=protocols[id].handlers[mode].type ||
@ -112,7 +112,7 @@ void protocol(CLI *c, const PROTOCOL_TYPE type) {
/* /*
* PROXY protocol: http://haproxy.1wt.eu/download/1.5/doc/proxy-protocol.txt * PROXY protocol: http://haproxy.1wt.eu/download/1.5/doc/proxy-protocol.txt
* this is a protocol client support for stunnel acting as an SSL server * this is a protocol client support for stunnel acting as an SSL server
* I don't think anything else is useful, but feel free to discuss on the * I don't think anything else is useful, but feel free to discuss on the
* stunnel-users mailing list if you disagree * stunnel-users mailing list if you disagree
*/ */
@ -157,9 +157,11 @@ static void proxy_server(CLI *c) {
case AF_INET: case AF_INET:
proto="TCP4"; proto="TCP4";
break; break;
#ifdef USE_IPv6
case AF_INET6: case AF_INET6:
proto="TCP6"; proto="TCP6";
break; break;
#endif
default: /* AF_UNIX */ default: /* AF_UNIX */
proto="UNKNOWN"; proto="UNKNOWN";
} }
@ -203,7 +205,7 @@ static void cifs_server(CLI *c) {
longjmp(c->err, 1); longjmp(c->err, 1);
} }
read_blocking(c, c->local_rfd.fd, buffer+4, len); read_blocking(c, c->local_rfd.fd, buffer+4, len);
if(buffer[0]!=0x81){ /* NB_SSN_REQUEST */ if(buffer[0]!=0x81) { /* NB_SSN_REQUEST */
s_log(LOG_ERR, "Client did not send session setup"); s_log(LOG_ERR, "Client did not send session setup");
write_blocking(c, c->local_wfd.fd, response_access_denied, 5); write_blocking(c, c->local_wfd.fd, response_access_denied, 5);
longjmp(c->err, 1); longjmp(c->err, 1);
@ -246,28 +248,35 @@ static void pgsql_server(CLI *c) {
static void smtp_client(CLI *c) { static void smtp_client(CLI *c) {
char *line; char *line;
line=str_dup("");
do { /* copy multiline greeting */ do { /* copy multiline greeting */
str_free(line);
line=fd_getline(c, c->remote_fd.fd); line=fd_getline(c, c->remote_fd.fd);
fd_putline(c, c->local_wfd.fd, line); fd_putline(c, c->local_wfd.fd, line);
} while(isprefix(line, "220-")); } while(is_prefix(line, "220-"));
fd_putline(c, c->remote_fd.fd, "EHLO localhost"); fd_putline(c, c->remote_fd.fd, "EHLO localhost");
do { /* skip multiline reply */ do { /* skip multiline reply */
str_free(line);
line=fd_getline(c, c->remote_fd.fd); line=fd_getline(c, c->remote_fd.fd);
} while(isprefix(line, "250-")); } while(is_prefix(line, "250-"));
if(!isprefix(line, "250 ")) { /* error */ if(!is_prefix(line, "250 ")) { /* error */
s_log(LOG_ERR, "Remote server is not RFC 1425 compliant"); s_log(LOG_ERR, "Remote server is not RFC 1425 compliant");
str_free(line);
longjmp(c->err, 1); longjmp(c->err, 1);
} }
fd_putline(c, c->remote_fd.fd, "STARTTLS"); fd_putline(c, c->remote_fd.fd, "STARTTLS");
do { /* skip multiline reply */ do { /* skip multiline reply */
str_free(line);
line=fd_getline(c, c->remote_fd.fd); line=fd_getline(c, c->remote_fd.fd);
} while(isprefix(line, "220-")); } while(is_prefix(line, "220-"));
if(!isprefix(line, "220 ")) { /* error */ if(!is_prefix(line, "220 ")) { /* error */
s_log(LOG_ERR, "Remote server is not RFC 2487 compliant"); s_log(LOG_ERR, "Remote server is not RFC 2487 compliant");
str_free(line);
longjmp(c->err, 1); longjmp(c->err, 1);
} }
str_free(line);
} }
static void smtp_server(CLI *c) { static void smtp_server(CLI *c) {
@ -288,24 +297,30 @@ static void smtp_server(CLI *c) {
} }
line=fd_getline(c, c->remote_fd.fd); line=fd_getline(c, c->remote_fd.fd);
if(!isprefix(line, "220")) { if(!is_prefix(line, "220")) {
s_log(LOG_ERR, "Unknown server welcome"); s_log(LOG_ERR, "Unknown server welcome");
str_free(line);
longjmp(c->err, 1); longjmp(c->err, 1);
} }
fd_printf(c, c->local_wfd.fd, "%s + stunnel", line); fd_printf(c, c->local_wfd.fd, "%s + stunnel", line);
str_free(line);
line=fd_getline(c, c->local_rfd.fd); line=fd_getline(c, c->local_rfd.fd);
if(!isprefix(line, "EHLO ")) { if(!is_prefix(line, "EHLO ")) {
s_log(LOG_ERR, "Unknown client EHLO"); s_log(LOG_ERR, "Unknown client EHLO");
str_free(line);
longjmp(c->err, 1); longjmp(c->err, 1);
} }
fd_printf(c, c->local_wfd.fd, "250-%s Welcome", line); fd_printf(c, c->local_wfd.fd, "250-%s Welcome", line);
fd_putline(c, c->local_wfd.fd, "250 STARTTLS"); fd_putline(c, c->local_wfd.fd, "250 STARTTLS");
str_free(line);
line=fd_getline(c, c->local_rfd.fd); line=fd_getline(c, c->local_rfd.fd);
if(!isprefix(line, "STARTTLS")) { if(!is_prefix(line, "STARTTLS")) {
s_log(LOG_ERR, "STARTTLS expected"); s_log(LOG_ERR, "STARTTLS expected");
str_free(line);
longjmp(c->err, 1); longjmp(c->err, 1);
} }
fd_putline(c, c->local_wfd.fd, "220 Go ahead"); fd_putline(c, c->local_wfd.fd, "220 Go ahead");
str_free(line);
} }
/**************************************** pop3 */ /**************************************** pop3 */
@ -314,17 +329,21 @@ static void pop3_client(CLI *c) {
char *line; char *line;
line=fd_getline(c, c->remote_fd.fd); line=fd_getline(c, c->remote_fd.fd);
if(!isprefix(line, "+OK ")) { if(!is_prefix(line, "+OK ")) {
s_log(LOG_ERR, "Unknown server welcome"); s_log(LOG_ERR, "Unknown server welcome");
str_free(line);
longjmp(c->err, 1); longjmp(c->err, 1);
} }
fd_putline(c, c->local_wfd.fd, line); fd_putline(c, c->local_wfd.fd, line);
fd_putline(c, c->remote_fd.fd, "STLS"); fd_putline(c, c->remote_fd.fd, "STLS");
str_free(line);
line=fd_getline(c, c->remote_fd.fd); line=fd_getline(c, c->remote_fd.fd);
if(!isprefix(line, "+OK ")) { if(!is_prefix(line, "+OK ")) {
s_log(LOG_ERR, "Server does not support TLS"); s_log(LOG_ERR, "Server does not support TLS");
str_free(line);
longjmp(c->err, 1); longjmp(c->err, 1);
} }
str_free(line);
} }
static void pop3_server(CLI *c) { static void pop3_server(CLI *c) {
@ -332,17 +351,21 @@ static void pop3_server(CLI *c) {
line=fd_getline(c, c->remote_fd.fd); line=fd_getline(c, c->remote_fd.fd);
fd_printf(c, c->local_wfd.fd, "%s + stunnel", line); fd_printf(c, c->local_wfd.fd, "%s + stunnel", line);
str_free(line);
line=fd_getline(c, c->local_rfd.fd); line=fd_getline(c, c->local_rfd.fd);
if(isprefix(line, "CAPA")) { /* client wants RFC 2449 extensions */ if(is_prefix(line, "CAPA")) { /* client wants RFC 2449 extensions */
fd_putline(c, c->local_wfd.fd, "+OK Stunnel capability list follows"); fd_putline(c, c->local_wfd.fd, "+OK Stunnel capability list follows");
fd_putline(c, c->local_wfd.fd, "STLS"); fd_putline(c, c->local_wfd.fd, "STLS");
fd_putline(c, c->local_wfd.fd, "."); fd_putline(c, c->local_wfd.fd, ".");
str_free(line);
line=fd_getline(c, c->local_rfd.fd); line=fd_getline(c, c->local_rfd.fd);
} }
if(!isprefix(line, "STLS")) { if(!is_prefix(line, "STLS")) {
s_log(LOG_ERR, "Client does not want TLS"); s_log(LOG_ERR, "Client does not want TLS");
str_free(line);
longjmp(c->err, 1); longjmp(c->err, 1);
} }
str_free(line);
fd_putline(c, c->local_wfd.fd, "+OK Stunnel starts TLS negotiation"); fd_putline(c, c->local_wfd.fd, "+OK Stunnel starts TLS negotiation");
} }
@ -352,24 +375,28 @@ static void imap_client(CLI *c) {
char *line; char *line;
line=fd_getline(c, c->remote_fd.fd); line=fd_getline(c, c->remote_fd.fd);
if(!isprefix(line, "* OK")) { if(!is_prefix(line, "* OK")) {
s_log(LOG_ERR, "Unknown server welcome"); s_log(LOG_ERR, "Unknown server welcome");
str_free(line);
longjmp(c->err, 1); longjmp(c->err, 1);
} }
fd_putline(c, c->local_wfd.fd, line); fd_putline(c, c->local_wfd.fd, line);
fd_putline(c, c->remote_fd.fd, "stunnel STARTTLS"); fd_putline(c, c->remote_fd.fd, "stunnel STARTTLS");
str_free(line);
line=fd_getline(c, c->remote_fd.fd); line=fd_getline(c, c->remote_fd.fd);
if(!isprefix(line, "stunnel OK")) { if(!is_prefix(line, "stunnel OK")) {
fd_putline(c, c->local_wfd.fd, fd_putline(c, c->local_wfd.fd,
"* BYE stunnel: Server does not support TLS"); "* BYE stunnel: Server does not support TLS");
s_log(LOG_ERR, "Server does not support TLS"); s_log(LOG_ERR, "Server does not support TLS");
str_free(line);
longjmp(c->err, 2); /* don't reset */ longjmp(c->err, 2); /* don't reset */
} }
str_free(line);
} }
static void imap_server(CLI *c) { static void imap_server(CLI *c) {
char *line, *id, *tail, *capa; char *line, *id, *tail, *capa;
s_poll_init(c->fds); s_poll_init(c->fds);
s_poll_add(c->fds, c->local_rfd.fd, 1, 0); s_poll_add(c->fds, c->local_rfd.fd, 1, 0);
switch(s_poll_wait(c->fds, 0, 200)) { switch(s_poll_wait(c->fds, 0, 200)) {
@ -386,8 +413,9 @@ static void imap_server(CLI *c) {
/* process server welcome and send it to client */ /* process server welcome and send it to client */
line=fd_getline(c, c->remote_fd.fd); line=fd_getline(c, c->remote_fd.fd);
if(!isprefix(line, "* OK")) { if(!is_prefix(line, "* OK")) {
s_log(LOG_ERR, "Unknown server welcome"); s_log(LOG_ERR, "Unknown server welcome");
str_free(line);
longjmp(c->err, 1); longjmp(c->err, 1);
} }
capa=strstr(line, "CAPABILITY"); capa=strstr(line, "CAPABILITY");
@ -397,41 +425,48 @@ static void imap_server(CLI *c) {
*capa='K'; /* disable CAPABILITY within greeting */ *capa='K'; /* disable CAPABILITY within greeting */
fd_printf(c, c->local_wfd.fd, "%s (stunnel)", line); fd_printf(c, c->local_wfd.fd, "%s (stunnel)", line);
id=str_dup("");
while(1) { /* process client commands */ while(1) { /* process client commands */
str_free(line);
line=fd_getline(c, c->local_rfd.fd); line=fd_getline(c, c->local_rfd.fd);
/* split line into id and tail */ /* split line into id and tail */
str_free(id);
id=str_dup(line); id=str_dup(line);
tail=strchr(id, ' '); tail=strchr(id, ' ');
if(!tail) if(!tail)
break; break;
*tail++='\0'; *tail++='\0';
if(isprefix(tail, "STARTTLS")) { if(is_prefix(tail, "STARTTLS")) {
fd_printf(c, c->local_wfd.fd, fd_printf(c, c->local_wfd.fd,
"%s OK Begin TLS negotiation now", id); "%s OK Begin TLS negotiation now", id);
str_free(line);
str_free(id);
return; /* success */ return; /* success */
} else if(isprefix(tail, "CAPABILITY")) { } else if(is_prefix(tail, "CAPABILITY")) {
fd_putline(c, c->remote_fd.fd, line); /* send it to server */ fd_putline(c, c->remote_fd.fd, line); /* send it to server */
str_free(line);
line=fd_getline(c, c->remote_fd.fd); /* get the capabilites */ line=fd_getline(c, c->remote_fd.fd); /* get the capabilites */
if(*line=='*') { if(*line=='*') {
/* /*
* append STARTTLS * append STARTTLS
* should also add LOGINDISABLED, but can't because * should also add LOGINDISABLED, but can't because
* of Mozilla bug #324138/#312009 * of Mozilla bug #324138/#312009
* LOGIN would fail as "unexpected command", anyway * LOGIN would fail as "unexpected command", anyway
*/ */
fd_printf(c, c->local_wfd.fd, "%s STARTTLS", line); fd_printf(c, c->local_wfd.fd, "%s STARTTLS", line);
str_free(line);
line=fd_getline(c, c->remote_fd.fd); /* next line */ line=fd_getline(c, c->remote_fd.fd); /* next line */
} }
fd_putline(c, c->local_wfd.fd, line); /* forward to the client */ fd_putline(c, c->local_wfd.fd, line); /* forward to the client */
tail=strchr(line, ' '); tail=strchr(line, ' ');
if(!tail || !isprefix(tail+1, "OK")) { /* not OK? */ if(!tail || !is_prefix(tail+1, "OK")) { /* not OK? */
fd_putline(c, c->local_wfd.fd, fd_putline(c, c->local_wfd.fd,
"* BYE unexpected server response"); "* BYE unexpected server response");
s_log(LOG_ERR, "Unexpected server response: %s", line); s_log(LOG_ERR, "Unexpected server response: %s", line);
break; break;
} }
} else if(isprefix(tail, "LOGOUT")) { } else if(is_prefix(tail, "LOGOUT")) {
fd_putline(c, c->local_wfd.fd, "* BYE server terminating"); fd_putline(c, c->local_wfd.fd, "* BYE server terminating");
fd_printf(c, c->local_wfd.fd, "%s OK LOGOUT completed", id); fd_printf(c, c->local_wfd.fd, "%s OK LOGOUT completed", id);
break; break;
@ -441,12 +476,17 @@ static void imap_server(CLI *c) {
s_log(LOG_ERR, "Unexpected client command %s", tail); s_log(LOG_ERR, "Unexpected client command %s", tail);
break; break;
} }
} }
/* clean server shutdown */ /* clean server shutdown */
str_free(id);
fd_putline(c, c->remote_fd.fd, "stunnel LOGOUT"); fd_putline(c, c->remote_fd.fd, "stunnel LOGOUT");
str_free(line);
line=fd_getline(c, c->remote_fd.fd); line=fd_getline(c, c->remote_fd.fd);
if(*line=='*') if(*line=='*') {
str_free(line);
line=fd_getline(c, c->remote_fd.fd); line=fd_getline(c, c->remote_fd.fd);
}
str_free(line);
longjmp(c->err, 2); /* don't reset */ longjmp(c->err, 2); /* don't reset */
} }
@ -456,49 +496,61 @@ static void nntp_client(CLI *c) {
char *line; char *line;
line=fd_getline(c, c->remote_fd.fd); line=fd_getline(c, c->remote_fd.fd);
if(!isprefix(line, "200 ") && !isprefix(line, "201 ")) { if(!is_prefix(line, "200 ") && !is_prefix(line, "201 ")) {
s_log(LOG_ERR, "Unknown server welcome"); s_log(LOG_ERR, "Unknown server welcome");
str_free(line);
longjmp(c->err, 1); longjmp(c->err, 1);
} }
fd_putline(c, c->local_wfd.fd, line); fd_putline(c, c->local_wfd.fd, line);
fd_putline(c, c->remote_fd.fd, "STARTTLS"); fd_putline(c, c->remote_fd.fd, "STARTTLS");
str_free(line);
line=fd_getline(c, c->remote_fd.fd); line=fd_getline(c, c->remote_fd.fd);
if(!isprefix(line, "382 ")) { if(!is_prefix(line, "382 ")) {
s_log(LOG_ERR, "Server does not support TLS"); s_log(LOG_ERR, "Server does not support TLS");
str_free(line);
longjmp(c->err, 1); longjmp(c->err, 1);
} }
str_free(line);
} }
/**************************************** connect */ /**************************************** connect */
static void connect_server(CLI *c) { static void connect_server(CLI *c) {
char *request, *proto, *header; char *request, *proto, *header;
int not_empty; NAME_LIST host_list;
request=fd_getline(c, c->local_rfd.fd); request=fd_getline(c, c->local_rfd.fd);
if(!isprefix(request, "CONNECT ")) { if(!is_prefix(request, "CONNECT ")) {
fd_putline(c, c->local_wfd.fd, "HTTP/1.0 400 Bad Request Method"); fd_putline(c, c->local_wfd.fd, "HTTP/1.0 400 Bad Request Method");
fd_putline(c, c->local_wfd.fd, "Server: stunnel/" STUNNEL_VERSION); fd_putline(c, c->local_wfd.fd, "Server: stunnel/" STUNNEL_VERSION);
fd_putline(c, c->local_wfd.fd, ""); fd_putline(c, c->local_wfd.fd, "");
str_free(request);
longjmp(c->err, 1); longjmp(c->err, 1);
} }
proto=strchr(request+8, ' '); proto=strchr(request+8, ' ');
if(!proto || !isprefix(proto, " HTTP/")) { if(!proto || !is_prefix(proto, " HTTP/")) {
fd_putline(c, c->local_wfd.fd, "HTTP/1.0 400 Bad Request Protocol"); fd_putline(c, c->local_wfd.fd, "HTTP/1.0 400 Bad Request Protocol");
fd_putline(c, c->local_wfd.fd, "Server: stunnel/" STUNNEL_VERSION); fd_putline(c, c->local_wfd.fd, "Server: stunnel/" STUNNEL_VERSION);
fd_putline(c, c->local_wfd.fd, ""); fd_putline(c, c->local_wfd.fd, "");
str_free(request);
longjmp(c->err, 1); longjmp(c->err, 1);
} }
*proto='\0'; *proto='\0';
do { /* ignore any headers*/
header=fd_getline(c, c->local_rfd.fd); header=str_dup("");
not_empty=*header; do { /* ignore any headers */
str_free(header); str_free(header);
} while(not_empty); header=fd_getline(c, c->local_rfd.fd);
if(!name2addrlist(&c->connect_addr, request+8, DEFAULT_LOOPBACK)) { } while(*header); /* not empty */
str_free(header);
host_list.name=request+8;
host_list.next=NULL;
if(!namelist2addrlist(&c->connect_addr, &host_list, DEFAULT_LOOPBACK)) {
fd_putline(c, c->local_wfd.fd, "HTTP/1.0 404 Not Found"); fd_putline(c, c->local_wfd.fd, "HTTP/1.0 404 Not Found");
fd_putline(c, c->local_wfd.fd, "Server: stunnel/" STUNNEL_VERSION); fd_putline(c, c->local_wfd.fd, "Server: stunnel/" STUNNEL_VERSION);
fd_putline(c, c->local_wfd.fd, ""); fd_putline(c, c->local_wfd.fd, "");
str_free(request);
longjmp(c->err, 1); longjmp(c->err, 1);
} }
str_free(request); str_free(request);
@ -541,23 +593,27 @@ static void connect_client(CLI *c) {
} }
fd_putline(c, c->remote_fd.fd, ""); /* empty line */ fd_putline(c, c->remote_fd.fd, ""); /* empty line */
line=fd_getline(c, c->remote_fd.fd); line=fd_getline(c, c->remote_fd.fd);
if(strlen(line)<12 || line[9]!='2') { if(!is_prefix(line, "HTTP/1.0 2") && !is_prefix(line, "HTTP/1.1 2")) {
/* not "HTTP/1.0 200 Connection established" */ /* not "HTTP/1.x 2xx Connection established" */
s_log(LOG_ERR, "CONNECT request rejected"); s_log(LOG_ERR, "CONNECT request rejected");
do { /* read all headers */ do { /* read all headers */
str_free(line);
line=fd_getline(c, c->remote_fd.fd); line=fd_getline(c, c->remote_fd.fd);
} while(*line); } while(*line);
str_free(line);
longjmp(c->err, 1); longjmp(c->err, 1);
} }
s_log(LOG_INFO, "CONNECT request accepted"); s_log(LOG_INFO, "CONNECT request accepted");
do { do {
str_free(line);
line=fd_getline(c, c->remote_fd.fd); /* read all headers */ line=fd_getline(c, c->remote_fd.fd); /* read all headers */
} while(*line); } while(*line);
str_free(line);
} }
#if !defined(OPENSSL_NO_MD4) && OPENSSL_VERSION_NUMBER>=0x0090700fL #if !defined(OPENSSL_NO_MD4) && OPENSSL_VERSION_NUMBER>=0x0090700fL
/* /*
* NTLM code is based on the following documentation: * NTLM code is based on the following documentation:
* http://davenport.sourceforge.net/ntlm.html * http://davenport.sourceforge.net/ntlm.html
* http://www.innovation.ch/personal/ronald/ntlm.html * http://www.innovation.ch/personal/ronald/ntlm.html
@ -566,7 +622,7 @@ static void connect_client(CLI *c) {
#define s_min(a, b) ((a)>(b)?(b):(a)) #define s_min(a, b) ((a)>(b)?(b):(a))
static void ntlm(CLI *c) { static void ntlm(CLI *c) {
char *line, buf[BUFSIZ], *ntlm1_txt, *ntlm2_txt, *ntlm3_txt; char *line, buf[BUFSIZ], *ntlm1_txt, *ntlm2_txt, *ntlm3_txt, *tmpstr;
long content_length=0; /* no HTTP content */ long content_length=0; /* no HTTP content */
/* send Proxy-Authorization (phase 1) */ /* send Proxy-Authorization (phase 1) */
@ -582,28 +638,38 @@ static void ntlm(CLI *c) {
line=fd_getline(c, c->remote_fd.fd); line=fd_getline(c, c->remote_fd.fd);
/* receive Proxy-Authenticate (phase 2) */ /* receive Proxy-Authenticate (phase 2) */
if(line[9]!='4' || line[10]!='0' || line[11]!='7') { /* code 407 */ if(!is_prefix(line, "HTTP/1.0 407") && !is_prefix(line, "HTTP/1.1 407")) {
s_log(LOG_ERR, "NTLM authorization request rejected"); s_log(LOG_ERR, "Proxy-Authenticate: NTLM authorization request rejected");
do { /* read all headers */ do { /* read all headers */
str_free(line);
line=fd_getline(c, c->remote_fd.fd); line=fd_getline(c, c->remote_fd.fd);
} while(*line); } while(*line);
str_free(line);
longjmp(c->err, 1); longjmp(c->err, 1);
} }
ntlm2_txt=NULL; ntlm2_txt=NULL;
do { /* read all headers */ do { /* read all headers */
str_free(line);
line=fd_getline(c, c->remote_fd.fd); line=fd_getline(c, c->remote_fd.fd);
if(isprefix(line, "Proxy-Authenticate: NTLM ")) if(is_prefix(line, "Proxy-Authenticate: NTLM "))
ntlm2_txt=str_dup(line+25); ntlm2_txt=str_dup(line+25);
else if(isprefix(line, "Content-Length: ")) else if(is_prefix(line, "Content-Length: ")) {
content_length=atol(line+16); content_length=strtol(line+16, &tmpstr, 10);
if(tmpstr==line+16 || *tmpstr || content_length<0) {
s_log(LOG_ERR, "Proxy-Authenticate: Invalid Content-Length");
str_free(line);
longjmp(c->err, 1);
}
}
} while(*line); } while(*line);
if(!ntlm2_txt) { /* no Proxy-Authenticate: NTLM header */ if(!ntlm2_txt) { /* no Proxy-Authenticate: NTLM header */
s_log(LOG_ERR, "Proxy-Authenticate: NTLM header not found"); s_log(LOG_ERR, "Proxy-Authenticate: NTLM header not found");
str_free(line);
longjmp(c->err, 1); longjmp(c->err, 1);
} }
/* read and ignore HTTP content (if any) */ /* read and ignore HTTP content (if any) */
while(content_length) { while(content_length>0) {
read_blocking(c, c->remote_fd.fd, buf, s_min(content_length, BUFSIZ)); read_blocking(c, c->remote_fd.fd, buf, s_min(content_length, BUFSIZ));
content_length-=s_min(content_length, BUFSIZ); content_length-=s_min(content_length, BUFSIZ);
} }

View File

@ -1,6 +1,6 @@
/* /*
* stunnel Universal SSL tunnel * stunnel Universal SSL tunnel
* Copyright (C) 1998-2012 Michal Trojnara <Michal.Trojnara@mirt.net> * Copyright (C) 1998-2013 Michal Trojnara <Michal.Trojnara@mirt.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
@ -60,6 +60,11 @@ typedef union sockaddr_union {
#endif #endif
} SOCKADDR_UNION; } SOCKADDR_UNION;
typedef struct name_list_struct {
char *name;
struct name_list_struct *next;
} NAME_LIST;
typedef struct sockaddr_list { /* list of addresses */ typedef struct sockaddr_list { /* list of addresses */
SOCKADDR_UNION *addr; /* the list of addresses */ SOCKADDR_UNION *addr; /* the list of addresses */
u16 cur; /* current address for round-robin */ u16 cur; /* current address for round-robin */
@ -146,7 +151,7 @@ typedef struct service_options_struct {
char *cipher_list; char *cipher_list;
char *cert; /* cert filename */ char *cert; /* cert filename */
char *key; /* pem (priv key/cert) filename */ char *key; /* pem (priv key/cert) filename */
long session_timeout; long session_size, session_timeout;
long ssl_options; long ssl_options;
SSL_METHOD *client_method, *server_method; SSL_METHOD *client_method, *server_method;
SOCKADDR_UNION sessiond_addr; SOCKADDR_UNION sessiond_addr;
@ -173,7 +178,7 @@ typedef struct service_options_struct {
SOCKADDR_UNION local_addr, source_addr; SOCKADDR_UNION local_addr, source_addr;
SOCKADDR_LIST connect_addr; SOCKADDR_LIST connect_addr;
char *username; char *username;
char *connect_name; NAME_LIST *connect_list;
int timeout_busy; /* maximum waiting for data time */ int timeout_busy; /* maximum waiting for data time */
int timeout_close; /* maximum close_notify time */ int timeout_close; /* maximum close_notify time */
int timeout_connect; /* maximum connect() time */ int timeout_connect; /* maximum connect() time */
@ -190,8 +195,8 @@ typedef struct service_options_struct {
/* service-specific data for gui.c */ /* service-specific data for gui.c */
#ifdef USE_WIN32 #ifdef USE_WIN32
int section_number; int section_number;
LPTSTR file, help; LPTSTR file;
char *chain; char *help, *chain;
#endif #endif
/* on/off switches */ /* on/off switches */
@ -218,6 +223,8 @@ typedef struct service_options_struct {
#ifdef HAVE_OSSL_OCSP_H #ifdef HAVE_OSSL_OCSP_H
unsigned int ocsp:1; unsigned int ocsp:1;
#endif #endif
unsigned int reset:1; /* reset sockets on error */
unsigned int renegotiation:1;
} option; } option;
} SERVICE_OPTIONS; } SERVICE_OPTIONS;
@ -322,7 +329,7 @@ void set_nonblock(int, unsigned long);
void syslog_open(void); void syslog_open(void);
void syslog_close(void); void syslog_close(void);
#endif #endif
void log_open(void); int log_open(void);
void log_close(void); void log_close(void);
void log_flush(LOG_MODE); void log_flush(LOG_MODE);
void s_log(int, const char *, ...) void s_log(int, const char *, ...)
@ -377,7 +384,8 @@ void s_poll_init(s_poll_set *);
void s_poll_add(s_poll_set *, int, int, int); void s_poll_add(s_poll_set *, int, int, int);
int s_poll_canread(s_poll_set *, int); int s_poll_canread(s_poll_set *, int);
int s_poll_canwrite(s_poll_set *, int); int s_poll_canwrite(s_poll_set *, int);
int s_poll_error(s_poll_set *, FD *); int s_poll_hup(s_poll_set *, int);
int s_poll_error(s_poll_set *, int);
int s_poll_wait(s_poll_set *, int, int); int s_poll_wait(s_poll_set *, int, int);
#ifdef USE_WIN32 #ifdef USE_WIN32
@ -391,11 +399,16 @@ int s_poll_wait(s_poll_set *, int, int);
#endif #endif
int set_socket_options(int, int); int set_socket_options(int, int);
int get_socket_error(const int);
int make_sockets(int [2]); int make_sockets(int [2]);
/**************************************** prototypes for client.c */ /**************************************** prototypes for client.c */
typedef enum {
RENEG_INIT, /* initial state */
RENEG_ESTABLISHED, /* initial handshake completed */
RENEG_DETECTED /* renegotiation detected */
} RENEG_STATE;
typedef struct { typedef struct {
jmp_buf err; /* exception handler needs to be 16-byte aligned on Itanium */ jmp_buf err; /* exception handler needs to be 16-byte aligned on Itanium */
SSL *ssl; /* SSL connnection */ SSL *ssl; /* SSL connnection */
@ -410,6 +423,7 @@ typedef struct {
/* IP for explicit local bind or transparent proxy */ /* IP for explicit local bind or transparent proxy */
unsigned long pid; /* PID of the local process */ unsigned long pid; /* PID of the local process */
int fd; /* temporary file descriptor */ int fd; /* temporary file descriptor */
RENEG_STATE reneg_state; /* used to track renegotiation attempts */
/* data for transfer() function */ /* data for transfer() function */
char sock_buff[BUFFSIZE]; /* socket read buffer */ char sock_buff[BUFFSIZE]; /* socket read buffer */
@ -447,17 +461,17 @@ typedef enum {
PROTOCOL_PRE_CONNECT, PROTOCOL_PRE_CONNECT,
PROTOCOL_PRE_SSL, PROTOCOL_PRE_SSL,
PROTOCOL_POST_SSL PROTOCOL_POST_SSL
} PROTOCOL_TYPE; } PROTOCOL_PHASE;
int find_protocol_id(const char *); int find_protocol_id(const char *);
void protocol(CLI *, const PROTOCOL_TYPE); void protocol(CLI *, const PROTOCOL_PHASE);
/**************************************** prototypes for resolver.c */ /**************************************** prototypes for resolver.c */
void resolver_init();
int name2addr(SOCKADDR_UNION *, char *, char *); int name2addr(SOCKADDR_UNION *, char *, char *);
int hostport2addr(SOCKADDR_UNION *, char *, char *); int hostport2addr(SOCKADDR_UNION *, char *, char *);
int name2addrlist(SOCKADDR_LIST *, char *, char *); int namelist2addrlist(SOCKADDR_LIST *, NAME_LIST *, char *);
int hostport2addrlist(SOCKADDR_LIST *, char *, char *);
char *s_ntop(SOCKADDR_UNION *, socklen_t); char *s_ntop(SOCKADDR_UNION *, socklen_t);
socklen_t addr_len(const SOCKADDR_UNION *); socklen_t addr_len(const SOCKADDR_UNION *);
const char *s_gai_strerror(int); const char *s_gai_strerror(int);
@ -472,9 +486,22 @@ const char *s_gai_strerror(int);
#endif #endif
#ifdef USE_WIN32 #ifdef USE_WIN32
/* rename some locally shadowed declarations */ /* rename some locally shadowed declarations */
#define getnameinfo local_getnameinfo #define getnameinfo local_getnameinfo
#endif /* defined USE_WIN32 */
#ifndef _WIN32_WCE
typedef int (CALLBACK * GETADDRINFO) (const char *,
const char *, const struct addrinfo *, struct addrinfo **);
typedef void (CALLBACK * FREEADDRINFO) (struct addrinfo FAR *);
typedef int (CALLBACK * GETNAMEINFO) (const struct sockaddr *, socklen_t,
char *, size_t, char *, size_t, int);
extern GETADDRINFO s_getaddrinfo;
extern FREEADDRINFO s_freeaddrinfo;
extern GETNAMEINFO s_getnameinfo;
#endif /* ! _WIN32_WCE */
#endif /* USE_WIN32 */
int getnameinfo(const struct sockaddr *, int, char *, int, char *, int, int); int getnameinfo(const struct sockaddr *, int, char *, int, char *, int, int);
@ -523,23 +550,14 @@ void stack_info(int);
/**************************************** prototypes for gui.c */ /**************************************** prototypes for gui.c */
#ifdef USE_WIN32 #ifdef USE_WIN32
extern HWND hwnd; void message_box(const LPSTR, const UINT);
void win_new_chain(int);
void win_new_log(char *);
void win_new_config(void);
int passwd_cb(char *, int, int, void *); int passwd_cb(char *, int, int, void *);
#ifdef HAVE_OSSL_ENGINE_H #ifdef HAVE_OSSL_ENGINE_H
int pin_cb(UI *, UI_STRING *); int pin_cb(UI *, UI_STRING *);
#endif #endif
#ifndef _WIN32_WCE
typedef int (CALLBACK * GETADDRINFO) (const char *,
const char *, const struct addrinfo *, struct addrinfo **);
typedef void (CALLBACK * FREEADDRINFO) (struct addrinfo FAR *);
typedef int (CALLBACK * GETNAMEINFO) (const struct sockaddr *, socklen_t,
char *, size_t, char *, size_t, int);
extern GETADDRINFO s_getaddrinfo;
extern FREEADDRINFO s_freeaddrinfo;
extern GETNAMEINFO s_getnameinfo;
#endif /* ! _WIN32_WCE */
#endif /* USE_WIN32 */ #endif /* USE_WIN32 */
/**************************************** prototypes for file.c */ /**************************************** prototypes for file.c */

View File

@ -1,24 +1,24 @@
/* /*
* stunnel Universal SSL tunnel * stunnel Universal SSL tunnel
* Copyright (C) 1998-2012 Michal Trojnara <Michal.Trojnara@mirt.net> * Copyright (C) 1998-2013 Michal Trojnara <Michal.Trojnara@mirt.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your * Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with this program; if not, see <http://www.gnu.org/licenses>. * with this program; if not, see <http://www.gnu.org/licenses>.
* *
* Linking stunnel statically or dynamically with other modules is making * Linking stunnel statically or dynamically with other modules is making
* a combined work based on stunnel. Thus, the terms and conditions of * a combined work based on stunnel. Thus, the terms and conditions of
* the GNU General Public License cover the whole combination. * the GNU General Public License cover the whole combination.
* *
* In addition, as a special exception, the copyright holder of stunnel * In addition, as a special exception, the copyright holder of stunnel
* gives you permission to combine stunnel with free software programs or * gives you permission to combine stunnel with free software programs or
* libraries that are released under the GNU LGPL and with code included * libraries that are released under the GNU LGPL and with code included
@ -26,7 +26,7 @@
* modified versions of such code, with unchanged license). You may copy * modified versions of such code, with unchanged license). You may copy
* and distribute such a system following the terms of the GNU GPL for * and distribute such a system following the terms of the GNU GPL for
* stunnel and the licenses of the other code concerned. * stunnel and the licenses of the other code concerned.
* *
* Note that people who make modified versions of stunnel are not obligated * Note that people who make modified versions of stunnel are not obligated
* to grant this special exception for their modified versions; it is their * to grant this special exception for their modified versions; it is their
* choice whether to do so. The GNU General Public License gives permission * choice whether to do so. The GNU General Public License gives permission

View File

@ -1,24 +1,24 @@
/* /*
* stunnel Universal SSL tunnel * stunnel Universal SSL tunnel
* Copyright (C) 1998-2012 Michal Trojnara <Michal.Trojnara@mirt.net> * Copyright (C) 1998-2013 Michal Trojnara <Michal.Trojnara@mirt.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your * Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with this program; if not, see <http://www.gnu.org/licenses>. * with this program; if not, see <http://www.gnu.org/licenses>.
* *
* Linking stunnel statically or dynamically with other modules is making * Linking stunnel statically or dynamically with other modules is making
* a combined work based on stunnel. Thus, the terms and conditions of * a combined work based on stunnel. Thus, the terms and conditions of
* the GNU General Public License cover the whole combination. * the GNU General Public License cover the whole combination.
* *
* In addition, as a special exception, the copyright holder of stunnel * In addition, as a special exception, the copyright holder of stunnel
* gives you permission to combine stunnel with free software programs or * gives you permission to combine stunnel with free software programs or
* libraries that are released under the GNU LGPL and with code included * libraries that are released under the GNU LGPL and with code included
@ -26,7 +26,7 @@
* modified versions of such code, with unchanged license). You may copy * modified versions of such code, with unchanged license). You may copy
* and distribute such a system following the terms of the GNU GPL for * and distribute such a system following the terms of the GNU GPL for
* stunnel and the licenses of the other code concerned. * stunnel and the licenses of the other code concerned.
* *
* Note that people who make modified versions of stunnel are not obligated * Note that people who make modified versions of stunnel are not obligated
* to grant this special exception for their modified versions; it is their * to grant this special exception for their modified versions; it is their
* choice whether to do so. The GNU General Public License gives permission * choice whether to do so. The GNU General Public License gives permission
@ -40,6 +40,9 @@
/**************************************** prototypes */ /**************************************** prototypes */
static int name2addrlist(SOCKADDR_LIST *, char *, char *);
static int hostport2addrlist(SOCKADDR_LIST *, char *, char *);
#ifndef HAVE_GETADDRINFO #ifndef HAVE_GETADDRINFO
#ifndef EAI_MEMORY #ifndef EAI_MEMORY
@ -77,6 +80,42 @@ static void freeaddrinfo(struct addrinfo *);
#endif /* !defined HAVE_GETADDRINFO */ #endif /* !defined HAVE_GETADDRINFO */
/**************************************** resolver initialization */
#if defined(USE_WIN32) && !defined(_WIN32_WCE)
GETADDRINFO s_getaddrinfo;
FREEADDRINFO s_freeaddrinfo;
GETNAMEINFO s_getnameinfo;
#endif
void resolver_init() {
#if defined(USE_WIN32) && !defined(_WIN32_WCE)
HINSTANCE handle;
handle=LoadLibrary("ws2_32.dll"); /* IPv6 in Windows XP or higher */
if(handle) {
s_getaddrinfo=(GETADDRINFO)GetProcAddress(handle, "getaddrinfo");
s_freeaddrinfo=(FREEADDRINFO)GetProcAddress(handle, "freeaddrinfo");
s_getnameinfo=(GETNAMEINFO)GetProcAddress(handle, "getnameinfo");
if(s_getaddrinfo && s_freeaddrinfo && s_getnameinfo)
return; /* IPv6 detected -> OK */
FreeLibrary(handle);
}
handle=LoadLibrary("wship6.dll"); /* experimental IPv6 for Windows 2000 */
if(handle) {
s_getaddrinfo=(GETADDRINFO)GetProcAddress(handle, "getaddrinfo");
s_freeaddrinfo=(FREEADDRINFO)GetProcAddress(handle, "freeaddrinfo");
s_getnameinfo=(GETNAMEINFO)GetProcAddress(handle, "getnameinfo");
if(s_getaddrinfo && s_freeaddrinfo && s_getnameinfo)
return; /* IPv6 detected -> OK */
FreeLibrary(handle);
}
s_getaddrinfo=NULL;
s_freeaddrinfo=NULL;
s_getnameinfo=NULL;
#endif
}
/**************************************** stunnel resolver API */ /**************************************** stunnel resolver API */
int name2addr(SOCKADDR_UNION *addr, char *name, char *default_host) { int name2addr(SOCKADDR_UNION *addr, char *name, char *default_host) {
@ -107,7 +146,15 @@ int hostport2addr(SOCKADDR_UNION *addr, char *hostname, char *portname) {
return retval; return retval;
} }
int name2addrlist(SOCKADDR_LIST *addr_list, char *name, char *default_host) { int namelist2addrlist(SOCKADDR_LIST *addr_list, NAME_LIST *name_list, char *default_host) {
/* recursive implementation to reverse the list */
if(!name_list)
return 0;
return namelist2addrlist(addr_list, name_list->next, default_host) +
name2addrlist(addr_list, name_list->name, default_host);
}
static int name2addrlist(SOCKADDR_LIST *addr_list, char *name, char *default_host) {
char *tmp, *hostname, *portname; char *tmp, *hostname, *portname;
int retval; int retval;
@ -146,10 +193,10 @@ int name2addrlist(SOCKADDR_LIST *addr_list, char *name, char *default_host) {
return retval; return retval;
} }
int hostport2addrlist(SOCKADDR_LIST *addr_list, static int hostport2addrlist(SOCKADDR_LIST *addr_list,
char *hostname, char *portname) { char *hostname, char *portname) {
struct addrinfo hints, *res=NULL, *cur; struct addrinfo hints, *res=NULL, *cur;
int err; int err, retries=0;
memset(&hints, 0, sizeof hints); memset(&hints, 0, sizeof hints);
#if defined(USE_IPv6) || defined(USE_WIN32) #if defined(USE_IPv6) || defined(USE_WIN32)
@ -159,15 +206,15 @@ int hostport2addrlist(SOCKADDR_LIST *addr_list,
#endif #endif
hints.ai_socktype=SOCK_STREAM; hints.ai_socktype=SOCK_STREAM;
hints.ai_protocol=IPPROTO_TCP; hints.ai_protocol=IPPROTO_TCP;
do { for(;;) {
err=getaddrinfo(hostname, portname, &hints, &res); err=getaddrinfo(hostname, portname, &hints, &res);
if(err && res) if(err && res)
freeaddrinfo(res); freeaddrinfo(res);
if(err==EAI_AGAIN) { if(err!=EAI_AGAIN || ++retries>=3)
s_log(LOG_DEBUG, "getaddrinfo: EAI_AGAIN received: retrying"); break;
sleep(1); s_log(LOG_DEBUG, "getaddrinfo: EAI_AGAIN received: retrying");
} sleep(1);
} while(err==EAI_AGAIN); }
switch(err) { switch(err) {
case 0: case 0:
break; /* success */ break; /* success */

View File

@ -19,7 +19,7 @@ BEGIN
VALUE "FileDescription", "stunnel - multiplatform SSL tunneling proxy" VALUE "FileDescription", "stunnel - multiplatform SSL tunneling proxy"
VALUE "FileVersion", STUNNEL_VERSION VALUE "FileVersion", STUNNEL_VERSION
VALUE "InternalName", "stunnel" VALUE "InternalName", "stunnel"
VALUE "LegalCopyright", "© by Michal Trojnara, 1998-2012" VALUE "LegalCopyright", "© by Michal Trojnara, 1998-2013"
VALUE "OriginalFilename", "stunnel.exe" VALUE "OriginalFilename", "stunnel.exe"
VALUE "ProductName", STUNNEL_PRODUCTNAME VALUE "ProductName", STUNNEL_PRODUCTNAME
VALUE "ProductVersion", STUNNEL_VERSION VALUE "ProductVersion", STUNNEL_VERSION
@ -90,7 +90,7 @@ BEGIN
ICON IDI_MYICON, -1, 9, 8, 18, 20 ICON IDI_MYICON, -1, 9, 8, 18, 20
LTEXT "stunnel version", -1, 30, 4, 52, 8 LTEXT "stunnel version", -1, 30, 4, 52, 8
LTEXT STUNNEL_VERSION, -1, 82, 4, 54, 8 LTEXT STUNNEL_VERSION, -1, 82, 4, 54, 8
LTEXT "© by Michal Trojnara, 1998-2012", -1, 30, 12, 106, 8 LTEXT "© by Michal Trojnara, 1998-2013", -1, 30, 12, 106, 8
LTEXT "All Rights Reserved", -1, 30, 20, 106, 8 LTEXT "All Rights Reserved", -1, 30, 20, 106, 8
LTEXT "Licensed under the GNU GPL version 2", -1, 4, 28, 132, 8 LTEXT "Licensed under the GNU GPL version 2", -1, 4, 28, 132, 8
LTEXT "with a special exception for OpenSSL", -1, 4, 36, 132, 8 LTEXT "with a special exception for OpenSSL", -1, 4, 36, 132, 8

View File

@ -1,24 +1,24 @@
/* /*
* stunnel Universal SSL tunnel * stunnel Universal SSL tunnel
* Copyright (C) 1998-2012 Michal Trojnara <Michal.Trojnara@mirt.net> * Copyright (C) 1998-2013 Michal Trojnara <Michal.Trojnara@mirt.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your * Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with this program; if not, see <http://www.gnu.org/licenses>. * with this program; if not, see <http://www.gnu.org/licenses>.
* *
* Linking stunnel statically or dynamically with other modules is making * Linking stunnel statically or dynamically with other modules is making
* a combined work based on stunnel. Thus, the terms and conditions of * a combined work based on stunnel. Thus, the terms and conditions of
* the GNU General Public License cover the whole combination. * the GNU General Public License cover the whole combination.
* *
* In addition, as a special exception, the copyright holder of stunnel * In addition, as a special exception, the copyright holder of stunnel
* gives you permission to combine stunnel with free software programs or * gives you permission to combine stunnel with free software programs or
* libraries that are released under the GNU LGPL and with code included * libraries that are released under the GNU LGPL and with code included
@ -26,7 +26,7 @@
* modified versions of such code, with unchanged license). You may copy * modified versions of such code, with unchanged license). You may copy
* and distribute such a system following the terms of the GNU GPL for * and distribute such a system following the terms of the GNU GPL for
* stunnel and the licenses of the other code concerned. * stunnel and the licenses of the other code concerned.
* *
* Note that people who make modified versions of stunnel are not obligated * Note that people who make modified versions of stunnel are not obligated
* to grant this special exception for their modified versions; it is their * to grant this special exception for their modified versions; it is their
* choice whether to do so. The GNU General Public License gives permission * choice whether to do so. The GNU General Public License gives permission
@ -225,15 +225,15 @@ static int add_rand_file(GLOBAL_OPTIONS *global, const char *filename) {
struct stat sb; struct stat sb;
if(stat(filename, &sb)) if(stat(filename, &sb))
return 0; /* could not stat() file -> return 0 bytes */ return 0; /* could not stat() file --> return 0 bytes */
if((readbytes=RAND_load_file(filename, global->random_bytes))) if((readbytes=RAND_load_file(filename, global->random_bytes)))
s_log(LOG_DEBUG, "Snagged %d random bytes from %s", s_log(LOG_DEBUG, "Snagged %d random bytes from %s",
readbytes, filename); readbytes, filename);
else else
s_log(LOG_INFO, "Unable to retrieve any random data from %s", s_log(LOG_INFO, "Cannot retrieve any random data from %s",
filename); filename);
/* write new random data for future seeding if it's a regular file */ /* write new random data for future seeding if it's a regular file */
if(global->option.rand_write && (sb.st_mode & S_IFREG)){ if(global->option.rand_write && (sb.st_mode & S_IFREG)) {
writebytes=RAND_write_file(filename); writebytes=RAND_write_file(filename);
if(writebytes==-1) if(writebytes==-1)
s_log(LOG_WARNING, "Failed to write strong random data to %s - " s_log(LOG_WARNING, "Failed to write strong random data to %s - "

View File

@ -1,24 +1,24 @@
/* /*
* stunnel Universal SSL tunnel * stunnel Universal SSL tunnel
* Copyright (C) 1998-2012 Michal Trojnara <Michal.Trojnara@mirt.net> * Copyright (C) 1998-2013 Michal Trojnara <Michal.Trojnara@mirt.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your * Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with this program; if not, see <http://www.gnu.org/licenses>. * with this program; if not, see <http://www.gnu.org/licenses>.
* *
* Linking stunnel statically or dynamically with other modules is making * Linking stunnel statically or dynamically with other modules is making
* a combined work based on stunnel. Thus, the terms and conditions of * a combined work based on stunnel. Thus, the terms and conditions of
* the GNU General Public License cover the whole combination. * the GNU General Public License cover the whole combination.
* *
* In addition, as a special exception, the copyright holder of stunnel * In addition, as a special exception, the copyright holder of stunnel
* gives you permission to combine stunnel with free software programs or * gives you permission to combine stunnel with free software programs or
* libraries that are released under the GNU LGPL and with code included * libraries that are released under the GNU LGPL and with code included
@ -26,7 +26,7 @@
* modified versions of such code, with unchanged license). You may copy * modified versions of such code, with unchanged license). You may copy
* and distribute such a system following the terms of the GNU GPL for * and distribute such a system following the terms of the GNU GPL for
* stunnel and the licenses of the other code concerned. * stunnel and the licenses of the other code concerned.
* *
* Note that people who make modified versions of stunnel are not obligated * Note that people who make modified versions of stunnel are not obligated
* to grant this special exception for their modified versions; it is their * to grant this special exception for their modified versions; it is their
* choice whether to do so. The GNU General Public License gives permission * choice whether to do so. The GNU General Public License gives permission
@ -112,7 +112,7 @@ static CONTEXT *new_context(void) {
int sthreads_init(void) { int sthreads_init(void) {
/* create the first (listening) context and put it in the running queue */ /* create the first (listening) context and put it in the running queue */
if(!new_context()) { if(!new_context()) {
s_log(LOG_ERR, "Unable create the listening context"); s_log(LOG_ERR, "Cannot create the listening context");
return 1; return 1;
} }
/* no need to initialize ucontext_t structure here /* no need to initialize ucontext_t structure here
@ -124,7 +124,7 @@ int create_client(int ls, int s, CLI *arg, void *(*cli)(void *)) {
CONTEXT *context; CONTEXT *context;
(void)ls; /* this parameter is only used with USE_FORK */ (void)ls; /* this parameter is only used with USE_FORK */
s_log(LOG_DEBUG, "Creating a new context"); s_log(LOG_DEBUG, "Creating a new context");
context=new_context(); context=new_context();
if(!context) { if(!context) {

View File

@ -1,24 +1,24 @@
/* /*
* stunnel Universal SSL tunnel * stunnel Universal SSL tunnel
* Copyright (C) 1998-2012 Michal Trojnara <Michal.Trojnara@mirt.net> * Copyright (C) 1998-2013 Michal Trojnara <Michal.Trojnara@mirt.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your * Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with this program; if not, see <http://www.gnu.org/licenses>. * with this program; if not, see <http://www.gnu.org/licenses>.
* *
* Linking stunnel statically or dynamically with other modules is making * Linking stunnel statically or dynamically with other modules is making
* a combined work based on stunnel. Thus, the terms and conditions of * a combined work based on stunnel. Thus, the terms and conditions of
* the GNU General Public License cover the whole combination. * the GNU General Public License cover the whole combination.
* *
* In addition, as a special exception, the copyright holder of stunnel * In addition, as a special exception, the copyright holder of stunnel
* gives you permission to combine stunnel with free software programs or * gives you permission to combine stunnel with free software programs or
* libraries that are released under the GNU LGPL and with code included * libraries that are released under the GNU LGPL and with code included
@ -26,7 +26,7 @@
* modified versions of such code, with unchanged license). You may copy * modified versions of such code, with unchanged license). You may copy
* and distribute such a system following the terms of the GNU GPL for * and distribute such a system following the terms of the GNU GPL for
* stunnel and the licenses of the other code concerned. * stunnel and the licenses of the other code concerned.
* *
* Note that people who make modified versions of stunnel are not obligated * Note that people who make modified versions of stunnel are not obligated
* to grant this special exception for their modified versions; it is their * to grant this special exception for their modified versions; it is their
* choice whether to do so. The GNU General Public License gives permission * choice whether to do so. The GNU General Public License gives permission
@ -172,7 +172,7 @@ static ALLOC_TLS *get_alloc_tls() {
#ifdef USE_WIN32 #ifdef USE_WIN32
static DWORD tls_index; static DWORD tls_index;
void str_init() { void str_init() {
tls_index=TlsAlloc(); tls_index=TlsAlloc();

View File

@ -1,24 +1,24 @@
/* /*
* stunnel Universal SSL tunnel * stunnel Universal SSL tunnel
* Copyright (C) 1998-2012 Michal Trojnara <Michal.Trojnara@mirt.net> * Copyright (C) 1998-2013 Michal Trojnara <Michal.Trojnara@mirt.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your * Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with this program; if not, see <http://www.gnu.org/licenses>. * with this program; if not, see <http://www.gnu.org/licenses>.
* *
* Linking stunnel statically or dynamically with other modules is making * Linking stunnel statically or dynamically with other modules is making
* a combined work based on stunnel. Thus, the terms and conditions of * a combined work based on stunnel. Thus, the terms and conditions of
* the GNU General Public License cover the whole combination. * the GNU General Public License cover the whole combination.
* *
* In addition, as a special exception, the copyright holder of stunnel * In addition, as a special exception, the copyright holder of stunnel
* gives you permission to combine stunnel with free software programs or * gives you permission to combine stunnel with free software programs or
* libraries that are released under the GNU LGPL and with code included * libraries that are released under the GNU LGPL and with code included
@ -26,7 +26,7 @@
* modified versions of such code, with unchanged license). You may copy * modified versions of such code, with unchanged license). You may copy
* and distribute such a system following the terms of the GNU GPL for * and distribute such a system following the terms of the GNU GPL for
* stunnel and the licenses of the other code concerned. * stunnel and the licenses of the other code concerned.
* *
* Note that people who make modified versions of stunnel are not obligated * Note that people who make modified versions of stunnel are not obligated
* to grant this special exception for their modified versions; it is their * to grant this special exception for their modified versions; it is their
* choice whether to do so. The GNU General Public License gives permission * choice whether to do so. The GNU General Public License gives permission
@ -44,7 +44,11 @@
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-pedantic" #pragma GCC diagnostic ignored "-pedantic"
#endif /* __GNUC__ */ #endif /* __GNUC__ */
#ifdef __GNUC__
#include <../ms/applink.c>
#else /* __GNUC__ */
#include <openssl/applink.c> #include <openssl/applink.c>
#endif /* __GNUC__ */
#ifdef __GNUC__ #ifdef __GNUC__
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif /* __GNUC__ */ #endif /* __GNUC__ */
@ -119,12 +123,16 @@ static int main_unix(int argc, char* argv[]) {
fatal("Could not open /dev/null"); fatal("Could not open /dev/null");
#endif /* standard Unix */ #endif /* standard Unix */
main_initialize(); main_initialize();
if(main_configure(argc>1 ? argv[1] : NULL, argc>2 ? argv[2] : NULL)) if(main_configure(argc>1 ? argv[1] : NULL, argc>2 ? argv[2] : NULL)) {
close(fd);
return 1; return 1;
}
if(service_options.next) { /* there are service sections -> daemon mode */ if(service_options.next) { /* there are service sections -> daemon mode */
#if !defined(__vms) && !defined(USE_OS2) #if !defined(__vms) && !defined(USE_OS2)
if(daemonize(fd)) if(daemonize(fd)) {
close(fd);
return 1; return 1;
}
close(fd); close(fd);
/* create_pid() must be called after drop_privileges() /* create_pid() must be called after drop_privileges()
* or it won't be possible to remove the file on exit */ * or it won't be possible to remove the file on exit */
@ -202,7 +210,8 @@ int main_configure(char *arg1, char *arg2) {
* or logfile rotation won't be possible */ * or logfile rotation won't be possible */
/* log_open() must be be called before daemonize() /* log_open() must be be called before daemonize()
* since daemonize() invalidates stderr */ * since daemonize() invalidates stderr */
log_open(); if(log_open())
return 1;
return 0; return 0;
} }
@ -269,7 +278,9 @@ static int accept_connection(SERVICE_OPTIONS *opt) {
s_log(LOG_DEBUG, "Service [%s] accepted (FD=%d) from %s", s_log(LOG_DEBUG, "Service [%s] accepted (FD=%d) from %s",
opt->servname, s, from_address); opt->servname, s, from_address);
str_free(from_address); str_free(from_address);
#ifndef USE_FORK #ifdef USE_FORK
RAND_add("", 1, 0.0); /* each child needs a unique entropy pool */
#else
if(max_clients && num_clients>=max_clients) { if(max_clients && num_clients>=max_clients) {
s_log(LOG_WARNING, "Connection rejected: too many clients (>=%d)", s_log(LOG_WARNING, "Connection rejected: too many clients (>=%d)",
max_clients); max_clients);
@ -298,7 +309,8 @@ void unbind_ports(void) {
s_poll_init(fds); s_poll_init(fds);
s_poll_add(fds, signal_pipe[0], 1, 0); s_poll_add(fds, signal_pipe[0], 1, 0);
for(opt=service_options.next; opt; opt=opt->next) for(opt=service_options.next; opt; opt=opt->next) {
s_log(LOG_DEBUG, "Closing service [%s]", opt->servname);
if(opt->option.accept && opt->fd>=0) { if(opt->option.accept && opt->fd>=0) {
closesocket(opt->fd); closesocket(opt->fd);
s_log(LOG_DEBUG, "Service [%s] closed (FD=%d)", s_log(LOG_DEBUG, "Service [%s] closed (FD=%d)",
@ -318,7 +330,22 @@ void unbind_ports(void) {
opt->local_addr.un.sun_path); opt->local_addr.un.sun_path);
} }
#endif #endif
} else if(opt->option.program && opt->option.remote) {
/* create exec+connect services */
/* FIXME: this is just a crude workaround */
/* is it better to kill the service? */
opt->option.retry=0;
} }
if(opt->ctx) {
s_log(LOG_DEBUG, "Sessions cached before flush: %ld",
SSL_CTX_sess_number(opt->ctx));
SSL_CTX_flush_sessions(opt->ctx,
(long)time(NULL)+opt->session_timeout+1);
s_log(LOG_DEBUG, "Sessions cached after flush: %ld",
SSL_CTX_sess_number(opt->ctx));
}
s_log(LOG_DEBUG, "Service [%s] closed", opt->servname);
}
} }
/* open new ports, update fds */ /* open new ports, update fds */
@ -375,6 +402,7 @@ int bind_ports(void) {
str_free(local_address); str_free(local_address);
} else if(opt->option.program && opt->option.remote) { } else if(opt->option.program && opt->option.remote) {
/* create exec+connect services */ /* create exec+connect services */
/* FIXME: needs to be delayed on reload with opt->option.retry set */
create_client(-1, -1, create_client(-1, -1,
alloc_client_session(opt, -1, -1), client_thread); alloc_client_session(opt, -1, -1), client_thread);
} }
@ -659,7 +687,7 @@ static void signal_handler(int sig) {
#endif /* !defined(USE_WIN32) && !defined(USE_OS2) */ #endif /* !defined(USE_WIN32) && !defined(USE_OS2) */
/**************************************** log messages to identify build */ /**************************************** log build details */
void stunnel_info(int level) { void stunnel_info(int level) {
s_log(level, "stunnel " STUNNEL_VERSION " on " HOST " platform"); s_log(level, "stunnel " STUNNEL_VERSION " on " HOST " platform");
@ -671,6 +699,7 @@ void stunnel_info(int level) {
s_log(level, "Update OpenSSL shared libraries or rebuild stunnel"); s_log(level, "Update OpenSSL shared libraries or rebuild stunnel");
} }
s_log(level, s_log(level,
"Threading:" "Threading:"
#ifdef USE_UCONTEXT #ifdef USE_UCONTEXT
"UCONTEXT" "UCONTEXT"
@ -685,35 +714,37 @@ void stunnel_info(int level) {
"FORK" "FORK"
#endif #endif
" SSL:"
#if defined HAVE_OSSL_ENGINE_H || defined HAVE_OSSL_OCSP_H || defined USE_FIPS
#ifdef HAVE_OSSL_ENGINE_H
"+ENGINE"
#endif
#ifdef HAVE_OSSL_OCSP_H
"+OCSP"
#endif
#ifdef USE_FIPS
"+FIPS"
#endif
#else
"none"
#endif
" Auth:"
#ifdef USE_LIBWRAP
"LIBWRAP"
#else
"none"
#endif
" Sockets:" " Sockets:"
#ifdef USE_POLL #ifdef USE_POLL
"POLL" "POLL"
#else /* defined(USE_POLL) */ #else /* defined(USE_POLL) */
"SELECT" "SELECT"
#endif /* defined(USE_POLL) */ #endif /* defined(USE_POLL) */
"+IPv%c", ",IPv%c"
#if defined HAVE_OSSL_ENGINE_H || defined HAVE_OSSL_OCSP_H || defined USE_FIPS
" SSL:"
#define ITEM_SEPARATOR ""
#ifdef HAVE_OSSL_ENGINE_H
"ENGINE"
#undef ITEM_SEPARATOR
#define ITEM_SEPARATOR ","
#endif /* defined(HAVE_OSSL_ENGINE_H) */
#ifdef HAVE_OSSL_OCSP_H
ITEM_SEPARATOR "OCSP"
#undef ITEM_SEPARATOR
#define ITEM_SEPARATOR ","
#endif /* HAVE_OSSL_OCSP_H */
#ifdef USE_FIPS
ITEM_SEPARATOR "FIPS"
#endif /* USE_FIPS */
#endif /* an SSL optional feature enabled */
#ifdef USE_LIBWRAP
" Auth:LIBWRAP"
#endif
, /* supported IP version parameter */
#if defined(USE_WIN32) && !defined(_WIN32_WCE) #if defined(USE_WIN32) && !defined(_WIN32_WCE)
s_getaddrinfo ? '6' : '4' s_getaddrinfo ? '6' : '4'
#else /* defined(USE_WIN32) */ #else /* defined(USE_WIN32) */

View File

@ -1,4 +1,4 @@
# vc.mak by Michal Trojnara 1998-2012 # vc.mak by Michal Trojnara 1998-2013
# with help of David Gillingham <dgillingham@gmail.com> # with help of David Gillingham <dgillingham@gmail.com>
# with help of Pierre Delaage <delaage.pierre@free.fr> # with help of Pierre Delaage <delaage.pierre@free.fr>
@ -11,13 +11,20 @@
# modify this to point to your OpenSSL directory # modify this to point to your OpenSSL directory
# either install a precompiled version (*not* the "Light" one) from # either install a precompiled version (*not* the "Light" one) from
# http://www.slproweb.com/products/Win32OpenSSL.html # http://www.slproweb.com/products/Win32OpenSSL.html
SSLDIR=C:\OpenSSL-Win32 #SSLDIR=C:\OpenSSL-Win32
INCDIR=$(SSLDIR)\include #INCDIR=$(SSLDIR)\include
LIBDIR=$(SSLDIR)\lib #FIPSDIR=$(SSLDIR)\include
#LIBDIR=$(SSLDIR)\lib
# or compile one yourself # or compile one yourself
#SSLDIR=..\..\openssl-1.0.0f #SSLDIR=..\..\openssl-1.0.1e
#INCDIR=$(SSLDIR)\inc32 #INCDIR=$(SSLDIR)\inc32
#FIPSDIR=$(SSLDIR)\inc32
#LIBDIR=$(SSLDIR)\out32dll #LIBDIR=$(SSLDIR)\out32dll
# or simply install with "nmake -f ms\ntdll.mak install"
SSLDIR=\usr\local\ssl
INCDIR=$(SSLDIR)\include
FIPSDIR=$(SSLDIR)\fips-2.0\include
LIBDIR=$(SSLDIR)\lib
TARGETCPU=W32 TARGETCPU=W32
SRC=..\src SRC=..\src
@ -26,21 +33,25 @@ OBJ=$(OBJROOT)\$(TARGETCPU)
BINROOT=..\bin BINROOT=..\bin
BIN=$(BINROOT)\$(TARGETCPU) BIN=$(BINROOT)\$(TARGETCPU)
OBJS=$(OBJ)\stunnel.obj $(OBJ)\ssl.obj $(OBJ)\ctx.obj \ SHAREDOBJS=$(OBJ)\stunnel.obj $(OBJ)\ssl.obj $(OBJ)\ctx.obj \
$(OBJ)\verify.obj $(OBJ)\file.obj $(OBJ)\client.obj \ $(OBJ)\verify.obj $(OBJ)\file.obj $(OBJ)\client.obj \
$(OBJ)\protocol.obj $(OBJ)\sthreads.obj $(OBJ)\log.obj \ $(OBJ)\protocol.obj $(OBJ)\sthreads.obj $(OBJ)\log.obj \
$(OBJ)\options.obj $(OBJ)\network.obj $(OBJ)\resolver.obj \ $(OBJ)\options.obj $(OBJ)\network.obj $(OBJ)\resolver.obj \
$(OBJ)\gui.obj $(OBJ)\resources.res $(OBJ)\str.obj $(OBJ)/fd.obj $(OBJ)\str.obj $(OBJ)/fd.obj
GUIOBJS=$(OBJ)\gui.obj $(OBJ)\resources.res
NOGUIOBJS=$(OBJ)\nogui.obj
CC=cl CC=cl
LINK=link LINK=link
CFLAGS=/MD /W3 /O2 /nologo /I"$(INCDIR)" CFLAGS=/MD /W3 /O2 /nologo /I"$(INCDIR)" /I"$(FIPSDIR)"
LDFLAGS=/NOLOGO LDFLAGS=/NOLOGO
LIBS=advapi32.lib comdlg32.lib crypt32.lib gdi32.lib \ SHAREDLIBS=ws2_32.lib user32.lib
psapi.lib shell32.lib user32.lib ws2_32.lib \ GUILIBS=advapi32.lib comdlg32.lib crypt32.lib gdi32.lib \
/LIBPATH:"$(LIBDIR)" libeay32.lib ssleay32.lib psapi.lib shell32.lib
NOGUILIBS=
SSLLIBS=/LIBPATH:"$(LIBDIR)" libeay32.lib ssleay32.lib
# static linking: # static linking:
# /LIBPATH:"$(LIBDIR)\VC\static" libeay32MD.lib ssleay32MD.lib # /LIBPATH:"$(LIBDIR)\VC\static" libeay32MD.lib ssleay32MD.lib
@ -50,15 +61,19 @@ LIBS=advapi32.lib comdlg32.lib crypt32.lib gdi32.lib \
{$(SRC)\}.rc{$(OBJ)\}.res: {$(SRC)\}.rc{$(OBJ)\}.res:
$(RC) -fo$@ -r $< $(RC) -fo$@ -r $<
all: makedirs $(BIN)\stunnel.exe all: makedirs $(BIN)\stunnel.exe $(BIN)\tstunnel.exe
clean: clean:
-@ del $(OBJS) >NUL 2>&1 -@ del $(SHAREDOBJS) >NUL 2>&1
-@ del $(GUIBJS) >NUL 2>&1
-@ del $(NOGUIBJS) >NUL 2>&1
# -@ del *.manifest >NUL 2>&1 # -@ del *.manifest >NUL 2>&1
-@ del $(BIN)\stunnel.exe >NUL 2>&1 -@ del $(BIN)\stunnel.exe >NUL 2>&1
-@ del $(BIN)\stunnel.exe.manifest >NUL 2>&1 -@ del $(BIN)\stunnel.exe.manifest >NUL 2>&1
-@ rmdir $(OBJ) >NUL 2>&1 -@ del $(BIN)\tstunnel.exe >NUL 2>&1
-@ rmdir $(BIN) >NUL 2>&1 -@ del $(BIN)\tstunnel.exe.manifest >NUL 2>&1
-@ rmdir $(OBJ) >NUL 2>&1
-@ rmdir $(BIN) >NUL 2>&1
makedirs: makedirs:
-@ IF NOT EXIST $(OBJROOT) mkdir $(OBJROOT) >NUL 2>&1 -@ IF NOT EXIST $(OBJROOT) mkdir $(OBJROOT) >NUL 2>&1
@ -66,10 +81,17 @@ makedirs:
-@ IF NOT EXIST $(BINROOT) mkdir $(BINROOT) >NUL 2>&1 -@ IF NOT EXIST $(BINROOT) mkdir $(BINROOT) >NUL 2>&1
-@ IF NOT EXIST $(BIN) mkdir $(BIN) >NUL 2>&1 -@ IF NOT EXIST $(BIN) mkdir $(BIN) >NUL 2>&1
$(OBJS): *.h vc.mak $(SHAREDOBJS): *.h vc.mak
$(GUIOBJS): *.h vc.mak
$(NOGUIOBJS): *.h vc.mak
$(BIN)\stunnel.exe: $(OBJS) $(BIN)\stunnel.exe: $(SHAREDOBJS) $(GUIOBJS)
$(LINK) $(LDFLAGS) $(LIBS) /OUT:$@ $** $(LINK) $(LDFLAGS) $(SHAREDLIBS) $(GUILIBS) $(SSLLIBS) /OUT:$@ $**
IF EXIST $@.manifest \
mt -nologo -manifest $@.manifest -outputresource:$@;1
$(BIN)\tstunnel.exe: $(SHAREDOBJS) $(NOGUIOBJS)
$(LINK) $(LDFLAGS) $(SHAREDLIBS) $(NOGUILIBS) $(SSLLIBS) /OUT:$@ $**
IF EXIST $@.manifest \ IF EXIST $@.manifest \
mt -nologo -manifest $@.manifest -outputresource:$@;1 mt -nologo -manifest $@.manifest -outputresource:$@;1

View File

@ -1,24 +1,24 @@
/* /*
* stunnel Universal SSL tunnel * stunnel Universal SSL tunnel
* Copyright (C) 1998-2012 Michal Trojnara <Michal.Trojnara@mirt.net> * Copyright (C) 1998-2013 Michal Trojnara <Michal.Trojnara@mirt.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your * Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with this program; if not, see <http://www.gnu.org/licenses>. * with this program; if not, see <http://www.gnu.org/licenses>.
* *
* Linking stunnel statically or dynamically with other modules is making * Linking stunnel statically or dynamically with other modules is making
* a combined work based on stunnel. Thus, the terms and conditions of * a combined work based on stunnel. Thus, the terms and conditions of
* the GNU General Public License cover the whole combination. * the GNU General Public License cover the whole combination.
* *
* In addition, as a special exception, the copyright holder of stunnel * In addition, as a special exception, the copyright holder of stunnel
* gives you permission to combine stunnel with free software programs or * gives you permission to combine stunnel with free software programs or
* libraries that are released under the GNU LGPL and with code included * libraries that are released under the GNU LGPL and with code included
@ -26,7 +26,7 @@
* modified versions of such code, with unchanged license). You may copy * modified versions of such code, with unchanged license). You may copy
* and distribute such a system following the terms of the GNU GPL for * and distribute such a system following the terms of the GNU GPL for
* stunnel and the licenses of the other code concerned. * stunnel and the licenses of the other code concerned.
* *
* Note that people who make modified versions of stunnel are not obligated * Note that people who make modified versions of stunnel are not obligated
* to grant this special exception for their modified versions; it is their * to grant this special exception for their modified versions; it is their
* choice whether to do so. The GNU General Public License gives permission * choice whether to do so. The GNU General Public License gives permission
@ -225,7 +225,7 @@ static int cert_check(CLI *c, X509_STORE_CTX *callback_ctx, int preverify_ok) {
if(c->opt->verify_level>=4 && depth>0) { if(c->opt->verify_level>=4 && depth>0) {
s_log(LOG_INFO, "CERT: Invalid CA certificate ignored"); s_log(LOG_INFO, "CERT: Invalid CA certificate ignored");
return 1; /* accept connection */ return 1; /* accept connection */
} else { } else {
s_log(LOG_WARNING, "CERT: Verification error: %s", s_log(LOG_WARNING, "CERT: Verification error: %s",
X509_verify_cert_error_string( X509_verify_cert_error_string(
X509_STORE_CTX_get_error(callback_ctx))); X509_STORE_CTX_get_error(callback_ctx)));

View File

@ -1,6 +1,6 @@
/* /*
* stunnel Universal SSL tunnel * stunnel Universal SSL tunnel
* Copyright (C) 1998-2012 Michal Trojnara <Michal.Trojnara@mirt.net> * Copyright (C) 1998-2013 Michal Trojnara <Michal.Trojnara@mirt.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
@ -58,7 +58,7 @@
/* START CUSTOMIZE */ /* START CUSTOMIZE */
#define VERSION_MAJOR 4 #define VERSION_MAJOR 4
#define VERSION_MINOR 53 #define VERSION_MINOR 57
/* END CUSTOMIZE */ /* END CUSTOMIZE */
/* all the following macros are ABSOLUTELY NECESSARY to have proper string /* all the following macros are ABSOLUTELY NECESSARY to have proper string

View File

@ -1,5 +1,5 @@
# OpenSSL configuration file to create a server certificate # OpenSSL configuration file to create a server certificate
# by Michal Trojnara 1998-2012 # by Michal Trojnara 1998-2013
[ req ] [ req ]
# the default key length is secure and quite fast - do not change it # the default key length is secure and quite fast - do not change it

View File

@ -1,4 +1,4 @@
; Sample stunnel configuration file for Unix by Michal Trojnara 2002-2012 ; Sample stunnel configuration file for Unix by Michal Trojnara 2002-2013
; Some options used here may be inadequate for your particular configuration ; Some options used here may be inadequate for your particular configuration
; This sample file does *not* represent stunnel.conf defaults ; This sample file does *not* represent stunnel.conf defaults
; Please consult the manual for detailed description of available options ; Please consult the manual for detailed description of available options

View File

@ -1,4 +1,4 @@
Copyright (C) 1998-2012 Michal Trojnara Copyright (C) 1998-2013 Michal Trojnara
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

View File

@ -1,182 +1,289 @@
# NSIS stunnel installer by Michal Trojnara 1998-2012 # NSIS stunnel installer by Michal Trojnara 1998-2013
!include "Sections.nsh" !include "Sections.nsh"
Name "stunnel ${VERSION}" !ifndef VERSION
OutFile "stunnel-${VERSION}-installer.exe" !define VERSION 4.57
InstallDir "$PROGRAMFILES\stunnel" !endif
BrandingText "Author: Michal Trojnara"
LicenseData "${SRCDIR}/tools/stunnel.license" !ifndef ZLIBDIR
SetCompressor /SOLID LZMA !define ZLIBDIR zlib-1.2.7
InstallDirRegKey HKLM "Software\NSIS_stunnel" "Install_Dir" !endif
RequestExecutionLevel admin !ifndef OPENSSLDIR
!define OPENSSLDIR openssl-1.0.1e
Page license !endif
Page components
Page directory !addplugindir "plugins/SimpleFC"
Page instfiles !addplugindir "plugins/ShellLink/Plugins"
UninstPage uninstConfirm Name "stunnel ${VERSION}"
UninstPage instfiles OutFile "stunnel-${VERSION}-installer.exe"
InstallDir "$PROGRAMFILES\stunnel"
Section "Stunnel Core Files (required)" BrandingText "Author: Michal Trojnara"
SectionIn RO LicenseData "stunnel.license"
SetOutPath "$INSTDIR" SetCompressor /SOLID LZMA
InstallDirRegKey HKLM "Software\NSIS_stunnel" "Install_Dir"
# stop the service, exit stunnel
ReadRegStr $R0 HKLM \ RequestExecutionLevel admin
"Software\Microsoft\Windows NT\CurrentVersion" CurrentVersion
IfErrors skip_service_stop Page license
ExecWait '"$INSTDIR\stunnel.exe" -stop -quiet' Page components
skip_service_stop: Page directory
# skip if the previously installed stunnel version is older than 4.40 Page instfiles
GetDLLVersion "$INSTDIR\stunnel.exe" $R0 $R1
IfErrors skip_process_exit UninstPage uninstConfirm
ExecWait '"$INSTDIR\stunnel.exe" -exit -quiet' UninstPage instfiles
skip_process_exit:
Section "Stunnel Core Files (required)"
# write files SectionIn RO
SetOverwrite off SetOutPath "$INSTDIR"
File "${SRCDIR}/tools/stunnel.conf"
SetOverwrite on # stop the service, exit stunnel
#File "${DLLS}/*eay32.dll" ReadRegStr $R0 HKLM \
File "${DLLS}/libeay32.dll" "Software\Microsoft\Windows NT\CurrentVersion" CurrentVersion
File "${DLLS}/ssleay32.dll" IfErrors skip_service_stop
File "${DLLS}/zlib1.dll" ExecWait '"$INSTDIR\stunnel.exe" -stop -quiet'
File "${DLLS}/msvcr90.dll" skip_service_stop:
File "${DLLS}/Microsoft.VC90.CRT.manifest" ExecWait '"$INSTDIR\stunnel.exe" -exit -quiet'
File "src/stunnel.exe"
File "${SRCDIR}/doc/stunnel.html" # write files
WriteUninstaller "uninstall.exe" SetOverwrite off
File "stunnel.conf"
# add uninstaller registry entries SetOverwrite on
WriteRegStr HKLM "Software\NSIS_stunnel" "Install_Dir" "$INSTDIR" !cd ".."
WriteRegStr HKLM \ !cd "doc"
"Software\Microsoft\Windows\CurrentVersion\Uninstall\stunnel" \ File "stunnel.html"
"DisplayName" "stunnel" !cd ".."
WriteRegStr HKLM \ !cd "bin"
"Software\Microsoft\Windows\CurrentVersion\Uninstall\stunnel" \ !cd "W32"
"UninstallString" '"$INSTDIR\uninstall.exe"' File "stunnel.exe"
WriteRegDWORD HKLM \ File "stunnel.exe.manifest"
"Software\Microsoft\Windows\CurrentVersion\Uninstall\stunnel" \ !cd ".."
"NoModify" 1 !cd ".."
WriteRegDWORD HKLM \ !cd ".."
"Software\Microsoft\Windows\CurrentVersion\Uninstall\stunnel" \ !cd "${ZLIBDIR}"
"NoRepair" 1 File "zlib1.dll"
SectionEnd File "zlib1.dll.manifest"
!cd ".."
Section "Self-signed Certificate Tools" sectionCA !cd "${OPENSSLDIR}"
SetOutPath "$INSTDIR" !cd "out32dll"
File "*.dll"
# write files File "*.dll.manifest"
File "${DLLS}/openssl.exe" !cd ".."
File "${SRCDIR}/tools/stunnel.cnf" !cd ".."
IfSilent lbl_skip_new_pem !cd "redist"
IfFileExists "$INSTDIR\stunnel.pem" lbl_skip_new_pem File "msvcr90.dll"
ExecWait '"$INSTDIR\openssl.exe" req -new -x509 -days 365 -config stunnel.cnf -out stunnel.pem -keyout stunnel.pem' File "Microsoft.VC90.CRT.manifest"
lbl_skip_new_pem: !cd ".."
SectionEnd !cd "stunnel"
!cd "tools"
Section "Start Menu Shortcuts"
SetShellVarContext all # add firewall rule
CreateDirectory "$SMPROGRAMS\stunnel" SimpleFC::AddApplication "stunnel (GUI Version)" \
"$INSTDIR\stunnel.exe" 0 2 "" 1
# remove old links Pop $0 # returns error(1)/success(0)
Delete "$SMPROGRAMS\stunnel\*.lnk" DetailPrint "SimpleFC::AddApplication: $0"
Delete "$SMPROGRAMS\stunnel\*.url"
# write uninstaller and its registry entries
# main link WriteUninstaller "uninstall.exe"
CreateShortCut "$SMPROGRAMS\stunnel\Run stunnel.lnk" \ WriteRegStr HKLM "Software\NSIS_stunnel" "Install_Dir" "$INSTDIR"
"$INSTDIR\stunnel.exe" "" "$INSTDIR\stunnel.exe" 0 WriteRegStr HKLM \
CreateShortCut "$SMPROGRAMS\stunnel\Exit stunnel.lnk" \ "Software\Microsoft\Windows\CurrentVersion\Uninstall\stunnel" \
"$INSTDIR\stunnel.exe" "-exit" "$INSTDIR\stunnel.exe" 0 "DisplayName" "stunnel"
WriteRegStr HKLM \
# NT service "Software\Microsoft\Windows\CurrentVersion\Uninstall\stunnel" \
ClearErrors "UninstallString" '"$INSTDIR\uninstall.exe"'
ReadRegStr $R0 HKLM \ WriteRegDWORD HKLM \
"Software\Microsoft\Windows NT\CurrentVersion" CurrentVersion "Software\Microsoft\Windows\CurrentVersion\Uninstall\stunnel" \
IfErrors skip_service_links "NoModify" 1
CreateShortCut "$SMPROGRAMS\stunnel\Service install.lnk" \ WriteRegDWORD HKLM \
"$INSTDIR\stunnel.exe" "-install" "$INSTDIR\stunnel.exe" 0 "Software\Microsoft\Windows\CurrentVersion\Uninstall\stunnel" \
CreateShortCut "$SMPROGRAMS\stunnel\Service uninstall.lnk" \ "NoRepair" 1
"$INSTDIR\stunnel.exe" "-uninstall" "$INSTDIR\stunnel.exe" 0 SectionEnd
CreateShortCut "$SMPROGRAMS\stunnel\Service start.lnk" \
"$INSTDIR\stunnel.exe" "-start" "$INSTDIR\stunnel.exe" 0 Section "Self-signed Certificate Tools" sectionCA
CreateShortCut "$SMPROGRAMS\stunnel\Service stop.lnk" \ SetOutPath "$INSTDIR"
"$INSTDIR\stunnel.exe" "-stop" "$INSTDIR\stunnel.exe" 0 !cd ".."
skip_service_links: !cd ".."
!cd "${OPENSSLDIR}"
# edit config file !cd "out32dll"
CreateShortCut "$SMPROGRAMS\stunnel\Edit stunnel.conf.lnk" \ File "openssl.exe"
"notepad.exe" "stunnel.conf" "notepad.exe" 0 File "openssl.exe.manifest"
!cd ".."
# OpenSSL shell !cd ".."
CreateShortCut "$SMPROGRAMS\stunnel\OpenSSL Shell.lnk" \ !cd "stunnel"
"$INSTDIR\openssl.exe" "" "$INSTDIR\openssl.exe" 0 !cd "tools"
File "stunnel.cnf"
# make stunnel.pem IfSilent lbl_skip_new_pem
SectionGetFlags sectionCA $0 IfFileExists "$INSTDIR\stunnel.pem" lbl_skip_new_pem
IntOp $0 $0 & SF_SELECTED ExecWait '"$INSTDIR\openssl.exe" req -new -x509 -days 365 -config stunnel.cnf -out stunnel.pem -keyout stunnel.pem'
IntCmp $0 0 lbl_noCA lbl_skip_new_pem:
CreateShortCut "$SMPROGRAMS\stunnel\Build Self-signed stunnel.pem.lnk" \ SectionEnd
"$INSTDIR\openssl.exe" \
"req -new -x509 -days 365 -config stunnel.cnf -out stunnel.pem -keyout stunnel.pem" Section "Terminal Version of stunnel" sectionTERM
lbl_noCA: SetOutPath "$INSTDIR"
!cd ".."
# help/uninstall !cd "bin"
WriteINIStr "$SMPROGRAMS\stunnel\Manual.url" "InternetShortcut" \ !cd "W32"
"URL" "file://$INSTDIR/stunnel.html" File "tstunnel.exe"
CreateShortCut "$SMPROGRAMS\stunnel\Uninstall stunnel.lnk" \ File "tstunnel.exe.manifest"
"$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 !cd ".."
SectionEnd !cd ".."
!cd "tools"
Section "Desktop Shortcut" # add firewall rule
SetShellVarContext all SimpleFC::AddApplication "stunnel (Terminal Version)" \
Delete "$DESKTOP\stunnel.lnk" "$INSTDIR\tstunnel.exe" 0 2 "" 1
CreateShortCut "$DESKTOP\stunnel.lnk" \ Pop $0 # returns error(1)/success(0)
"$INSTDIR\stunnel.exe" "" "$INSTDIR\stunnel.exe" 0 DetailPrint "SimpleFC::AddApplication: $0"
SectionEnd SectionEnd
Section "Uninstall" Section "Start Menu Shortcuts"
ClearErrors SetShellVarContext all
CreateDirectory "$SMPROGRAMS\stunnel"
# stop and remove the service, exit stunnel
ReadRegStr $R0 HKLM \ # remove old links
"Software\Microsoft\Windows NT\CurrentVersion" CurrentVersion Delete "$SMPROGRAMS\stunnel\*.lnk"
IfErrors skip_service_uninstall Delete "$SMPROGRAMS\stunnel\*.url"
ExecWait '"$INSTDIR\stunnel.exe" -stop -quiet'
ExecWait '"$INSTDIR\stunnel.exe" -uninstall -quiet' # main link
skip_service_uninstall: CreateShortCut "$SMPROGRAMS\stunnel\stunnel GUI Start.lnk" \
ExecWait '"$INSTDIR\stunnel.exe" -exit -quiet' "$INSTDIR\stunnel.exe" "" "$INSTDIR\stunnel.exe" 0
CreateShortCut "$SMPROGRAMS\stunnel\stunnel GUI Stop.lnk" \
# remove stunnel folder "$INSTDIR\stunnel.exe" "-exit" "$INSTDIR\stunnel.exe" 0
Delete "$INSTDIR\stunnel.conf"
Delete "$INSTDIR\stunnel.pem" # tstunnel
Delete "$INSTDIR\stunnel.exe" SectionGetFlags ${sectionTERM} $0
Delete "$INSTDIR\stunnel.cnf" IntOp $0 $0 & ${SF_SELECTED}
Delete "$INSTDIR\openssl.exe" IntCmp $0 0 lbl_noTERM
#Delete "$INSTDIR\*eay32.dll" CreateShortCut "$SMPROGRAMS\stunnel\stunnel Terminal Start.lnk" \
Delete "$INSTDIR\libeay32.dll" "$INSTDIR\tstunnel.exe" "" "$INSTDIR\tstunnel.exe" 0
Delete "$INSTDIR\ssleay32.dll" lbl_noTERM:
Delete "$INSTDIR\zlib1.dll"
Delete "$INSTDIR\msvcr90.dll" # NT service
Delete "$INSTDIR\Microsoft.VC90.CRT.manifest" ClearErrors
Delete "$INSTDIR\stunnel.html" ReadRegStr $R0 HKLM \
Delete "$INSTDIR\uninstall.exe" "Software\Microsoft\Windows NT\CurrentVersion" CurrentVersion
RMDir "$INSTDIR" IfErrors skip_service_links
# remove menu shortcuts CreateShortCut "$SMPROGRAMS\stunnel\stunnel Service Install.lnk" \
SetShellVarContext all "$INSTDIR\stunnel.exe" "-install" "$INSTDIR\stunnel.exe" 0
Delete "$DESKTOP\stunnel.lnk" ShellLink::SetRunAsAdministrator \
Delete "$SMPROGRAMS\stunnel\*.lnk" "$SMPROGRAMS\stunnel\stunnel Service Install.lnk"
Delete "$SMPROGRAMS\stunnel\*.url" Pop $0 # returns error(-1)/success(0)
RMDir "$SMPROGRAMS\stunnel" DetailPrint "ShellLink::SetRunAsAdministrator: $0"
# remove uninstaller registry entires CreateShortCut "$SMPROGRAMS\stunnel\stunnel Service Uninstall.lnk" \
DeleteRegKey HKLM \ "$INSTDIR\stunnel.exe" "-uninstall" "$INSTDIR\stunnel.exe" 0
"Software\Microsoft\Windows\CurrentVersion\Uninstall\stunnel" ShellLink::SetRunAsAdministrator \
DeleteRegKey HKLM "Software\NSIS_stunnel" "$SMPROGRAMS\stunnel\stunnel Service Uninstall.lnk"
SectionEnd Pop $0 # returns error(-1)/success(0)
DetailPrint "ShellLink::SetRunAsAdministrator: $0"
# end of stunnel.nsi
CreateShortCut "$SMPROGRAMS\stunnel\stunnel Service Start.lnk" \
"$INSTDIR\stunnel.exe" "-start" "$INSTDIR\stunnel.exe" 0
ShellLink::SetRunAsAdministrator \
"$SMPROGRAMS\stunnel\stunnel Service Start.lnk"
Pop $0 # returns error(-1)/success(0)
DetailPrint "ShellLink::SetRunAsAdministrator: $0"
CreateShortCut "$SMPROGRAMS\stunnel\stunnel Service Stop.lnk" \
"$INSTDIR\stunnel.exe" "-stop" "$INSTDIR\stunnel.exe" 0
ShellLink::SetRunAsAdministrator \
"$SMPROGRAMS\stunnel\stunnel Service Stop.lnk"
Pop $0 # returns error(-1)/success(0)
DetailPrint "ShellLink::SetRunAsAdministrator: $0"
skip_service_links:
# edit config file
CreateShortCut "$SMPROGRAMS\stunnel\Edit stunnel.conf.lnk" \
"notepad.exe" "$INSTDIR\stunnel.conf" "notepad.exe" 0
ShellLink::SetRunAsAdministrator \
"$SMPROGRAMS\stunnel\Edit stunnel.conf.lnk"
Pop $0 # returns error(-1)/success(0)
DetailPrint "ShellLink::SetRunAsAdministrator: $0"
SectionGetFlags ${sectionCA} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 0 lbl_noCA
# OpenSSL shell
CreateShortCut "$SMPROGRAMS\stunnel\OpenSSL Shell.lnk" \
"$INSTDIR\openssl.exe" "" "$INSTDIR\openssl.exe" 0
# make stunnel.pem
CreateShortCut "$SMPROGRAMS\stunnel\Build Self-signed stunnel.pem.lnk" \
"$INSTDIR\openssl.exe" \
"req -new -x509 -days 365 -config stunnel.cnf -out stunnel.pem -keyout stunnel.pem"
ShellLink::SetRunAsAdministrator \
"$SMPROGRAMS\stunnel\\Build Self-signed stunnel.pem.lnk"
Pop $0 # returns error(-1)/success(0)
DetailPrint "ShellLink::SetRunAsAdministrator: $0"
lbl_noCA:
# help/uninstall
WriteINIStr "$SMPROGRAMS\stunnel\Manual.url" "InternetShortcut" \
"URL" "file://$INSTDIR/stunnel.html"
CreateShortCut "$SMPROGRAMS\stunnel\Uninstall stunnel.lnk" \
"$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
SectionEnd
Section "Desktop Shortcut"
SetShellVarContext all
Delete "$DESKTOP\stunnel.lnk"
CreateShortCut "$DESKTOP\stunnel.lnk" \
"$INSTDIR\stunnel.exe" "" "$INSTDIR\stunnel.exe" 0
SectionEnd
Section "Uninstall"
ClearErrors
# stop and remove the service, exit stunnel
ReadRegStr $R0 HKLM \
"Software\Microsoft\Windows NT\CurrentVersion" CurrentVersion
IfErrors skip_service_uninstall
ExecWait '"$INSTDIR\stunnel.exe" -stop -quiet'
ExecWait '"$INSTDIR\stunnel.exe" -uninstall -quiet'
skip_service_uninstall:
ExecWait '"$INSTDIR\stunnel.exe" -exit -quiet'
# remove stunnel folder
Delete "$INSTDIR\stunnel.conf"
Delete "$INSTDIR\stunnel.pem"
Delete "$INSTDIR\stunnel.exe"
Delete "$INSTDIR\stunnel.exe.manifest"
Delete "$INSTDIR\tstunnel.exe"
Delete "$INSTDIR\tstunnel.exe.manifest"
Delete "$INSTDIR\stunnel.cnf"
Delete "$INSTDIR\openssl.exe"
Delete "$INSTDIR\openssl.exe.manifest"
Delete "$INSTDIR\*.dll"
Delete "$INSTDIR\*.dll.manifest"
Delete "$INSTDIR\Microsoft.VC90.CRT.manifest"
Delete "$INSTDIR\stunnel.html"
Delete "$INSTDIR\uninstall.exe"
RMDir "$INSTDIR"
# remove menu shortcuts
SetShellVarContext all
Delete "$DESKTOP\stunnel.lnk"
Delete "$SMPROGRAMS\stunnel\*.lnk"
Delete "$SMPROGRAMS\stunnel\*.url"
RMDir "$SMPROGRAMS\stunnel"
# remove firewall rules
SimpleFC::RemoveApplication "$INSTDIR\stunnel.exe"
Pop $0 # returns error(1)/success(0)
DetailPrint "SimpleFC::RemoveApplication: $0"
SimpleFC::RemoveApplication "$INSTDIR\tstunnel.exe"
Pop $0 # returns error(1)/success(0)
DetailPrint "SimpleFC::RemoveApplication: $0"
# remove uninstaller registry entires
DeleteRegKey HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\stunnel"
DeleteRegKey HKLM "Software\NSIS_stunnel"
SectionEnd
# end of stunnel.nsi

View File

@ -3,7 +3,7 @@
Summary: Program that wraps normal socket connections with SSL/TLS Summary: Program that wraps normal socket connections with SSL/TLS
Name: stunnel Name: stunnel
Version: 4.53 Version: 4.57
Release: 1 Release: 1
Copyright: GPL Copyright: GPL
Group: Applications/Networking Group: Applications/Networking