diff -u -r -N squid-3.1.12/ChangeLog squid-3.1.12.1/ChangeLog
--- squid-3.1.12/ChangeLog 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/ChangeLog 2011-04-19 17:27:09.000000000 +1200
@@ -1,3 +1,13 @@
+Changes to squid-3.1.12.1 (19 Apr 2011):
+
+ - Port from 3.2: Dynamic SSL Certificate generation
+ - Bug 3194: selinux may prevent ntlm_smb_lm_auth from using /tmp
+ - Bug 3185: 3.1.11 fails to compile on OpenBSD 4.8 and 4.9
+ - Bug 3183: Invalid URL accepted with url host part of only '@'
+ - Display ERROR in cache.log for invalid configured paths
+ - Cache Manager: send User-Agent header from cachemgr.cgi
+ - ... and many portability compile fixes for non-GCC systems.
+
Changes to squid-3.1.12 (04 Apr 2011):
- Regression fix: Use bigger buffer for server reads.
diff -u -r -N squid-3.1.12/compat/assert.cc squid-3.1.12.1/compat/assert.cc
--- squid-3.1.12/compat/assert.cc 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/compat/assert.cc 2011-04-19 17:27:09.000000000 +1200
@@ -33,17 +33,6 @@
#include "config.h"
-#if HAVE_STDIO_H
-#include
-#endif
-#if HAVE_STDLIB_H
-#include
-#endif
-
-#if 0
-#include "compat/assert.h"
-#endif
-
void xassert(const char *expr, const char *file, int line)
{
fprintf(stderr, "assertion failed: %s:%d: \"%s\"\n", file, line, expr);
diff -u -r -N squid-3.1.12/compat/compat.h squid-3.1.12.1/compat/compat.h
--- squid-3.1.12/compat/compat.h 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/compat/compat.h 2011-04-19 17:27:09.000000000 +1200
@@ -75,6 +75,9 @@
#include "compat/stdvarargs.h"
#include "compat/assert.h"
+/* cstdio has a bunch of problems with 64-bit definitions */
+#include "compat/stdio.h"
+
/*****************************************************/
/* component-specific portabilities */
/*****************************************************/
diff -u -r -N squid-3.1.12/compat/compat_shared.h squid-3.1.12.1/compat/compat_shared.h
--- squid-3.1.12/compat/compat_shared.h 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/compat/compat_shared.h 2011-04-19 17:27:09.000000000 +1200
@@ -30,8 +30,7 @@
/*
* DIRENT functionality can apparently come from many places.
- * I believe these should really be done by OS-specific compat
- * files, but for now its left here.
+ * With various complaints by different compilers
*/
#if HAVE_DIRENT_H
#include
@@ -51,6 +50,15 @@
#endif /* HAVE_NDIR_H */
#endif /* HAVE_DIRENT_H */
+/* The structure dirent also varies between 64-bit and 32-bit environments.
+ * Define our own dirent_t type for consistent simple internal use.
+ * NP: GCC seems not to care about the type naming differences.
+ */
+#if defined(__USE_FILE_OFFSET64) && !defined(__GNUC__)
+#define dirent_t struct dirent64
+#else
+#define dirent_t struct dirent
+#endif
/*
* Filedescriptor limits in the different select loops
diff -u -r -N squid-3.1.12/compat/GnuRegex.c squid-3.1.12.1/compat/GnuRegex.c
--- squid-3.1.12/compat/GnuRegex.c 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/compat/GnuRegex.c 2011-04-19 17:27:09.000000000 +1200
@@ -235,9 +235,6 @@
#define STREQ(s1, s2) ((strcmp (s1, s2) == 0))
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-
#if !defined(__MINGW32__) /* MinGW defines boolean */
typedef char boolean;
#endif
@@ -452,12 +449,6 @@
#ifdef DEBUG
-/* We use standard I/O for debugging. */
-#include
-
-/* It is useful to test things that ``must'' be true when debugging. */
-#include
-
static int debug = 0;
#define DEBUG_STATEMENT(e) e
@@ -3147,7 +3138,7 @@
if (bufp->regs_allocated == REGS_UNALLOCATED) { /* No. So allocate them with malloc. We need one
* extra element beyond `num_regs' for the `-1' marker
* GNU code uses. */
- regs->num_regs = MAX(RE_NREGS, num_regs + 1);
+ regs->num_regs = max(RE_NREGS, num_regs + 1);
regs->start = TALLOC(regs->num_regs, regoff_t);
regs->end = TALLOC(regs->num_regs, regoff_t);
if (regs->start == NULL || regs->end == NULL)
@@ -3176,7 +3167,7 @@
}
/* Go through the first `min (num_regs, regs->num_regs)'
* registers, since that is all we initialized. */
- for (mcnt = 1; mcnt < MIN(num_regs, regs->num_regs); mcnt++) {
+ for (mcnt = 1; mcnt < min(num_regs, regs->num_regs); mcnt++) {
if (REG_UNSET(regstart[mcnt]) || REG_UNSET(regend[mcnt]))
regs->start[mcnt] = regs->end[mcnt] = -1;
else {
diff -u -r -N squid-3.1.12/compat/Makefile.am squid-3.1.12.1/compat/Makefile.am
--- squid-3.1.12/compat/Makefile.am 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/compat/Makefile.am 2011-04-19 17:27:09.000000000 +1200
@@ -17,6 +17,7 @@
compat_shared.h \
fdsetsize.h \
osdetect.h \
+ stdio.h \
stdvarargs.h \
valgrind.h \
\
diff -u -r -N squid-3.1.12/compat/Makefile.in squid-3.1.12.1/compat/Makefile.in
--- squid-3.1.12/compat/Makefile.in 2011-04-04 13:24:42.000000000 +1200
+++ squid-3.1.12.1/compat/Makefile.in 2011-04-19 17:27:51.000000000 +1200
@@ -307,6 +307,7 @@
compat_shared.h \
fdsetsize.h \
osdetect.h \
+ stdio.h \
stdvarargs.h \
valgrind.h \
\
diff -u -r -N squid-3.1.12/compat/os/linux.h squid-3.1.12.1/compat/os/linux.h
--- squid-3.1.12/compat/os/linux.h 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/compat/os/linux.h 2011-04-19 17:27:09.000000000 +1200
@@ -44,6 +44,29 @@
#include
#endif /* HAVE_SYS_CAPABILITY_H */
+/*
+ * glob.h is provided by GNU on Linux and contains some unavoidable preprocessor
+ * logic errors in its 64-bit definitions which are hit by non-GCC compilers.
+ *
+ * #if __USE_FILE_OFFSET64 && __GNUC__ < 2
+ * # define glob glob64
+ * #endif
+ * #if !defined __USE_FILE_OFFSET64 || __GNUC__ < 2
+ * extern "C" glob(...);
+ * #endif
+ * extern "C" glob64(...);
+ *
+ * ... and multiple "C" definitions of glob64 refuse to compile.
+ * Because __GNUC__ being undefined equates to 0 and (0 < 2)
+ */
+#if __USE_FILE_OFFSET64 && __GNUC__ < 2
+#if HAVE_GLOB_H
+#undef HAVE_GLOB_H
+#endif
+#if HAVE_GLOB
+#undef HAVE_GLOB
+#endif
+#endif
#endif /* _SQUID_LINUX_ */
#endif /* SQUID_OS_LINUX_H */
diff -u -r -N squid-3.1.12/compat/os/openbsd.h squid-3.1.12.1/compat/os/openbsd.h
--- squid-3.1.12/compat/os/openbsd.h 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/compat/os/openbsd.h 2011-04-19 17:27:09.000000000 +1200
@@ -35,5 +35,13 @@
#define IPV6_V6ONLY 27 // from OpenBSD 4.3 headers. (NP: does not match non-BSD OS values)
#endif
+/* OpenBSD 4.8 and 4.9 require netinet/in.h before arpa/inet.h */
+#if HAVE_NETINET_IN_H
+#include
+#endif
+#if HAVE_ARPA_INET_H
+#include
+#endif
+
#endif /* _SQUID_OPENBSD_ */
#endif /* SQUID_OS_OPENBSD_H */
diff -u -r -N squid-3.1.12/compat/stdio.h squid-3.1.12.1/compat/stdio.h
--- squid-3.1.12/compat/stdio.h 1970-01-01 12:00:00.000000000 +1200
+++ squid-3.1.12.1/compat/stdio.h 2011-04-19 17:27:09.000000000 +1200
@@ -0,0 +1,53 @@
+#ifndef _SQUID_COMPAT_STDIO_H
+#define _SQUID_COMPAT_STDIO_H
+
+/** 64-bit broken
+ *
+ * provides fgetpos64, fopen64 if __USE_FILE_OFFSET64 is defined.
+ * It then checks whether a gcc-specific __REDIRECT macro is available
+ * (defined in , depending on __GNUC__ begin available).
+ * If it is not available, it does a preprocessor #define.
+ * Which undefines, with this comment:
+ * "// Get rid of those macros defined in in lieu of real functions.".
+ * When it does a namespace redirection ("namespace std { using ::fgetpos; }") it goes blam, as
+ * fgetpos64 is available, while fgetpos is not.
+ */
+
+// Import the stdio.h definitions first to do the state setup
+#if HAVE_STDIO_H
+#include
+#endif
+
+// Check for the buggy case
+#if defined(__USE_FILE_OFFSET64) && !defined(__REDIRECT)
+
+// Define the problem functions as needed
+#if defined(fgetpos)
+#undef fgetpos
+inline int fgetpos(FILE *f, fpos64_t *p) { return fgetpos64(f,p); }
+#endif
+#if defined(fopen)
+#undef fopen
+inline FILE * fopen(const char *f, const char *m) { return fopen64(f,m); }
+#endif
+#if defined(freopen)
+#undef freopen
+inline FILE * freopen(const char *f, const char *m, FILE *s) { return freopen64(f,m,s); }
+#endif
+#if defined(fsetpos)
+#undef fsetpos
+inline int fsetpos(FILE *f, fpos64_t *p) { return fsetpos64(f,p); }
+#endif
+#if defined(tmpfile)
+#undef tmpfile
+inline FILE * tmpfile(void) { return tmpfile64(); }
+#endif
+
+#endif /* __USE_FILE_OFFSET64 && !__REDIRECT */
+
+// Finally import the stuff we actually use
+#if HAVE_CSTDIO
+#include
+#endif
+
+#endif /* _SQUID_COMPAT_STDIO_H */
diff -u -r -N squid-3.1.12/configure squid-3.1.12.1/configure
--- squid-3.1.12/configure 2011-04-04 13:25:13.000000000 +1200
+++ squid-3.1.12.1/configure 2011-04-19 17:28:35.000000000 +1200
@@ -1,7 +1,7 @@
#! /bin/sh
# From configure.ac Revision.
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for Squid Web Proxy 3.1.12.
+# Generated by GNU Autoconf 2.68 for Squid Web Proxy 3.1.12.1.
#
# Report bugs to .
#
@@ -575,8 +575,8 @@
# Identity of this package.
PACKAGE_NAME='Squid Web Proxy'
PACKAGE_TARNAME='squid'
-PACKAGE_VERSION='3.1.12'
-PACKAGE_STRING='Squid Web Proxy 3.1.12'
+PACKAGE_VERSION='3.1.12.1'
+PACKAGE_STRING='Squid Web Proxy 3.1.12.1'
PACKAGE_BUGREPORT='http://www.squid-cache.org/bugs/'
PACKAGE_URL=''
@@ -675,6 +675,8 @@
AUTH_LIBS_TO_BUILD
AUTH_MODULES
OPT_DEFAULT_HOSTS
+USE_SSL_CRTD_FALSE
+USE_SSL_CRTD_TRUE
USE_DNSSERVER_FALSE
USE_DNSSERVER_TRUE
MAKE_LEAKFINDER_FALSE
@@ -950,6 +952,7 @@
enable_follow_x_forwarded_for
enable_ident_lookups
enable_internal_dns
+enable_ssl_crtd
enable_default_hostsfile
enable_auth
enable_basic_auth_helpers
@@ -1536,7 +1539,7 @@
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures Squid Web Proxy 3.1.12 to adapt to many kinds of systems.
+\`configure' configures Squid Web Proxy 3.1.12.1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1606,7 +1609,7 @@
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of Squid Web Proxy 3.1.12:";;
+ short | recursive ) echo "Configuration of Squid Web Proxy 3.1.12.1:";;
esac
cat <<\_ACEOF
@@ -1729,6 +1732,9 @@
--disable-internal-dns Prevents Squid from directly sending and receiving
DNS messages, and instead enables the old external
'dnsserver' processes.
+ --enable-ssl-crtd Prevent Squid from directly generation of SSL
+ private key and certificate request and instead
+ enables the ssl_crtd processes.
--enable-default-hostsfile=path
Select default location for hosts file. See
hosts_file directive in squid.conf for details
@@ -1934,7 +1940,7 @@
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-Squid Web Proxy configure 3.1.12
+Squid Web Proxy configure 3.1.12.1
generated by GNU Autoconf 2.68
Copyright (C) 2010 Free Software Foundation, Inc.
@@ -2945,7 +2951,7 @@
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by Squid Web Proxy $as_me 3.1.12, which was
+It was created by Squid Web Proxy $as_me 3.1.12.1, which was
generated by GNU Autoconf 2.68. Invocation command line was
$ $0 $@
@@ -3764,7 +3770,7 @@
# Define the identity of the package.
PACKAGE='squid'
- VERSION='3.1.12'
+ VERSION='3.1.12.1'
cat >>confdefs.h <<_ACEOF
@@ -19480,6 +19486,43 @@
fi
+ if false; then
+ USE_SSL_CRTD_TRUE=
+ USE_SSL_CRTD_FALSE='#'
+else
+ USE_SSL_CRTD_TRUE='#'
+ USE_SSL_CRTD_FALSE=
+fi
+
+use_ssl_crtd=
+# Check whether --enable-ssl-crtd was given.
+if test "${enable_ssl_crtd+set}" = set; then :
+ enableval=$enable_ssl_crtd;
+ if test "x$enableval" = "xyes" ; then
+ use_ssl_crtd="yes"
+ fi
+
+fi
+
+
+if test "x$use_ssl_crtd" = "xyes" -a -z "$USE_OPENSSL" ; then
+ as_fn_error $? "You need to enable ssl gatewaying support to use ssl_crtd feature. Try to use --enable-ssl. " "$LINENO" 5
+fi
+
+if test "x$use_ssl_crtd" = "xyes"; then
+
+$as_echo "#define USE_SSL_CRTD 1" >>confdefs.h
+
+ if true; then
+ USE_SSL_CRTD_TRUE=
+ USE_SSL_CRTD_FALSE='#'
+else
+ USE_SSL_CRTD_TRUE='#'
+ USE_SSL_CRTD_FALSE=
+fi
+
+fi
+
# Check whether --enable-default-hostsfile was given.
if test "${enable_default_hostsfile+set}" = set; then :
enableval=$enable_default_hostsfile;
@@ -21071,6 +21114,7 @@
execinfo.h \
fcntl.h \
fnmatch.h \
+ fstream \
getopt.h \
glob.h \
gnumalloc.h \
@@ -21086,12 +21130,16 @@
libc.h \
libgen.h \
limits.h \
+ limits \
linux/posix_types.h \
linux/types.h \
+ list \
machine/byte_swap.h \
malloc.h \
+ map \
math.h \
memory.h \
+ memory \
mount.h \
netdb.h \
netinet/in.h \
@@ -21100,6 +21148,7 @@
openssl/err.h \
openssl/md5.h \
openssl/ssl.h \
+ openssl/txt_db.h \
openssl/x509v3.h \
netinet/tcp.h \
openssl/engine.h \
@@ -27308,7 +27357,7 @@
rm -f core
-ac_config_files="$ac_config_files Makefile compat/Makefile lib/Makefile scripts/Makefile src/Makefile src/base/Makefile src/acl/Makefile src/fs/Makefile src/repl/Makefile src/auth/Makefile src/adaptation/Makefile src/adaptation/icap/Makefile src/adaptation/ecap/Makefile src/esi/Makefile src/icmp/Makefile src/ident/Makefile src/ip/Makefile contrib/Makefile snmplib/Makefile icons/Makefile errors/Makefile test-suite/Makefile doc/Makefile helpers/Makefile helpers/basic_auth/Makefile helpers/basic_auth/LDAP/Makefile helpers/basic_auth/MSNT/Makefile helpers/basic_auth/NCSA/Makefile helpers/basic_auth/PAM/Makefile helpers/basic_auth/SMB/Makefile helpers/basic_auth/mswin_sspi/Makefile helpers/basic_auth/YP/Makefile helpers/basic_auth/getpwnam/Makefile helpers/basic_auth/multi-domain-NTLM/Makefile helpers/basic_auth/SASL/Makefile helpers/basic_auth/POP3/Makefile helpers/basic_auth/DB/Makefile helpers/basic_auth/squid_radius_auth/Makefile helpers/digest_auth/Makefile helpers/digest_auth/password/Makefile helpers/digest_auth/ldap/Makefile helpers/digest_auth/eDirectory/Makefile helpers/ntlm_auth/Makefile helpers/ntlm_auth/fakeauth/Makefile helpers/ntlm_auth/no_check/Makefile helpers/ntlm_auth/smb_lm/Makefile helpers/ntlm_auth/smb_lm/smbval/Makefile helpers/ntlm_auth/mswin_sspi/Makefile helpers/negotiate_auth/Makefile helpers/negotiate_auth/mswin_sspi/Makefile helpers/external_acl/Makefile helpers/external_acl/ip_user/Makefile helpers/external_acl/ldap_group/Makefile helpers/external_acl/session/Makefile helpers/external_acl/unix_group/Makefile helpers/external_acl/wbinfo_group/Makefile helpers/external_acl/mswin_ad_group/Makefile helpers/external_acl/mswin_lm_group/Makefile tools/Makefile"
+ac_config_files="$ac_config_files Makefile compat/Makefile lib/Makefile scripts/Makefile src/Makefile src/base/Makefile src/acl/Makefile src/fs/Makefile src/repl/Makefile src/auth/Makefile src/adaptation/Makefile src/adaptation/icap/Makefile src/adaptation/ecap/Makefile src/esi/Makefile src/icmp/Makefile src/ident/Makefile src/ip/Makefile src/ssl/Makefile contrib/Makefile snmplib/Makefile icons/Makefile errors/Makefile test-suite/Makefile doc/Makefile helpers/Makefile helpers/basic_auth/Makefile helpers/basic_auth/LDAP/Makefile helpers/basic_auth/MSNT/Makefile helpers/basic_auth/NCSA/Makefile helpers/basic_auth/PAM/Makefile helpers/basic_auth/SMB/Makefile helpers/basic_auth/mswin_sspi/Makefile helpers/basic_auth/YP/Makefile helpers/basic_auth/getpwnam/Makefile helpers/basic_auth/multi-domain-NTLM/Makefile helpers/basic_auth/SASL/Makefile helpers/basic_auth/POP3/Makefile helpers/basic_auth/DB/Makefile helpers/basic_auth/squid_radius_auth/Makefile helpers/digest_auth/Makefile helpers/digest_auth/password/Makefile helpers/digest_auth/ldap/Makefile helpers/digest_auth/eDirectory/Makefile helpers/ntlm_auth/Makefile helpers/ntlm_auth/fakeauth/Makefile helpers/ntlm_auth/no_check/Makefile helpers/ntlm_auth/smb_lm/Makefile helpers/ntlm_auth/smb_lm/smbval/Makefile helpers/ntlm_auth/mswin_sspi/Makefile helpers/negotiate_auth/Makefile helpers/negotiate_auth/mswin_sspi/Makefile helpers/external_acl/Makefile helpers/external_acl/ip_user/Makefile helpers/external_acl/ldap_group/Makefile helpers/external_acl/session/Makefile helpers/external_acl/unix_group/Makefile helpers/external_acl/wbinfo_group/Makefile helpers/external_acl/mswin_ad_group/Makefile helpers/external_acl/mswin_lm_group/Makefile tools/Makefile"
subdirs="$subdirs lib/libTrie"
@@ -27591,6 +27640,14 @@
as_fn_error $? "conditional \"USE_DNSSERVER\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
+if test -z "${USE_SSL_CRTD_TRUE}" && test -z "${USE_SSL_CRTD_FALSE}"; then
+ as_fn_error $? "conditional \"USE_SSL_CRTD\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${USE_SSL_CRTD_TRUE}" && test -z "${USE_SSL_CRTD_FALSE}"; then
+ as_fn_error $? "conditional \"USE_SSL_CRTD\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
if test -z "${ENABLE_UNLINKD_TRUE}" && test -z "${ENABLE_UNLINKD_FALSE}"; then
as_fn_error $? "conditional \"ENABLE_UNLINKD\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -28045,7 +28102,7 @@
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by Squid Web Proxy $as_me 3.1.12, which was
+This file was extended by Squid Web Proxy $as_me 3.1.12.1, which was
generated by GNU Autoconf 2.68. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -28111,7 +28168,7 @@
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-Squid Web Proxy config.status 3.1.12
+Squid Web Proxy config.status 3.1.12.1
configured by $0, generated by GNU Autoconf 2.68,
with options \\"\$ac_cs_config\\"
@@ -28620,6 +28677,7 @@
"src/icmp/Makefile") CONFIG_FILES="$CONFIG_FILES src/icmp/Makefile" ;;
"src/ident/Makefile") CONFIG_FILES="$CONFIG_FILES src/ident/Makefile" ;;
"src/ip/Makefile") CONFIG_FILES="$CONFIG_FILES src/ip/Makefile" ;;
+ "src/ssl/Makefile") CONFIG_FILES="$CONFIG_FILES src/ssl/Makefile" ;;
"contrib/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/Makefile" ;;
"snmplib/Makefile") CONFIG_FILES="$CONFIG_FILES snmplib/Makefile" ;;
"icons/Makefile") CONFIG_FILES="$CONFIG_FILES icons/Makefile" ;;
diff -u -r -N squid-3.1.12/configure.ac squid-3.1.12.1/configure.ac
--- squid-3.1.12/configure.ac 2011-04-04 13:25:13.000000000 +1200
+++ squid-3.1.12.1/configure.ac 2011-04-19 17:28:34.000000000 +1200
@@ -2,7 +2,7 @@
dnl
dnl $Id$
dnl
-AC_INIT([Squid Web Proxy],[3.1.12],[http://www.squid-cache.org/bugs/],[squid])
+AC_INIT([Squid Web Proxy],[3.1.12.1],[http://www.squid-cache.org/bugs/],[squid])
AC_PREREQ(2.61)
AC_CONFIG_HEADERS([include/autoconf.h])
AC_CONFIG_AUX_DIR(cfgaux)
@@ -1678,6 +1678,26 @@
AM_CONDITIONAL(USE_DNSSERVER, true)
fi
+AM_CONDITIONAL(USE_SSL_CRTD, false)
+use_ssl_crtd=
+AC_ARG_ENABLE(ssl-crtd,
+ AC_HELP_STRING([--enable-ssl-crtd],
+ [Prevent Squid from directly generation of SSL private key and
+ certificate request and instead enables the ssl_crtd processes.]), [
+ if test "x$enableval" = "xyes" ; then
+ use_ssl_crtd="yes"
+ fi
+])
+
+if test "x$use_ssl_crtd" = "xyes" -a -z "$USE_OPENSSL" ; then
+ AC_MSG_ERROR([You need to enable ssl gatewaying support to use ssl_crtd feature. Try to use --enable-ssl. ])
+fi
+
+if test "x$use_ssl_crtd" = "xyes"; then
+ AC_DEFINE(USE_SSL_CRTD, 1,[Use ssl_crtd daemon])
+ AM_CONDITIONAL(USE_SSL_CRTD, true)
+fi
+
dnl Select Default hosts file location
AC_ARG_ENABLE(default-hostsfile,
AS_HELP_STRING([--enable-default-hostsfile=path],[Select default location for hosts file.
@@ -2257,6 +2277,7 @@
execinfo.h \
fcntl.h \
fnmatch.h \
+ fstream \
getopt.h \
glob.h \
gnumalloc.h \
@@ -2272,12 +2293,16 @@
libc.h \
libgen.h \
limits.h \
+ limits \
linux/posix_types.h \
linux/types.h \
+ list \
machine/byte_swap.h \
malloc.h \
+ map \
math.h \
memory.h \
+ memory \
mount.h \
netdb.h \
netinet/in.h \
@@ -2286,6 +2311,7 @@
openssl/err.h \
openssl/md5.h \
openssl/ssl.h \
+ openssl/txt_db.h \
openssl/x509v3.h \
netinet/tcp.h \
openssl/engine.h \
@@ -3934,6 +3960,7 @@
src/icmp/Makefile \
src/ident/Makefile \
src/ip/Makefile \
+ src/ssl/Makefile \
contrib/Makefile \
snmplib/Makefile \
icons/Makefile \
diff -u -r -N squid-3.1.12/helpers/ntlm_auth/smb_lm/ntlm_smb_lm_auth.c squid-3.1.12.1/helpers/ntlm_auth/smb_lm/ntlm_smb_lm_auth.c
--- squid-3.1.12/helpers/ntlm_auth/smb_lm/ntlm_smb_lm_auth.c 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/helpers/ntlm_auth/smb_lm/ntlm_smb_lm_auth.c 2011-04-19 17:27:09.000000000 +1200
@@ -462,13 +462,6 @@
main(int argc, char *argv[])
{
debug("ntlm_auth build " __DATE__ ", " __TIME__ " starting up...\n");
-#ifdef DEBUG
- debug("changing dir to /tmp\n");
- if (chdir("/tmp") != 0) {
- debug("ERROR: (%d) failed.\n",errno);
- return 2;
- }
-#endif
my_program_name = argv[0];
process_options(argc, argv);
diff -u -r -N squid-3.1.12/include/autoconf.h.in squid-3.1.12.1/include/autoconf.h.in
--- squid-3.1.12/include/autoconf.h.in 2011-04-04 13:24:37.000000000 +1200
+++ squid-3.1.12.1/include/autoconf.h.in 2011-04-19 17:27:45.000000000 +1200
@@ -210,6 +210,9 @@
/* Define to 1 if you have the header file. */
#undef HAVE_FNMATCH_H
+/* Define to 1 if you have the header file. */
+#undef HAVE_FSTREAM
+
/* "Define to 1 if aufs filesystem module is build" */
#undef HAVE_FS_AUFS
@@ -369,6 +372,9 @@
/* Define to 1 if you have the header file. */
#undef HAVE_LIBXML_PARSER_H
+/* Define to 1 if you have the header file. */
+#undef HAVE_LIMITS
+
/* Define to 1 if you have the header file. */
#undef HAVE_LIMITS_H
@@ -385,6 +391,9 @@
/* Define to 1 if you have the header file. */
#undef HAVE_LINUX_TYPES_H
+/* Define to 1 if you have the header file. */
+#undef HAVE_LIST
+
/* long is defined in system headers */
#undef HAVE_LONG
@@ -415,6 +424,9 @@
/* Define to 1 if you have the `mallopt' function. */
#undef HAVE_MALLOPT
+/* Define to 1 if you have the
Most user-facing changes are reflected in squid.conf (see below).
@@ -371,8 +373,30 @@
configuration. Use of interception for port 443 is not officially supported, despite
being known to work under certain limited networking circumstances.
+
+
+ SslBump users know how many certificate warnings a single complex site
+(using dedicated image, style, and/or advertisement servers for embedded content)
+can generate. The warnings are legitimate and are caused by Squid-provided site
+certificate. Two things may be wrong with that certificate:
+
+- Squid certificate is not signed by a trusted authority.
+- Squid certificate name does not match the site domain name.
+
-2.8 eCAP Adaptation Module support
+Squid can do nothing about (A), but in most targeted environments, users will
+trust the "man in the middle" authority and install the corresponding root
+certificate.
+
+
To avoid mismatch (B), the DynamicSslCert feature concentrates on generating
+site certificates that match the requested site domain name. Please note that
+the browser site name check does not really add much security in an SslBump
+environment where the user already trusts the "man in the middle". The check
+only adds warnings and creates page rendering problems in browsers that try to
+reduce the number of warnings by blocking some embedded content.
+
+
Details in
@@ -384,7 +408,7 @@
Currently known and available eCAP modules are listed in the wiki feature page on eCAP.
-Details in
@@ -446,7 +470,7 @@
environments yet may be small enough to limit side-effects of loops.
-2.10 ICY streaming protocol support
+2.11 ICY streaming protocol support
Squid-3.1 adds native support for streaming protocol ICY.
@@ -1047,6 +1071,12 @@
+sslcrtd_program
+Specify the location and options of the executable for ssl_crtd process.
+
+sslcrtd_children
+ Configures the number of sslcrtd processes to spawn
+
sslproxy_cert_error
New Access Control to selectively bypass server certificate validation errors.
DEFAULT: None bypassed.
@@ -1575,6 +1605,10 @@
original or indirect client when a request has been forwarded through other
proxies.
+--enable-ssl-crtd
+Prevent Squid from direct generation of SSL private key and
+certificate request and instead enables the ssl_crtd processes.
+
--enable-zph-qos
Build with support for ZPH Quality of Service controls
diff -u -r -N squid-3.1.12/src/acl/DomainData.cc squid-3.1.12.1/src/acl/DomainData.cc
--- squid-3.1.12/src/acl/DomainData.cc 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/acl/DomainData.cc 2011-04-19 17:27:09.000000000 +1200
@@ -74,8 +74,8 @@
static int
aclHostDomainCompare( char *const &a, char * const &b)
{
- const char *h = (const char *)a;
- const char *d = (const char *)b;
+ const char *h = static_cast(a);
+ const char *d = static_cast(b);
return matchDomainName(h, d);
}
@@ -86,8 +86,8 @@
int
aclDomainCompare(T const &a, T const &b)
{
- char * const d1 = (char *const)b;
- char * const d2 = (char *const )a;
+ char * const d1 = static_cast(b);
+ char * const d2 = static_cast(a);
int ret;
ret = aclHostDomainCompare(d1, d2);
diff -u -r -N squid-3.1.12/src/acl/SslErrorData.cc squid-3.1.12.1/src/acl/SslErrorData.cc
--- squid-3.1.12/src/acl/SslErrorData.cc 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/acl/SslErrorData.cc 2011-04-19 17:27:09.000000000 +1200
@@ -22,7 +22,7 @@
}
bool
-ACLSslErrorData::match(ssl_error_t toFind)
+ACLSslErrorData::match(Ssl::ssl_error_t toFind)
{
return values->findAndTune (toFind);
}
@@ -30,17 +30,17 @@
/* explicit instantiation required for some systems */
/** \cond AUTODOCS-IGNORE */
// AYJ: 2009-05-20 : Removing. clashes with template instantiation for other ACLs.
-// template cbdata_type CbDataList::CBDATA_CbDataList;
+// template cbdata_type CbDataList::CBDATA_CbDataList;
/** \endcond */
wordlist *
ACLSslErrorData::dump()
{
wordlist *W = NULL;
- CbDataList *data = values;
+ CbDataList *data = values;
while (data != NULL) {
- wordlistAdd(&W, sslFindErrorString(data->element));
+ wordlistAdd(&W, Ssl::getErrorName(data->element));
data = data->next;
}
@@ -50,12 +50,12 @@
void
ACLSslErrorData::parse()
{
- CbDataList **Tail;
+ CbDataList **Tail;
char *t = NULL;
for (Tail = &values; *Tail; Tail = &((*Tail)->next));
while ((t = strtokFile())) {
- CbDataList *q = new CbDataList(sslParseErrorString(t));
+ CbDataList *q = new CbDataList(Ssl::parseErrorString(t));
*(Tail) = q;
Tail = &q->next;
}
@@ -67,7 +67,7 @@
return values == NULL;
}
-ACLData *
+ACLData *
ACLSslErrorData::clone() const
{
/* Splay trees don't clone yet. */
diff -u -r -N squid-3.1.12/src/acl/SslErrorData.h squid-3.1.12.1/src/acl/SslErrorData.h
--- squid-3.1.12/src/acl/SslErrorData.h 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/acl/SslErrorData.h 2011-04-19 17:27:09.000000000 +1200
@@ -9,8 +9,9 @@
#include "acl/Data.h"
#include "CbDataList.h"
#include "ssl_support.h"
+#include "ssl/ErrorDetail.h"
-class ACLSslErrorData : public ACLData
+class ACLSslErrorData : public ACLData
{
public:
@@ -20,13 +21,13 @@
ACLSslErrorData(ACLSslErrorData const &);
ACLSslErrorData &operator= (ACLSslErrorData const &);
virtual ~ACLSslErrorData();
- bool match(ssl_error_t);
+ bool match(Ssl::ssl_error_t);
wordlist *dump();
void parse();
bool empty() const;
- virtual ACLData *clone() const;
+ virtual ACLData *clone() const;
- CbDataList *values;
+ CbDataList *values;
};
MEMPROXY_CLASS_INLINE(ACLSslErrorData);
diff -u -r -N squid-3.1.12/src/adaptation/icap/ModXact.cc squid-3.1.12.1/src/adaptation/icap/ModXact.cc
--- squid-3.1.12/src/adaptation/icap/ModXact.cc 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/adaptation/icap/ModXact.cc 2011-04-19 17:27:09.000000000 +1200
@@ -1374,8 +1374,6 @@
// we decided to do preview, now compute its size
- Must(wantedSize >= 0);
-
// cannot preview more than we can backup
size_t ad = min(wantedSize, TheBackupLimit);
@@ -1622,7 +1620,6 @@
void Adaptation::Icap::VirginBodyAct::progress(size_t size)
{
Must(active());
- Must(size >= 0);
theStart += static_cast(size);
}
@@ -1639,7 +1636,6 @@
void Adaptation::Icap::Preview::enable(size_t anAd)
{
// TODO: check for anAd not exceeding preview size limit
- Must(anAd >= 0);
Must(!enabled());
theAd = anAd;
theState = stWriting;
diff -u -r -N squid-3.1.12/src/adaptation/icap/Xaction.cc squid-3.1.12.1/src/adaptation/icap/Xaction.cc
--- squid-3.1.12/src/adaptation/icap/Xaction.cc 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/adaptation/icap/Xaction.cc 2011-04-19 17:27:09.000000000 +1200
@@ -355,7 +355,6 @@
reader = NULL;
Must(io.flag == COMM_OK);
- Must(io.size >= 0);
if (!io.size) {
commEof = true;
diff -u -r -N squid-3.1.12/src/base/Makefile.am squid-3.1.12.1/src/base/Makefile.am
--- squid-3.1.12/src/base/Makefile.am 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/base/Makefile.am 2011-04-19 17:27:09.000000000 +1200
@@ -12,4 +12,5 @@
AsyncJobCalls.h \
AsyncCallQueue.cc \
AsyncCallQueue.h \
- CbcPointer.h
+ CbcPointer.h \
+ TidyPointer.h
diff -u -r -N squid-3.1.12/src/base/Makefile.in squid-3.1.12.1/src/base/Makefile.in
--- squid-3.1.12/src/base/Makefile.in 2011-04-04 13:24:51.000000000 +1200
+++ squid-3.1.12.1/src/base/Makefile.in 2011-04-19 17:28:07.000000000 +1200
@@ -292,7 +292,8 @@
AsyncJobCalls.h \
AsyncCallQueue.cc \
AsyncCallQueue.h \
- CbcPointer.h
+ CbcPointer.h \
+ TidyPointer.h
all: all-am
diff -u -r -N squid-3.1.12/src/base/TidyPointer.h squid-3.1.12.1/src/base/TidyPointer.h
--- squid-3.1.12/src/base/TidyPointer.h 1970-01-01 12:00:00.000000000 +1200
+++ squid-3.1.12.1/src/base/TidyPointer.h 2011-04-19 17:27:09.000000000 +1200
@@ -0,0 +1,64 @@
+/*
+ * $Id$
+ */
+
+#ifndef SQUID_BASE_TIDYPOINTER_H
+#define SQUID_BASE_TIDYPOINTER_H
+
+/**
+ * A pointer that deletes the object it points to when the pointer's owner or
+ * context is gone. Similar to std::auto_ptr but without confusing assignment
+ * and with a customizable cleanup method. Prevents memory leaks in
+ * the presence of exceptions and processing short cuts.
+*/
+template class TidyPointer
+{
+public:
+ /// Delete callback.
+ typedef void DCB (T *t);
+ TidyPointer(T *t = NULL)
+ : raw(t) {}
+public:
+ bool operator !() const { return !raw; }
+ /// Returns raw and possibly NULL pointer
+ T *get() const { return raw; }
+ /// Address of the raw pointer, for pointer-setting functions
+ T **addr() { return &raw; }
+ /// Reset raw pointer - delete last one and save new one.
+ void reset(T *t) {
+ deletePointer();
+ raw = t;
+ }
+
+ /// Forget the raw pointer without freeing it. Become a nil pointer.
+ T *release() {
+ T *ret = raw;
+ raw = NULL;
+ return ret;
+ }
+ /// Deallocate raw pointer.
+ ~TidyPointer() {
+ deletePointer();
+ }
+private:
+ /// Forbidden copy constructor.
+ TidyPointer(TidyPointer const &);
+ /// Forbidden assigment operator.
+ TidyPointer & operator = (TidyPointer const &);
+ /// Deallocate raw pointer. Become a nil pointer.
+ void deletePointer() {
+ if (raw) {
+ DeAllocator(raw);
+ }
+ raw = NULL;
+ }
+ T *raw; ///< pointer to T object or NULL
+};
+
+/// DeAllocator for pointers that need free(3) from the std C library
+template void tidyFree(T *p)
+{
+ xfree(p);
+}
+
+#endif // SQUID_BASE_TIDYPOINTER_H
diff -u -r -N squid-3.1.12/src/BodyPipe.cc squid-3.1.12.1/src/BodyPipe.cc
--- squid-3.1.12/src/BodyPipe.cc 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/BodyPipe.cc 2011-04-19 17:27:09.000000000 +1200
@@ -148,7 +148,6 @@
void BodyPipe::setBodySize(uint64_t aBodySize)
{
assert(!bodySizeKnown());
- assert(aBodySize >= 0);
assert(thePutSize <= aBodySize);
// If this assert fails, we need to add code to check for eof and inform
diff -u -r -N squid-3.1.12/src/cache_cf.cc squid-3.1.12.1/src/cache_cf.cc
--- squid-3.1.12/src/cache_cf.cc 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/cache_cf.cc 2011-04-19 17:27:09.000000000 +1200
@@ -57,6 +57,10 @@
#include
#endif
+#if HAVE_LIMITS
+#include
+#endif
+
#if SQUID_SNMP
#include "snmp.h"
#endif
@@ -64,6 +68,11 @@
#include "esi/Parser.h"
#endif
+#if USE_SSL
+#include "ssl/Config.h"
+#include "ssl/gadgets.h"
+#endif
+
#if USE_ADAPTATION
#include "adaptation/Config.h"
@@ -132,6 +141,9 @@
static void parse_obsolete(const char *);
static void parseBytesLine(size_t * bptr, const char *units);
static size_t parseBytesUnits(const char *unit);
+#if USE_SSL
+static void parseBytesOptionValue(size_t * bptr, const char *units, char const * value);
+#endif
static void free_all(void);
void requirePathnameExists(const char *name, const char *path);
static OBJH dump_config;
@@ -721,7 +733,13 @@
debugs(3, 1, "Initializing http_port " << s->http.s << " SSL context");
- s->sslContext = sslCreateServerContext(s->cert, s->key, s->version, s->cipher, s->options, s->sslflags, s->clientca, s->cafile, s->capath, s->crlfile, s->dhfile, s->sslcontext);
+ s->staticSslContext.reset(
+ sslCreateServerContext(s->cert, s->key,
+ s->version, s->cipher, s->options, s->sslflags, s->clientca,
+ s->cafile, s->capath, s->crlfile, s->dhfile,
+ s->sslContextSessionId));
+
+ Ssl::readCertAndPrivateKeyFromFiles(s->signingCert, s->signPkey, s->cert, s->key);
}
}
@@ -732,7 +750,11 @@
for (s = Config.Sockaddr.https; s != NULL; s = (https_port_list *) s->http.next) {
debugs(3, 1, "Initializing https_port " << s->http.s << " SSL context");
- s->sslContext = sslCreateServerContext(s->cert, s->key, s->version, s->cipher, s->options, s->sslflags, s->clientca, s->cafile, s->capath, s->crlfile, s->dhfile, s->sslcontext);
+ s->staticSslContext.reset(
+ sslCreateServerContext(s->cert, s->key,
+ s->version, s->cipher, s->options, s->sslflags, s->clientca,
+ s->cafile, s->capath, s->crlfile, s->dhfile,
+ s->sslContextSessionId));
}
}
@@ -931,6 +953,44 @@
self_destruct();
}
+#if USE_SSL
+/**
+ * Parse bytes from a string.
+ * Similar to the parseBytesLine function but parses the string value instead of
+ * the current token value.
+ */
+static void parseBytesOptionValue(size_t * bptr, const char *units, char const * value)
+{
+ int u;
+ if ((u = parseBytesUnits(units)) == 0) {
+ self_destruct();
+ return;
+ }
+
+ // Find number from string beginning.
+ char const * number_begin = value;
+ char const * number_end = value;
+
+ while ((*number_end >= '0' && *number_end <= '9')) {
+ number_end++;
+ }
+
+ String number;
+ number.limitInit(number_begin, number_end - number_begin);
+
+ int d = xatoi(number.termedBuf());
+ int m;
+ if ((m = parseBytesUnits(number_end)) == 0) {
+ self_destruct();
+ return;
+ }
+
+ *bptr = static_cast(m * d / u);
+ if (static_cast(*bptr) * 2 != m * d / u * 2)
+ self_destruct();
+}
+#endif
+
static size_t
parseBytesUnits(const char *unit)
{
@@ -3191,8 +3251,16 @@
safe_free(s->sslflags);
s->sslflags = xstrdup(token + 9);
} else if (strncmp(token, "sslcontext=", 11) == 0) {
- safe_free(s->sslcontext);
- s->sslcontext = xstrdup(token + 11);
+ safe_free(s->sslContextSessionId);
+ s->sslContextSessionId = xstrdup(token + 11);
+ } else if (strcmp(token, "generate-host-certificates") == 0) {
+ s->generateHostCertificates = true;
+ } else if (strcmp(token, "generate-host-certificates=on") == 0) {
+ s->generateHostCertificates = true;
+ } else if (strcmp(token, "generate-host-certificates=off") == 0) {
+ s->generateHostCertificates = false;
+ } else if (strncmp(token, "dynamic_cert_mem_cache_size=", 28) == 0) {
+ parseBytesOptionValue(&s->dynamicCertMemCacheSize, B_BYTES_STR, token + 28);
} else if (strcasecmp(token, "sslBump") == 0) {
debugs(3, DBG_CRITICAL, "WARNING: '" << token << "' is deprecated " <<
"in http_port. Use 'ssl-bump' instead.");
@@ -3269,7 +3337,7 @@
char *crlfile;
char *dhfile;
char *sslflags;
- char *sslcontext;
+ char *sslContextSessionId;
SSL_CTX *sslContext;
#endif
@@ -3415,8 +3483,14 @@
if (s->sslflags)
storeAppendPrintf(e, " sslflags=%s", s->sslflags);
- if (s->sslcontext)
- storeAppendPrintf(e, " sslcontext=%s", s->sslcontext);
+ if (s->sslContextSessionId)
+ storeAppendPrintf(e, " sslcontext=%s", s->sslContextSessionId);
+
+ if (s->generateHostCertificates)
+ storeAppendPrintf(e, " generate-host-certificates");
+
+ if (s->dynamicCertMemCacheSize != std::numeric_limits::max())
+ storeAppendPrintf(e, "dynamic_cert_mem_cache_size=%lu%s\n", (unsigned long)s->dynamicCertMemCacheSize, B_BYTES_STR);
#endif
}
@@ -3514,10 +3588,13 @@
}
if (stat(path, &sb) < 0) {
+ debugs(0, DBG_CRITICAL, (opt_parse_cfg_only?"FATAL ":"") << "ERROR: " << name << " " << path << ": " << xstrerror());
+ // keep going to find more issues if we are only checking the config file with "-k parse"
+ if (opt_parse_cfg_only)
+ return;
+ // this is fatal if it is found during startup or reconfigure
if (opt_send_signal == -1 || opt_send_signal == SIGHUP)
fatalf("%s %s: %s", name, path, xstrerror());
- else
- fprintf(stderr, "WARNING: %s %s: %s\n", name, path, xstrerror());
}
}
diff -u -r -N squid-3.1.12/src/cf.data.pre squid-3.1.12.1/src/cf.data.pre
--- squid-3.1.12/src/cf.data.pre 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/cf.data.pre 2011-04-19 17:27:09.000000000 +1200
@@ -1339,6 +1339,25 @@
sslcontext= SSL session ID context identifier.
+ generate-host-certificates[=]
+ Dynamically create SSL server certificates for the
+ destination hosts of bumped CONNECT requests.When
+ enabled, the cert and key options are used to sign
+ generated certificates. Otherwise generated
+ certificate will be selfsigned.
+ If there is CA certificate life time of generated
+ certificate equals lifetime of CA certificate. If
+ generated certificate is selfsigned lifetime is three
+ years.
+ This option is enabled by default when SslBump is used.
+ See the sslBump option above for more information.
+
+ dynamic_cert_mem_cache_size=SIZE
+ Approximate total RAM size spent on cached generated
+ certificates. If set to zero, caching is disabled. The
+ default value is 4MB. An average XXX-bit certificate
+ consumes about XXX bytes of RAM.
+
vport Accelerator with IP based virtual host support.
vport=NN As above, but uses specified port number rather
@@ -1710,6 +1729,35 @@
DOC_END
COMMENT_START
+OPTIONS RELATING TO EXTERNAL SSL_CRTD
+-----------------------------------------------------------------------------
+COMMENT_END
+
+NAME: sslcrtd_program
+TYPE: eol
+IFDEF: USE_SSL_CRTD
+DEFAULT: @DEFAULT_SSL_CRTD@ -s @DEFAULT_SSL_DB_DIR@ -M 4MB
+LOC: Ssl::TheConfig.ssl_crtd
+DOC_START
+ Specify the location and options of the executable for ssl_crtd process.
+ @DEFAULT_SSL_CRTD@ program requires -s and -M parameters
+ For more information use:
+ @DEFAULT_SSL_CRTD@ -h
+DOC_END
+
+NAME: sslcrtd_children
+TYPE: int
+IFDEF: USE_SSL_CRTD
+DEFAULT: 5
+LOC: Ssl::TheConfig.ssl_crtd_n_running
+DOC_START
+ The maximum number of processes spawn to service ssl server.
+ The maximum this may be safely set to is 32.
+
+ You must have at least one ssl_crtd process.
+DOC_END
+
+COMMENT_START
OPTIONS WHICH AFFECT THE NEIGHBOR SELECTION ALGORITHM
-----------------------------------------------------------------------------
COMMENT_END
@@ -3695,10 +3743,10 @@
DEFAULT: on
LOC: Adaptation::Icap::TheConfig.icap_uses_indirect_client
DOC_START
- Controls whether the indirect client address
- (see follow_x_forwarded_for) instead of the
- direct client address is passed to an ICAP
- server as "X-Client-IP".
+ Controls whether the indirect client IP address (instead of the direct
+ client IP address) is passed to adaptation services.
+
+ See also: follow_x_forwarded_for adaptation_send_client_ip
DOC_END
NAME: via
@@ -4475,7 +4523,7 @@
For a class 5 delay pool:
-delay_parameters pool tag
+delay_parameters pool tagrate
The variables here are:
@@ -4483,19 +4531,19 @@
number specified in delay_pools as used in
delay_class lines.
- aggregate the "delay parameters" for the aggregate bucket
+ aggregate the speed limit parameters for the aggregate bucket
(class 1, 2, 3).
- individual the "delay parameters" for the individual
+ individual the speed limit parameters for the individual
buckets (class 2, 3).
- network the "delay parameters" for the network buckets
+ network the speed limit parameters for the network buckets
(class 3).
- user the delay parameters for the user buckets
+ user the speed limit parameters for the user buckets
(class 4).
- tag the delay parameters for the tag buckets
+ tagrate the speed limit parameters for the tag buckets
(class 5).
A pair of delay parameters is written restore/maximum, where restore is
@@ -5804,7 +5852,11 @@
LOC: Adaptation::Icap::TheConfig.send_client_ip
DEFAULT: off
DOC_START
- This adds the header "X-Client-IP" to ICAP requests.
+ If enabled, Squid shares HTTP client IP information with adaptation
+ services. For ICAP, Squid adds the X-Client-IP header to ICAP requests.
+ For eCAP, Squid sets the libecap::metaClientIp transaction option.
+
+ See also: adaptation_uses_indirect_client
DOC_END
NAME: icap_send_client_username
diff -u -r -N squid-3.1.12/src/client_side.cc squid-3.1.12.1/src/client_side.cc
--- squid-3.1.12/src/client_side.cc 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/client_side.cc 2011-04-19 17:27:09.000000000 +1200
@@ -106,6 +106,20 @@
#include "ChunkedCodingParser.h"
#include "rfc1738.h"
+#if USE_SSL
+#include "ssl/context_storage.h"
+#include "ssl/helper.h"
+#include "ssl/gadgets.h"
+#endif
+#if USE_SSL_CRTD
+#include "ssl/crtd_message.h"
+#include "ssl/certificate_db.h"
+#endif
+
+#if HAVE_LIMITS
+#include
+#endif
+
#if LINGERING_CLOSE
#define comm_close comm_lingering_close
#endif
@@ -966,11 +980,6 @@
}
- /*
- * paranoid check
- */
- assert((available.size() >= 0 && i->debt() >= 0) || i->debt() == -1);
-
if (!canPackMoreRanges()) {
debugs(33, 3, "clientPackRange: Returning because !canPackMoreRanges.");
@@ -3294,7 +3303,7 @@
comm_err_t flag, int xerrno, void *data)
{
https_port_list *s = (https_port_list *)data;
- SSL_CTX *sslContext = s->sslContext;
+ SSL_CTX *sslContext = s->staticSslContext.get();
if (flag == COMM_ERR_CLOSING) {
return;
@@ -3355,24 +3364,109 @@
incoming_sockets_accepted++;
}
+void
+ConnStateData::sslCrtdHandleReplyWrapper(void *data, char *reply)
+{
+ ConnStateData * state_data = (ConnStateData *)(data);
+ state_data->sslCrtdHandleReply(reply);
+}
+
+void
+ConnStateData::sslCrtdHandleReply(const char * reply)
+{
+ if (!reply) {
+ debugs(1, 1, HERE << "\"ssl_crtd\" helper return reply");
+ } else {
+ Ssl::CrtdMessage reply_message;
+ if (reply_message.parse(reply, strlen(reply)) != Ssl::CrtdMessage::OK) {
+ debugs(33, 5, HERE << "Reply from ssl_crtd for " << sslHostName << " is incorrect");
+ } else {
+ if (reply_message.getCode() != "ok") {
+ debugs(33, 5, HERE << "Certificate for " << sslHostName << " cannot be generated. ssl_crtd response: " << reply_message.getBody());
+ } else {
+ debugs(33, 5, HERE << "Certificate for " << sslHostName << " was successfully recieved from ssl_crtd");
+ getSslContextDone(Ssl::generateSslContextUsingPkeyAndCertFromMemory(reply_message.getBody().c_str()), true);
+ return;
+ }
+ }
+ }
+ getSslContextDone(NULL);
+}
+
bool
-ConnStateData::switchToHttps()
+ConnStateData::getSslContextStart()
{
- assert(!switchedToHttps_);
+ char const * host = sslHostName.termedBuf();
+ if (port->generateHostCertificates && host && strcmp(host, "") != 0) {
+ debugs(33, 5, HERE << "Finding SSL certificate for " << host << " in cache");
+ Ssl::LocalContextStorage & ssl_ctx_cache(Ssl::TheGlobalContextStorage.getLocalStorage(port->s));
+ SSL_CTX * dynCtx = ssl_ctx_cache.find(host);
+ if (dynCtx) {
+ debugs(33, 5, HERE << "SSL certificate for " << host << " have found in cache");
+ if (Ssl::verifySslCertificateDate(dynCtx)) {
+ debugs(33, 5, HERE << "Cached SSL certificate for " << host << " is valid");
+ return getSslContextDone(dynCtx);
+ } else {
+ debugs(33, 5, HERE << "Cached SSL certificate for " << host << " is out of date. Delete this certificate from cache");
+ ssl_ctx_cache.remove(host);
+ }
+ } else {
+ debugs(33, 5, HERE << "SSL certificate for " << host << " haven't found in cache");
+ }
- //HTTPMSGLOCK(currentobject->http->request);
- assert(areAllContextsForThisConnection());
- freeAllContexts();
- //currentobject->connIsFinished();
+#ifdef USE_SSL_CRTD
+ debugs(33, 5, HERE << "Generating SSL certificate for " << host << " using ssl_crtd.");
+ Ssl::CrtdMessage request_message;
+ request_message.setCode(Ssl::CrtdMessage::code_new_certificate);
+ Ssl::CrtdMessage::BodyParams map;
+ map.insert(std::make_pair(Ssl::CrtdMessage::param_host, host));
+ std::string bufferToWrite;
+ Ssl::writeCertAndPrivateKeyToMemory(port->signingCert, port->signPkey, bufferToWrite);
+ request_message.composeBody(map, bufferToWrite);
+ Ssl::Helper::GetInstance()->sslSubmit(request_message, sslCrtdHandleReplyWrapper, this);
+ return true;
+#else
+ debugs(33, 5, HERE << "Generating SSL certificate for " << host);
+ dynCtx = Ssl::generateSslContext(host, port->signingCert, port->signPkey);
+ return getSslContextDone(dynCtx, true);
+#endif //USE_SSL_CRTD
+ }
+ return getSslContextDone(NULL);
+}
- debugs(33, 5, HERE << "converting FD " << fd << " to SSL");
+bool
+ConnStateData::getSslContextDone(SSL_CTX * sslContext, bool isNew)
+{
+ // Try to add generated ssl context to storage.
+ if (port->generateHostCertificates && isNew) {
+ Ssl::LocalContextStorage & ssl_ctx_cache(Ssl::TheGlobalContextStorage.getLocalStorage(port->s));
+ if (sslContext && sslHostName != "") {
+ if (!ssl_ctx_cache.add(sslHostName.termedBuf(), sslContext)) {
+ // If it is not in storage delete after using. Else storage deleted it.
+ fd_table[fd].dynamicSslContext = sslContext;
+ }
+ } else {
+ debugs(33, 2, HERE << "Failed to generate SSL cert for " << sslHostName);
+ }
+ }
+
+ // If generated ssl context = NULL, try to use static ssl context.
+ if (!sslContext) {
+ if (!port->staticSslContext) {
+ debugs(83, 1, "Closing SSL FD " << fd << " as lacking SSL context");
+ comm_close(fd);
+ return false;
+ } else {
+ debugs(33, 5, HERE << "Using static ssl context.");
+ sslContext = port->staticSslContext.get();
+ }
+ }
// fake a ConnectionDetail object; XXX: make ConnState a ConnectionDetail?
ConnectionDetail detail;
detail.me = me;
detail.peer = peer;
- SSL_CTX *sslContext = port->sslContext;
SSL *ssl = NULL;
if (!(ssl = httpsCreate(fd, &detail, sslContext)))
return false;
@@ -3388,6 +3482,23 @@
return true;
}
+bool
+ConnStateData::switchToHttps(const char *host)
+{
+ assert(!switchedToHttps_);
+
+ sslHostName = host;
+
+ //HTTPMSGLOCK(currentobject->http->request);
+ assert(areAllContextsForThisConnection());
+ freeAllContexts();
+ //currentobject->connIsFinished();
+
+ debugs(33, 5, HERE << "converting FD " << fd << " to SSL");
+
+ return getSslContextStart();
+}
+
#endif /* USE_SSL */
@@ -3408,14 +3519,21 @@
}
#if USE_SSL
- if (s->sslBump && s->sslContext == NULL) {
+ if (s->sslBump &&
+ !s->staticSslContext && !s->generateHostCertificates) {
debugs(1, 1, "Will not bump SSL at http_port " <<
s->http.s << " due to SSL initialization failure.");
s->sslBump = 0;
}
- if (s->sslBump)
+ if (s->sslBump) {
++bumpCount;
+ // Create ssl_ctx cache for this port.
+ Ssl::TheGlobalContextStorage.addLocalStorage(s->s, s->dynamicCertMemCacheSize == std::numeric_limits::max() ? 4194304 : s->dynamicCertMemCacheSize);
+ }
#endif
+#if USE_SSL_CRTD
+ Ssl::Helper::GetInstance();
+#endif //USE_SSL_CRTD
enter_suid();
@@ -3467,7 +3585,7 @@
continue;
}
- if (s->sslContext == NULL) {
+ if (!s->staticSslContext) {
debugs(1, 1, "Ignoring https_port " << s->http.s <<
" due to SSL initialization failure.");
continue;
@@ -3615,7 +3733,7 @@
CBDATA_CLASS_INIT(ConnStateData);
-ConnStateData::ConnStateData() :AsyncJob("ConnStateData"), transparent_ (false), closing_ (false)
+ConnStateData::ConnStateData() :AsyncJob("ConnStateData"), transparent_ (false), closing_ (false), switchedToHttps_(false)
{
pinning.fd = -1;
pinning.pinned = false;
diff -u -r -N squid-3.1.12/src/client_side.h squid-3.1.12.1/src/client_side.h
--- squid-3.1.12/src/client_side.h 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/client_side.h 2011-04-19 17:27:09.000000000 +1200
@@ -259,7 +259,20 @@
virtual void swanSong();
#if USE_SSL
- bool switchToHttps();
+ /// Start to create dynamic SSL_CTX for host or uses static port SSL context.
+ bool getSslContextStart();
+ /**
+ * Done create dynamic ssl certificate.
+ *
+ * \param[in] isNew if generated certificate is new, so we need to add this certificate to storage.
+ */
+ bool getSslContextDone(SSL_CTX * sslContext, bool isNew = false);
+ /// Callback function. It is called when squid receive message from ssl_crtd.
+ static void sslCrtdHandleReplyWrapper(void *data, char *reply);
+ /// Proccess response from ssl_crtd.
+ void sslCrtdHandleReply(const char * reply);
+
+ bool switchToHttps(const char *host);
bool switchedToHttps() const { return switchedToHttps_; }
#else
bool switchedToHttps() const { return false; }
@@ -282,6 +295,7 @@
bool closing_;
bool switchedToHttps_;
+ String sslHostName; ///< Host name for SSL certificate generation
AsyncCall::Pointer reader; ///< set when we are reading
BodyPipe::Pointer bodyPipe; // set when we are reading request body
};
diff -u -r -N squid-3.1.12/src/client_side_request.cc squid-3.1.12.1/src/client_side_request.cc
--- squid-3.1.12/src/client_side_request.cc 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/client_side_request.cc 2011-04-19 17:27:09.000000000 +1200
@@ -1183,7 +1183,7 @@
return;
}
- getConn()->switchToHttps();
+ getConn()->switchToHttps(request->GetHost());
}
void
diff -u -r -N squid-3.1.12/src/client_side_request.cci squid-3.1.12.1/src/client_side_request.cci
--- squid-3.1.12/src/client_side_request.cci 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/client_side_request.cci 2011-04-19 17:27:09.000000000 +1200
@@ -50,15 +50,6 @@
}
ConnStateData *
-ClientHttpRequest::getConn()
-{
- if (!cbdataReferenceValid(conn_))
- return NULL;
-
- return conn_;
-}
-
-ConnStateData * const
ClientHttpRequest::getConn() const
{
if (!cbdataReferenceValid(conn_))
diff -u -r -N squid-3.1.12/src/client_side_request.h squid-3.1.12.1/src/client_side_request.h
--- squid-3.1.12/src/client_side_request.h 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/client_side_request.h 2011-04-19 17:27:09.000000000 +1200
@@ -93,8 +93,7 @@
_SQUID_INLINE_ StoreEntry *loggingEntry() const;
void loggingEntry(StoreEntry *);
- _SQUID_INLINE_ ConnStateData * getConn();
- _SQUID_INLINE_ ConnStateData * const getConn() const;
+ _SQUID_INLINE_ ConnStateData * getConn() const;
_SQUID_INLINE_ void setConn(ConnStateData *);
HttpRequest *request; /* Parsed URL ... */
char *uri;
diff -u -r -N squid-3.1.12/src/comm.cc squid-3.1.12.1/src/comm.cc
--- squid-3.1.12/src/comm.cc 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/comm.cc 2011-04-19 17:27:09.000000000 +1200
@@ -1550,6 +1550,10 @@
F->ssl = NULL;
}
+ if (F->dynamicSslContext) {
+ SSL_CTX_free(F->dynamicSslContext);
+ F->dynamicSslContext = NULL;
+ }
#endif
fd_close(fd); /* update fdstat */
diff -u -r -N squid-3.1.12/src/comm_poll.cc squid-3.1.12.1/src/comm_poll.cc
--- squid-3.1.12/src/comm_poll.cc 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/comm_poll.cc 2011-04-19 17:27:09.000000000 +1200
@@ -402,7 +402,7 @@
* Note that this will only ever trigger when there are no log files
* and stdout/err/in are all closed too.
*/
- if (nfds == 0 && !npending) {
+ if (nfds == 0 && npending == 0) {
if (shutting_down)
return COMM_SHUTDOWN;
else
@@ -416,7 +416,7 @@
++statCounter.select_loops;
PROF_stop(comm_poll_normal);
- if (num >= 0 || npending >= 0)
+ if (num >= 0 || npending > 0)
break;
if (ignoreErrno(errno))
diff -u -r -N squid-3.1.12/src/DiskIO/AIO/async_io.h squid-3.1.12.1/src/DiskIO/AIO/async_io.h
--- squid-3.1.12/src/DiskIO/AIO/async_io.h 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/DiskIO/AIO/async_io.h 2011-04-19 17:27:09.000000000 +1200
@@ -34,7 +34,6 @@
AQ_ENTRY_WRITE
} async_queue_entry_type_t;
-
typedef struct _async_queue_entry async_queue_entry_t;
typedef struct _async_queue async_queue_t;
@@ -47,7 +46,12 @@
async_queue_entry_state_t aq_e_state;
async_queue_entry_type_t aq_e_type;
+ /* 64-bit environments with non-GCC complain about the type mismatch on Linux */
+#if defined(__USE_FILE_OFFSET64) && !defined(__GNUC__)
+ struct aiocb64 aq_e_aiocb;
+#else
struct aiocb aq_e_aiocb;
+#endif
AIODiskFile *theFile;
void *aq_e_callback_data;
FREE *aq_e_free;
diff -u -r -N squid-3.1.12/src/dns_internal.cc squid-3.1.12.1/src/dns_internal.cc
--- squid-3.1.12/src/dns_internal.cc 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/dns_internal.cc 2011-04-19 17:27:09.000000000 +1200
@@ -1574,13 +1574,11 @@
", id = 0x" << std::hex << q->id);
q->callback = callback;
-
q->callback_data = cbdataReference(data);
q->start_t = current_time;
idnsCacheQuery(q);
-
idnsSendQuery(q);
}
@@ -1626,13 +1624,11 @@
", id = 0x" << std::hex << q->id);
q->callback = callback;
-
q->callback_data = cbdataReference(data);
q->start_t = current_time;
idnsCacheQuery(q);
-
idnsSendQuery(q);
}
diff -u -r -N squid-3.1.12/src/errorpage.cc squid-3.1.12.1/src/errorpage.cc
--- squid-3.1.12/src/errorpage.cc 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/errorpage.cc 2011-04-19 17:27:09.000000000 +1200
@@ -508,6 +508,9 @@
if (err->err_language != Config.errorDefaultLanguage)
#endif
safe_free(err->err_language);
+#if USE_SSL
+ delete err->detail;
+#endif
cbdataFree(err);
}
@@ -597,7 +600,7 @@
#define CVT_BUF_SZ 512
const char *
-ErrorState::Convert(char token)
+ErrorState::Convert(char token, bool allowRecursion)
{
static MemBuf mb;
const char *p = NULL; /* takes priority over mb if set */
@@ -628,6 +631,25 @@
break;
+ case 'D':
+ if (!allowRecursion)
+ p = "%D"; // if recursion is not allowed, do not convert
+#if USE_SSL
+ // currently only SSL error details implemented
+ else if (detail) {
+ const String &errDetail = detail->toString();
+ if (errDetail.defined()) {
+ MemBuf *detail_mb = ConvertText(errDetail.termedBuf(), false);
+ mb.append(detail_mb->content(), detail_mb->contentSize());
+ delete detail_mb;
+ do_quote = 0;
+ }
+ }
+#endif
+ if (!mb.contentSize())
+ mb.Printf("[No Error Detail]");
+ break;
+
case 'e':
mb.Printf("%d", xerrno);
@@ -929,10 +951,7 @@
MemBuf *
ErrorState::BuildContent()
{
- MemBuf *content = new MemBuf;
const char *m = NULL;
- const char *p;
- const char *t;
assert(page_id > ERR_NONE && page_id < error_page_count);
@@ -1051,12 +1070,25 @@
debugs(4, 2, HERE << "No existing error page language negotiated for " << errorPageName(page_id) << ". Using default error file.");
}
+ MemBuf *result = ConvertText(m, true);
+#if USE_ERR_LOCALES
+ safe_free(freePage);
+#endif
+
+ return result;
+}
+
+MemBuf *ErrorState::ConvertText(const char *text, bool allowRecursion)
+{
+ MemBuf *content = new MemBuf;
+ const char *p;
+ const char *m = text;
assert(m);
content->init();
while ((p = strchr(m, '%'))) {
content->append(m, p - m); /* copy */
- t = Convert(*++p); /* convert */
+ const char *t = Convert(*++p, allowRecursion); /* convert */
content->Printf("%s", t); /* copy */
m = p + 1; /* advance */
}
@@ -1066,9 +1098,5 @@
assert((size_t)content->contentSize() == strlen(content->content()));
-#if USE_ERR_LOCALES
- safe_free(freePage);
-#endif
-
return content;
}
diff -u -r -N squid-3.1.12/src/errorpage.h squid-3.1.12.1/src/errorpage.h
--- squid-3.1.12/src/errorpage.h 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/errorpage.h 2011-04-19 17:27:09.000000000 +1200
@@ -37,6 +37,9 @@
#include "squid.h"
#include "cbdata.h"
#include "ip/IpAddress.h"
+#if USE_SSL
+#include "ssl/ErrorDetail.h"
+#endif
/**
\defgroup ErrorPageAPI Error Pages API
@@ -48,6 +51,7 @@
B - URL with FTP %2f hack x
c - Squid error code x
d - seconds elapsed since request received x
+ D - Error details x
e - errno x
E - strerror() x
f - FTP request line x
@@ -99,9 +103,18 @@
MemBuf *BuildContent(void);
/**
+ * Convert the given template string into textual output
+ *
+ * \param text The string to be converted
+ * \param allowRecursion Whether to convert codes which output may contain codes
+ */
+ MemBuf *ConvertText(const char *text, bool allowRecursion);
+
+ /**
* Convert an error template into an error page.
+ * \ allowRecursion True if the codes which do recursions should converted
*/
- const char *Convert(char token);
+ const char *Convert(char token, bool allowRecursion);
/**
* CacheManager / Debug dump of the ErrorState object.
@@ -141,6 +154,9 @@
char *request_hdrs;
char *err_msg; /* Preformatted error message from the cache */
+#if USE_SSL
+ Ssl::ErrorDetail *detail;
+#endif
private:
CBDATA_CLASS2(ErrorState);
};
diff -u -r -N squid-3.1.12/src/fde.h squid-3.1.12.1/src/fde.h
--- squid-3.1.12/src/fde.h 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/fde.h 2011-04-19 17:27:09.000000000 +1200
@@ -102,6 +102,7 @@
WRITE_HANDLER *write_method;
#if USE_SSL
SSL *ssl;
+ SSL_CTX *dynamicSslContext; ///< cached and then freed when fd is closed
#endif
#ifdef _SQUID_MSWIN_
struct {
diff -u -r -N squid-3.1.12/src/forward.cc squid-3.1.12.1/src/forward.cc
--- squid-3.1.12/src/forward.cc 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/forward.cc 2011-04-19 17:27:09.000000000 +1200
@@ -48,6 +48,10 @@
#include "icmp/net_db.h"
#include "ip/IpIntercept.h"
#include "ip/tools.h"
+#if USE_SSL
+#include "ssl_support.h"
+#include "ssl/ErrorDetail.h"
+#endif
static PSC fwdStartCompleteWrapper;
static PF fwdServerClosedWrapper;
@@ -605,6 +609,14 @@
anErr->xerrno = EACCES;
#endif
+ Ssl::ErrorDetail *errFromFailure = (Ssl::ErrorDetail *)SSL_get_ex_data(ssl, ssl_ex_index_ssl_error_detail);
+ if (errFromFailure != NULL) {
+ // The errFromFailure is attached to the ssl object
+ // and will be released when ssl object destroyed.
+ // Copy errFromFailure to a new Ssl::ErrorDetail object
+ anErr->detail = new Ssl::ErrorDetail(*errFromFailure);
+ }
+
fail(anErr);
if (fs->_peer) {
diff -u -r -N squid-3.1.12/src/fs/ufs/store_dir_ufs.cc squid-3.1.12.1/src/fs/ufs/store_dir_ufs.cc
--- squid-3.1.12/src/fs/ufs/store_dir_ufs.cc 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/fs/ufs/store_dir_ufs.cc 2011-04-19 17:27:09.000000000 +1200
@@ -1063,7 +1063,6 @@
{
DIR *dir_pointer = NULL;
- struct dirent *de = NULL;
LOCAL_ARRAY(char, p1, MAXPATHLEN + 1);
LOCAL_ARRAY(char, p2, MAXPATHLEN + 1);
@@ -1107,6 +1106,7 @@
return 0;
}
+ dirent_t *de;
while ((de = readdir(dir_pointer)) != NULL && k < 20) {
if (sscanf(de->d_name, "%X", &swapfileno) != 1)
continue;
diff -u -r -N squid-3.1.12/src/fs/ufs/ufscommon.h squid-3.1.12.1/src/fs/ufs/ufscommon.h
--- squid-3.1.12/src/fs/ufs/ufscommon.h 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/fs/ufs/ufscommon.h 2011-04-19 17:27:09.000000000 +1200
@@ -399,7 +399,7 @@
int done;
int fn;
- struct dirent *entry;
+ dirent_t *entry;
DIR *td;
char fullpath[SQUID_MAXPATHLEN];
char fullfilename[SQUID_MAXPATHLEN];
diff -u -r -N squid-3.1.12/src/ftp.cc squid-3.1.12.1/src/ftp.cc
--- squid-3.1.12/src/ftp.cc 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/ftp.cc 2011-04-19 17:27:09.000000000 +1200
@@ -1362,7 +1362,7 @@
IOStats.Ftp.read_hist[bin]++;
}
- if (io.flag != COMM_OK || io.size < 0) {
+ if (io.flag != COMM_OK) {
debugs(50, ignoreErrno(io.xerrno) ? 3 : DBG_IMPORTANT,
"ftpDataRead: read error: " << xstrerr(io.xerrno));
@@ -1859,7 +1859,7 @@
fd_bytes(io.fd, io.size, FD_READ);
}
- if (io.flag != COMM_OK || io.size < 0) {
+ if (io.flag != COMM_OK) {
debugs(50, ignoreErrno(io.xerrno) ? 3 : DBG_IMPORTANT,
"ftpReadControlReply: read error: " << xstrerr(io.xerrno));
@@ -1868,9 +1868,7 @@
} else {
failed(ERR_READ_ERROR, io.xerrno);
/* failed closes ctrl.fd and frees ftpState */
- return;
}
-
return;
}
diff -u -r -N squid-3.1.12/src/globals.h squid-3.1.12.1/src/globals.h
--- squid-3.1.12/src/globals.h 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/globals.h 2011-04-19 17:27:09.000000000 +1200
@@ -172,6 +172,7 @@
extern int ssl_ex_index_server; /* -1 */
extern int ssl_ctx_ex_index_dont_verify_domain; /* -1 */
extern int ssl_ex_index_cert_error_check; /* -1 */
+ extern int ssl_ex_index_ssl_error_detail; /* -1 */
extern const char *external_acl_message; /* NULL */
extern int opt_send_signal; /* -1 */
diff -u -r -N squid-3.1.12/src/helper.cc squid-3.1.12.1/src/helper.cc
--- squid-3.1.12/src/helper.cc 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/helper.cc 2011-04-19 17:27:09.000000000 +1200
@@ -838,6 +838,55 @@
cbdataFree(srv);
}
+/// Calls back with a pointer to the buffer with the helper output
+static void helperReturnBuffer(int request_number, helper_server * srv, helper * hlp, char * msg, char * msg_end)
+{
+ helper_request *r = srv->requests[request_number];
+ if (r) {
+ HLPCB *callback = r->callback;
+
+ srv->requests[request_number] = NULL;
+
+ r->callback = NULL;
+
+ void *cbdata = NULL;
+ if (cbdataReferenceValidDone(r->data, &cbdata))
+ callback(cbdata, msg);
+
+ srv->stats.pending--;
+
+ hlp->stats.replies++;
+
+ srv->answer_time = current_time;
+
+ srv->dispatch_time = r->dispatch_time;
+
+ hlp->stats.avg_svc_time =
+ Math::intAverage(hlp->stats.avg_svc_time,
+ tvSubMsec(r->dispatch_time, current_time),
+ hlp->stats.replies, REDIRECT_AV_FACTOR);
+
+ helperRequestFree(r);
+ } else {
+ debugs(84, 1, "helperHandleRead: unexpected reply on channel " <<
+ request_number << " from " << hlp->id_name << " #" << srv->index + 1 <<
+ " '" << srv->rbuf << "'");
+ }
+ srv->roffset -= (msg_end - srv->rbuf);
+ memmove(srv->rbuf, msg_end, srv->roffset + 1);
+
+ if (!srv->flags.shutdown) {
+ helperKickQueue(hlp);
+ } else if (!srv->flags.closing && !srv->stats.pending) {
+ int wfd = srv->wfd;
+ srv->wfd = -1;
+ if (srv->rfd == wfd)
+ srv->rfd = -1;
+ srv->flags.closing=1;
+ comm_close(wfd);
+ return;
+ }
+}
static void
helperHandleRead(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, void *data)
@@ -857,12 +906,8 @@
debugs(84, 5, "helperHandleRead: " << len << " bytes from " << hlp->id_name << " #" << srv->index + 1);
- if (flag != COMM_OK || len <= 0) {
- if (len < 0)
- debugs(84, 1, "helperHandleRead: FD " << fd << " read: " << xstrerror());
-
+ if (flag != COMM_OK || len == 0) {
comm_close(fd);
-
return;
}
@@ -880,69 +925,29 @@
srv->rbuf[0] = '\0';
}
- while ((t = strchr(srv->rbuf, '\n'))) {
- /* end of reply found */
- helper_request *r;
- char *msg = srv->rbuf;
- int i = 0;
- debugs(84, 3, "helperHandleRead: end of reply found");
-
- if (t > srv->rbuf && t[-1] == '\r')
- t[-1] = '\0';
-
- *t++ = '\0';
-
- if (hlp->concurrency) {
- i = strtol(msg, &msg, 10);
+ if (hlp->return_full_reply) {
+ debugs(84, 3, HERE << "Return entire buffer");
+ helperReturnBuffer(0, srv, hlp, srv->rbuf, srv->rbuf + srv->roffset);
+ } else {
+ while ((t = strchr(srv->rbuf, '\n'))) {
+ /* end of reply found */
+ char *msg = srv->rbuf;
+ int i = 0;
+ debugs(84, 3, "helperHandleRead: end of reply found");
+
+ if (t > srv->rbuf && t[-1] == '\r')
+ t[-1] = '\0';
+
+ *t++ = '\0';
+
+ if (hlp->concurrency) {
+ i = strtol(msg, &msg, 10);
+
+ while (*msg && xisspace(*msg))
+ msg++;
+ }
- while (*msg && xisspace(*msg))
- msg++;
- }
-
- r = srv->requests[i];
-
- if (r) {
- HLPCB *callback = r->callback;
- void *cbdata;
-
- srv->requests[i] = NULL;
-
- r->callback = NULL;
-
- if (cbdataReferenceValidDone(r->data, &cbdata))
- callback(cbdata, msg);
-
- srv->stats.pending--;
-
- hlp->stats.replies++;
-
- srv->answer_time = current_time;
-
- srv->dispatch_time = r->dispatch_time;
-
- hlp->stats.avg_svc_time = Math::intAverage(hlp->stats.avg_svc_time, tvSubMsec(r->dispatch_time, current_time), hlp->stats.replies, REDIRECT_AV_FACTOR);
-
- helperRequestFree(r);
- } else {
- debugs(84, 1, "helperHandleRead: unexpected reply on channel " <<
- i << " from " << hlp->id_name << " #" << srv->index + 1 <<
- " '" << srv->rbuf << "'");
-
- }
-
- srv->roffset -= (t - srv->rbuf);
- memmove(srv->rbuf, t, srv->roffset + 1);
-
- if (!srv->flags.shutdown) {
- helperKickQueue(hlp);
- } else if (!srv->flags.closing && !srv->stats.pending) {
- int wfd = srv->wfd;
- srv->wfd = -1;
- if (srv->rfd == wfd)
- srv->rfd = -1;
- srv->flags.closing=1;
- comm_close(wfd);
- return;
+ helperReturnBuffer(i, srv, hlp, msg, t);
}
}
@@ -971,12 +976,8 @@
hlp->id_name << " #" << srv->index + 1);
- if (flag != COMM_OK || len <= 0) {
- if (len < 0)
- debugs(84, 1, "helperStatefulHandleRead: FD " << fd << " read: " << xstrerror());
-
+ if (flag != COMM_OK || len == 0) {
comm_close(fd);
-
return;
}
diff -u -r -N squid-3.1.12/src/helper.h squid-3.1.12.1/src/helper.h
--- squid-3.1.12/src/helper.h 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/helper.h 2011-04-19 17:27:09.000000000 +1200
@@ -73,6 +73,8 @@
int queue_size;
int avg_svc_time;
} stats;
+ /// True if callback expects the whole helper output, as a c-string.
+ bool return_full_reply;
};
struct _helper_stateful {
diff -u -r -N squid-3.1.12/src/htcp.h squid-3.1.12.1/src/htcp.h
--- squid-3.1.12/src/htcp.h 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/htcp.h 2011-04-19 17:27:09.000000000 +1200
@@ -33,6 +33,7 @@
#if USE_HTCP
#include "HttpHeader.h"
+#include "typedefs.h"
class IpAddress;
diff -u -r -N squid-3.1.12/src/HttpHeader.cc squid-3.1.12.1/src/HttpHeader.cc
--- squid-3.1.12/src/HttpHeader.cc 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/HttpHeader.cc 2011-04-19 17:27:09.000000000 +1200
@@ -1715,15 +1715,14 @@
http_hdr_type
httpHeaderIdByName(const char *name, size_t name_len, const HttpHeaderFieldInfo * info, int end)
{
- int i;
+ if (name_len > 0) {
+ for (int i = 0; i < end; ++i) {
+ if (name_len != info[i].name.size())
+ continue;
- for (i = 0; i < end; ++i) {
- if (name_len >= 0 && name_len != info[i].name.size())
- continue;
-
- if (!strncasecmp(name, info[i].name.termedBuf(),
- name_len < 0 ? info[i].name.size() + 1 : name_len))
- return info[i].id;
+ if (!strncasecmp(name, info[i].name.termedBuf(), name_len))
+ return info[i].id;
+ }
}
return HDR_BAD_HDR;
diff -u -r -N squid-3.1.12/src/HttpRequest.h squid-3.1.12.1/src/HttpRequest.h
--- squid-3.1.12/src/HttpRequest.h 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/HttpRequest.h 2011-04-19 17:27:09.000000000 +1200
@@ -104,7 +104,7 @@
}
};
inline const char* GetHost(void) const { return host; };
- inline const int GetHostIsNumeric(void) const { return host_is_numeric; };
+ inline int GetHostIsNumeric(void) const { return host_is_numeric; };
#if USE_ADAPTATION
/// Returns possibly nil history, creating it if adapt. logging is enabled
diff -u -r -N squid-3.1.12/src/HttpRequestMethod.h squid-3.1.12.1/src/HttpRequestMethod.h
--- squid-3.1.12/src/HttpRequestMethod.h 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/HttpRequestMethod.h 2011-04-19 17:27:09.000000000 +1200
@@ -137,10 +137,10 @@
\retval METHOD_OTHER the method is not recognized and has no unique ID
\retval * the method is on of the recognized HTTP methods.
*/
- _method_t const id() const { return theMethod; }
+ _method_t id() const { return theMethod; }
/** Get a char string representation of the method. */
- char const* image() const;
+ char const * image() const;
bool isCacheble() const;
bool purgesOthers() const;
diff -u -r -N squid-3.1.12/src/ip/IpAddress.cc squid-3.1.12.1/src/ip/IpAddress.cc
--- squid-3.1.12/src/ip/IpAddress.cc 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/ip/IpAddress.cc 2011-04-19 17:27:09.000000000 +1200
@@ -773,7 +773,7 @@
/* some external code may have blindly memset a parent. */
/* thats okay, our default is known */
if ( IsAnyAddr() ) {
- memcpy(buf,"::\0", min((const unsigned int)3,blen));
+ memcpy(buf,"::\0", min(static_cast(3),blen));
return buf;
}
@@ -783,7 +783,7 @@
/* However IPv4 CAN. */
if ( force == AF_INET && !IsIPv4() ) {
if ( IsIPv6() ) {
- memcpy(buf, "{!IPv4}\0", min((const unsigned int)8,blen));
+ memcpy(buf, "{!IPv4}\0", min(static_cast(8),blen));
}
return buf;
}
@@ -802,7 +802,7 @@
force << "). accepted={" << AF_UNSPEC << "," << AF_INET << "," << AF_INET6 << "}");
fprintf(stderr,"WARNING: Corrupt IP Address details OR required to display in unknown format (%d). accepted={%d,%d,%d} ",
force, AF_UNSPEC, AF_INET, AF_INET6);
- memcpy(buf,"dead:beef::\0", min((const unsigned int)13,blen));
+ memcpy(buf,"dead:beef::\0", min(static_cast(13),blen));
assert(false);
}
diff -u -r -N squid-3.1.12/src/LeakFinder.h squid-3.1.12.1/src/LeakFinder.h
--- squid-3.1.12/src/LeakFinder.h 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/LeakFinder.h 2011-04-19 17:27:09.000000000 +1200
@@ -1,10 +1,10 @@
-
-
-
#ifndef SQUID_LEAKFINDER_H
#define SQUID_LEAKFINDER_H
#if USE_LEAKFINDER
+
+#include "hash.h"
+
#define leakAdd(p,l) if (l) l->add(p,__FILE__,__LINE__)
#define leakTouch(p,l) if (l) l->touch(p,__FILE__,__LINE__)
#define leakFree(p,l) if (l) l->free(p,__FILE__,__LINE__)
diff -u -r -N squid-3.1.12/src/main.cc squid-3.1.12.1/src/main.cc
--- squid-3.1.12/src/main.cc 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/main.cc 2011-04-19 17:27:09.000000000 +1200
@@ -80,6 +80,15 @@
#include "LoadableModules.h"
#endif
+#if USE_SSL_CRTD
+#include "ssl/helper.h"
+#include "ssl/certificate_db.h"
+#endif
+
+#if USE_SSL
+#include "ssl/context_storage.h"
+#endif
+
#if ICAP_CLIENT
#include "adaptation/icap/Config.h"
#endif
@@ -691,7 +700,12 @@
idnsShutdown();
#endif
-
+#if USE_SSL_CRTD
+ Ssl::Helper::GetInstance()->Shutdown();
+#endif
+#if USE_SSL
+ Ssl::TheGlobalContextStorage.reconfigureStart();
+#endif
redirectShutdown();
authenticateShutdown();
externalAclShutdown();
@@ -767,6 +781,9 @@
idnsInit();
#endif
+#if USE_SSL_CRTD
+ Ssl::Helper::GetInstance()->Init();
+#endif
redirectInit();
authenticateInit(&Config.authConfiguration);
@@ -1701,7 +1718,9 @@
idnsShutdown();
#endif
-
+#if USE_SSL_CRTD
+ Ssl::Helper::GetInstance()->Shutdown();
+#endif
redirectShutdown();
externalAclShutdown();
icpConnectionClose();
diff -u -r -N squid-3.1.12/src/Makefile.am squid-3.1.12.1/src/Makefile.am
--- squid-3.1.12/src/Makefile.am 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/Makefile.am 2011-04-19 17:27:09.000000000 +1200
@@ -112,8 +112,13 @@
if ENABLE_SSL
SSL_SOURCE = $(SSL_ALL_SOURCE)
+SUBDIRS += ssl
+SSL_LIBS = \
+ ssl/libsslutil.la \
+ ssl/libsslsquid.la
else
SSL_SOURCE =
+SSL_LIBS =
endif
WIN32_ALL_SOURCE = \
@@ -531,6 +536,7 @@
${ADAPTATION_LIBS} \
$(ESI_LIBS) \
$(SSLLIB) \
+ $(SSL_LIBS) \
-lmiscutil \
$(EPOLL_LIBS) \
$(MINGW_LIBS) \
@@ -715,6 +721,7 @@
DEFAULT_CONFIG_FILE = $(DEFAULT_CONFIG_DIR)/squid.conf
DEFAULT_MIME_TABLE = $(DEFAULT_CONFIG_DIR)/mime.conf
DEFAULT_DNSSERVER = $(libexecdir)/`echo dnsserver | sed '$(transform);s/$$/$(EXEEXT)/'`
+DEFAULT_SSL_CRTD = $(libexecdir)/`echo ssl_crtd | sed '$(transform);s/$$/$(EXEEXT)/'`
DEFAULT_LOG_PREFIX = $(DEFAULT_LOG_DIR)
DEFAULT_CACHE_LOG = $(DEFAULT_LOG_PREFIX)/cache.log
DEFAULT_ACCESS_LOG = $(DEFAULT_LOG_PREFIX)/access.log
@@ -722,6 +729,7 @@
DEFAULT_PID_FILE = $(DEFAULT_PIDFILE)
DEFAULT_NETDB_FILE = $(DEFAULT_LOG_PREFIX)/netdb.state
DEFAULT_SWAP_DIR = $(localstatedir)/cache
+DEFAULT_SSL_DB_DIR = $(localstatedir)/lib/ssl_db
DEFAULT_PINGER = $(libexecdir)/`echo pinger | sed '$(transform);s/$$/$(EXEEXT)/'`
DEFAULT_UNLINKD = $(libexecdir)/`echo unlinkd | sed '$(transform);s/$$/$(EXEEXT)/'`
DEFAULT_DISKD = $(libexecdir)/`echo diskd | sed '$(transform);s/$$/$(EXEEXT)/'`
@@ -769,6 +777,7 @@
-e "s%[@]DEFAULT_CACHE_EFFECTIVE_USER[@]%${CACHE_EFFECTIVE_USER}%g" \
-e "s%[@]DEFAULT_MIME_TABLE[@]%$(DEFAULT_MIME_TABLE)%g" \
-e "s%[@]DEFAULT_DNSSERVER[@]%$(DEFAULT_DNSSERVER)%g" \
+ -e "s%[@]DEFAULT_SSL_CRTD[@]%$(DEFAULT_SSL_CRTD)%g" \
-e "s%[@]DEFAULT_UNLINKD[@]%$(DEFAULT_UNLINKD)%g" \
-e "s%[@]DEFAULT_PINGER[@]%$(DEFAULT_PINGER)%g" \
-e "s%[@]DEFAULT_DISKD[@]%$(DEFAULT_DISKD)%g" \
@@ -778,6 +787,7 @@
-e "s%[@]DEFAULT_PID_FILE[@]%$(DEFAULT_PID_FILE)%g" \
-e "s%[@]DEFAULT_NETDB_FILE[@]%$(DEFAULT_NETDB_FILE)%g" \
-e "s%[@]DEFAULT_SWAP_DIR[@]%$(DEFAULT_SWAP_DIR)%g" \
+ -e "s%[@]DEFAULT_SSL_DB_DIR[@]%$(DEFAULT_SSL_DB_DIR)%g" \
-e "s%[@]DEFAULT_ICON_DIR[@]%$(DEFAULT_ICON_DIR)%g" \
-e "s%[@]DEFAULT_CONFIG_DIR[@]%$(DEFAULT_CONFIG_DIR)%g" \
-e "s%[@]DEFAULT_PREFIX[@]%$(DEFAULT_PREFIX)%g" \
@@ -1195,6 +1205,7 @@
$(SQUID_CPPUNIT_LIBS) \
$(SQUID_CPPUNIT_LA) \
$(SSLLIB) \
+ $(SSL_LIBS) \
$(XTRA_LIBS)
tests_testCacheManager_LDFLAGS = $(LIBADD_DL)
tests_testCacheManager_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \
@@ -1370,6 +1381,7 @@
$(SQUID_CPPUNIT_LIBS) \
$(SQUID_CPPUNIT_LA) \
$(SSLLIB) \
+ $(SSL_LIBS) \
$(XTRA_LIBS)
tests_testEvent_LDFLAGS = $(LIBADD_DL)
tests_testEvent_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \
@@ -1520,6 +1532,7 @@
$(SQUID_CPPUNIT_LIBS) \
$(SQUID_CPPUNIT_LA) \
$(SSLLIB) \
+ $(SSL_LIBS) \
$(XTRA_LIBS)
tests_testEventLoop_LDFLAGS = $(LIBADD_DL)
tests_testEventLoop_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \
@@ -1665,6 +1678,7 @@
$(SQUID_CPPUNIT_LIBS) \
$(SQUID_CPPUNIT_LA) \
$(SSLLIB) \
+ $(SSL_LIBS) \
$(XTRA_LIBS)
tests_test_http_range_LDFLAGS = $(LIBADD_DL)
tests_test_http_range_DEPENDENCIES = \
@@ -1815,6 +1829,7 @@
$(SQUID_CPPUNIT_LIBS) \
$(SQUID_CPPUNIT_LA) \
$(SSLLIB) \
+ $(SSL_LIBS) \
$(XTRA_LIBS)
tests_testHttpRequest_LDFLAGS = $(LIBADD_DL)
tests_testHttpRequest_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \
@@ -2177,6 +2192,7 @@
$(SQUID_CPPUNIT_LIBS) \
$(SQUID_CPPUNIT_LA) \
$(SSLLIB) \
+ $(SSL_LIBS) \
$(XTRA_LIBS)
tests_testURL_LDFLAGS = $(LIBADD_DL)
tests_testURL_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \
diff -u -r -N squid-3.1.12/src/Makefile.in squid-3.1.12.1/src/Makefile.in
--- squid-3.1.12/src/Makefile.in 2011-04-04 13:24:50.000000000 +1200
+++ squid-3.1.12.1/src/Makefile.in 2011-04-19 17:28:05.000000000 +1200
@@ -57,6 +57,7 @@
@USE_LOADABLE_MODULES_TRUE@am__append_1 = $(INCLTDL)
@USE_ADAPTATION_TRUE@am__append_2 = adaptation
@USE_ESI_TRUE@am__append_3 = esi
+@ENABLE_SSL_TRUE@am__append_4 = ssl
EXTRA_PROGRAMS = DiskIO/DiskDaemon/diskd$(EXEEXT) unlinkd$(EXEEXT) \
dnsserver$(EXEEXT) recv-announce$(EXEEXT) \
tests/testUfs$(EXEEXT) tests/testCoss$(EXEEXT) \
@@ -65,8 +66,8 @@
sbin_PROGRAMS = squid$(EXEEXT)
bin_PROGRAMS =
libexec_PROGRAMS = $(am__EXEEXT_1) $(DISK_PROGRAMS) $(am__EXEEXT_2)
-@USE_LOADABLE_MODULES_TRUE@am__append_4 = $(LOADABLE_MODULES_SOURCES)
-@USE_LOADABLE_MODULES_TRUE@am__append_5 = \
+@USE_LOADABLE_MODULES_TRUE@am__append_5 = $(LOADABLE_MODULES_SOURCES)
+@USE_LOADABLE_MODULES_TRUE@am__append_6 = \
@USE_LOADABLE_MODULES_TRUE@ $(LIBLTDL)
subdir = src
@@ -332,7 +333,9 @@
squid_OBJECTS = $(am_squid_OBJECTS) $(nodist_squid_OBJECTS)
@USE_ESI_TRUE@am__DEPENDENCIES_2 = $(ESI_LOCAL_LIBS) \
@USE_ESI_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
-@USE_LOADABLE_MODULES_TRUE@am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1)
+@ENABLE_SSL_TRUE@am__DEPENDENCIES_3 = ssl/libsslutil.la \
+@ENABLE_SSL_TRUE@ ssl/libsslsquid.la
+@USE_LOADABLE_MODULES_TRUE@am__DEPENDENCIES_4 = $(am__DEPENDENCIES_1)
squid_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
$(squid_LDFLAGS) $(LDFLAGS) -o $@
@@ -563,7 +566,7 @@
nodist_tests_testCoss_OBJECTS = $(am__objects_29)
tests_testCoss_OBJECTS = $(am_tests_testCoss_OBJECTS) \
$(nodist_tests_testCoss_OBJECTS)
-am__DEPENDENCIES_4 = $(am__DEPENDENCIES_1) $(COMMON_LIBS) \
+am__DEPENDENCIES_5 = $(am__DEPENDENCIES_1) $(COMMON_LIBS) \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1) acl/libapi.la $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1)
@@ -1369,7 +1372,7 @@
CTAGS = ctags
am__tty_colors = \
red=; grn=; lgn=; blu=; std=
-DIST_SUBDIRS = base acl fs repl auth ip icmp ident adaptation esi
+DIST_SUBDIRS = base acl fs repl auth ip icmp ident adaptation esi ssl
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
am__relativize = \
dir0=`pwd`; \
@@ -1626,7 +1629,7 @@
LoadableModules.cc
SUBDIRS = base acl fs repl auth ip icmp ident $(am__append_2) \
- $(am__append_3)
+ $(am__append_3) $(am__append_4)
@USE_ESI_TRUE@ESI_LOCAL_LIBS = \
@USE_ESI_TRUE@ esi/libesi.la \
@USE_ESI_TRUE@ $(top_builddir)/lib/libTrie/src/libTrie.a
@@ -1678,6 +1681,11 @@
@ENABLE_SSL_FALSE@SSL_SOURCE =
@ENABLE_SSL_TRUE@SSL_SOURCE = $(SSL_ALL_SOURCE)
+@ENABLE_SSL_FALSE@SSL_LIBS =
+@ENABLE_SSL_TRUE@SSL_LIBS = \
+@ENABLE_SSL_TRUE@ ssl/libsslutil.la \
+@ENABLE_SSL_TRUE@ ssl/libsslsquid.la
+
WIN32_ALL_SOURCE = \
win32.cc \
WinSvc.cc
@@ -1843,7 +1851,7 @@
typedefs.h $(UNLINKDSOURCE) url.cc URL.h URLScheme.cc \
URLScheme.h urn.cc useragent.cc wccp.cc wccp2.cc whois.cc \
wordlist.cc wordlist.h $(WIN32_SOURCE) $(WINSVC_SOURCE) \
- $(am__append_4)
+ $(am__append_5)
noinst_HEADERS = \
client_side_request.cci \
MemBuf.cci \
@@ -1865,8 +1873,8 @@
../compat/libcompat.la -L../lib $(XTRA_OBJS) $(DISK_LINKOBJS) \
$(REPL_OBJS) $(DISK_LIBS) $(DISK_OS_LIBS) $(CRYPTLIB) \
$(REGEXLIB) $(SNMPLIB) ${ADAPTATION_LIBS} $(ESI_LIBS) \
- $(SSLLIB) -lmiscutil $(EPOLL_LIBS) $(MINGW_LIBS) $(XTRA_LIBS) \
- $(am__append_5)
+ $(SSLLIB) $(SSL_LIBS) -lmiscutil $(EPOLL_LIBS) $(MINGW_LIBS) \
+ $(XTRA_LIBS) $(am__append_6)
squid_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \
$(DISK_LIBS) \
$(DISK_LINKOBJS) \
@@ -2020,6 +2028,7 @@
DEFAULT_CONFIG_FILE = $(DEFAULT_CONFIG_DIR)/squid.conf
DEFAULT_MIME_TABLE = $(DEFAULT_CONFIG_DIR)/mime.conf
DEFAULT_DNSSERVER = $(libexecdir)/`echo dnsserver | sed '$(transform);s/$$/$(EXEEXT)/'`
+DEFAULT_SSL_CRTD = $(libexecdir)/`echo ssl_crtd | sed '$(transform);s/$$/$(EXEEXT)/'`
DEFAULT_LOG_PREFIX = $(DEFAULT_LOG_DIR)
DEFAULT_CACHE_LOG = $(DEFAULT_LOG_PREFIX)/cache.log
DEFAULT_ACCESS_LOG = $(DEFAULT_LOG_PREFIX)/access.log
@@ -2027,6 +2036,7 @@
DEFAULT_PID_FILE = $(DEFAULT_PIDFILE)
DEFAULT_NETDB_FILE = $(DEFAULT_LOG_PREFIX)/netdb.state
DEFAULT_SWAP_DIR = $(localstatedir)/cache
+DEFAULT_SSL_DB_DIR = $(localstatedir)/lib/ssl_db
DEFAULT_PINGER = $(libexecdir)/`echo pinger | sed '$(transform);s/$$/$(EXEEXT)/'`
DEFAULT_UNLINKD = $(libexecdir)/`echo unlinkd | sed '$(transform);s/$$/$(EXEEXT)/'`
DEFAULT_DISKD = $(libexecdir)/`echo diskd | sed '$(transform);s/$$/$(EXEEXT)/'`
@@ -2373,6 +2383,7 @@
$(SQUID_CPPUNIT_LIBS) \
$(SQUID_CPPUNIT_LA) \
$(SSLLIB) \
+ $(SSL_LIBS) \
$(XTRA_LIBS)
tests_testCacheManager_LDFLAGS = $(LIBADD_DL)
@@ -2552,6 +2563,7 @@
$(SQUID_CPPUNIT_LIBS) \
$(SQUID_CPPUNIT_LA) \
$(SSLLIB) \
+ $(SSL_LIBS) \
$(XTRA_LIBS)
tests_testEvent_LDFLAGS = $(LIBADD_DL)
@@ -2704,6 +2716,7 @@
$(SQUID_CPPUNIT_LIBS) \
$(SQUID_CPPUNIT_LA) \
$(SSLLIB) \
+ $(SSL_LIBS) \
$(XTRA_LIBS)
tests_testEventLoop_LDFLAGS = $(LIBADD_DL)
@@ -2852,6 +2865,7 @@
$(SQUID_CPPUNIT_LIBS) \
$(SQUID_CPPUNIT_LA) \
$(SSLLIB) \
+ $(SSL_LIBS) \
$(XTRA_LIBS)
tests_test_http_range_LDFLAGS = $(LIBADD_DL)
@@ -3003,6 +3017,7 @@
$(SQUID_CPPUNIT_LIBS) \
$(SQUID_CPPUNIT_LA) \
$(SSLLIB) \
+ $(SSL_LIBS) \
$(XTRA_LIBS)
tests_testHttpRequest_LDFLAGS = $(LIBADD_DL)
@@ -3376,6 +3391,7 @@
$(SQUID_CPPUNIT_LIBS) \
$(SQUID_CPPUNIT_LA) \
$(SSLLIB) \
+ $(SSL_LIBS) \
$(XTRA_LIBS)
tests_testURL_LDFLAGS = $(LIBADD_DL)
@@ -4733,6 +4749,7 @@
-e "s%[@]DEFAULT_CACHE_EFFECTIVE_USER[@]%${CACHE_EFFECTIVE_USER}%g" \
-e "s%[@]DEFAULT_MIME_TABLE[@]%$(DEFAULT_MIME_TABLE)%g" \
-e "s%[@]DEFAULT_DNSSERVER[@]%$(DEFAULT_DNSSERVER)%g" \
+ -e "s%[@]DEFAULT_SSL_CRTD[@]%$(DEFAULT_SSL_CRTD)%g" \
-e "s%[@]DEFAULT_UNLINKD[@]%$(DEFAULT_UNLINKD)%g" \
-e "s%[@]DEFAULT_PINGER[@]%$(DEFAULT_PINGER)%g" \
-e "s%[@]DEFAULT_DISKD[@]%$(DEFAULT_DISKD)%g" \
@@ -4742,6 +4759,7 @@
-e "s%[@]DEFAULT_PID_FILE[@]%$(DEFAULT_PID_FILE)%g" \
-e "s%[@]DEFAULT_NETDB_FILE[@]%$(DEFAULT_NETDB_FILE)%g" \
-e "s%[@]DEFAULT_SWAP_DIR[@]%$(DEFAULT_SWAP_DIR)%g" \
+ -e "s%[@]DEFAULT_SSL_DB_DIR[@]%$(DEFAULT_SSL_DB_DIR)%g" \
-e "s%[@]DEFAULT_ICON_DIR[@]%$(DEFAULT_ICON_DIR)%g" \
-e "s%[@]DEFAULT_CONFIG_DIR[@]%$(DEFAULT_CONFIG_DIR)%g" \
-e "s%[@]DEFAULT_PREFIX[@]%$(DEFAULT_PREFIX)%g" \
diff -u -r -N squid-3.1.12/src/ProtoPort.cc squid-3.1.12.1/src/ProtoPort.cc
--- squid-3.1.12/src/ProtoPort.cc 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/ProtoPort.cc 2011-04-19 17:27:09.000000000 +1200
@@ -6,11 +6,14 @@
#include "squid.h"
#include "ProtoPort.h"
+#if HAVE_LIMITS
+#include
+#endif
http_port_list::http_port_list(const char *aProtocol)
#if USE_SSL
:
- http(*this)
+ http(*this), dynamicCertMemCacheSize(std::numeric_limits::max())
#endif
{
protocol = xstrdup(aProtocol);
@@ -31,6 +34,7 @@
safe_free(capath);
safe_free(dhfile);
safe_free(sslflags);
+ safe_free(sslContextSessionId);
#endif
}
diff -u -r -N squid-3.1.12/src/ProtoPort.h squid-3.1.12.1/src/ProtoPort.h
--- squid-3.1.12/src/ProtoPort.h 2011-04-04 13:24:06.000000000 +1200
+++ squid-3.1.12.1/src/ProtoPort.h 2011-04-19 17:27:09.000000000 +1200
@@ -6,6 +6,9 @@
//#include "typedefs.h"
#include "cbdata.h"
+#if USE_SSL
+#include "ssl/gadgets.h"
+#endif
struct http_port_list {
http_port_list(const char *aProtocol);
@@ -52,8 +55,13 @@
char *crlfile;
char *dhfile;
char *sslflags;
- char *sslcontext;
- SSL_CTX *sslContext;
+ char *sslContextSessionId; ///< "session id context" for staticSslContext
+ bool generateHostCertificates; ///< dynamically make host cert for sslBump
+ size_t dynamicCertMemCacheSize; ///< max size of generated certificates memory cache
+
+ Ssl::SSL_CTX_Pointer staticSslContext; ///< for HTTPS accelerator or static sslBump
+ Ssl::X509_Pointer signingCert; ///< x509 certificate for signing generated certificates
+ Ssl::EVP_PKEY_Pointer signPkey; ///< private key for sighing generated certificates
#endif
CBDATA_CLASS2(http_port_list);
diff -u -r -N squid-3.1.12/src/ssl/certificate_db.cc squid-3.1.12.1/src/ssl/certificate_db.cc
--- squid-3.1.12/src/ssl/certificate_db.cc 1970-01-01 12:00:00.000000000 +1200
+++ squid-3.1.12.1/src/ssl/certificate_db.cc 2011-04-19 17:27:09.000000000 +1200
@@ -0,0 +1,487 @@
+/*
+ * $Id$
+ */
+
+#include "config.h"
+#include "util.h"
+#include "ssl/certificate_db.h"
+#if HAVE_FSTREAM
+#include
+#endif
+#if HAVE_STDEXCEPT
+#include
+#endif
+#if HAVE_SYS_STAT_H
+#include
+#endif
+#if HAVE_SYS_FILE_H
+#include
+#endif
+#if HAVE_FCNTL_H
+#include
+#endif
+
+Ssl::FileLocker::FileLocker(std::string const & filename)
+ : fd(-1)
+{
+#if _SQUID_MSWIN_
+ hFile = CreateFile(TEXT(filename.c_str()), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (hFile != INVALID_HANDLE_VALUE)
+ LockFile(hFile, 0, 0, 1, 0);
+#else
+ fd = open(filename.c_str(), 0);
+ if (fd != -1)
+ flock(fd, LOCK_EX);
+#endif
+}
+
+Ssl::FileLocker::~FileLocker()
+{
+#ifdef _SQUID_MSWIN_
+ if (hFile != INVALID_HANDLE_VALUE) {
+ UnlockFile(hFile, 0, 0, 1, 0);
+ CloseHandle(hFile);
+ }
+#else
+ if (fd != -1) {
+ flock(fd, LOCK_UN);
+ close(fd);
+ }
+#endif
+}
+
+Ssl::CertificateDb::Row::Row()
+ : width(cnlNumber)
+{
+ row = new char *[width + 1];
+ for (size_t i = 0; i < width + 1; i++)
+ row[i] = NULL;
+}
+
+Ssl::CertificateDb::Row::~Row()
+{
+ if (row) {
+ for (size_t i = 0; i < width + 1; i++) {
+ delete[](row[i]);
+ }
+ delete[](row);
+ }
+}
+
+void Ssl::CertificateDb::Row::reset()
+{
+ row = NULL;
+}
+
+void Ssl::CertificateDb::Row::setValue(size_t cell, char const * value)
+{
+ assert(cell < width);
+ if (row[cell]) {
+ free(row[cell]);
+ }
+ if (value) {
+ row[cell] = static_cast(xmalloc(sizeof(char) * (strlen(value) + 1)));
+ memcpy(row[cell], value, sizeof(char) * (strlen(value) + 1));
+ } else
+ row[cell] = NULL;
+}
+
+char ** Ssl::CertificateDb::Row::getRow()
+{
+ return row;
+}
+
+unsigned long Ssl::CertificateDb::index_serial_hash(const char **a)
+{
+ const char *n = a[Ssl::CertificateDb::cnlSerial];
+ while (*n == '0') n++;
+ return lh_strhash(n);
+}
+
+int Ssl::CertificateDb::index_serial_cmp(const char **a, const char **b)
+{
+ const char *aa, *bb;
+ for (aa = a[Ssl::CertificateDb::cnlSerial]; *aa == '0'; aa++);
+ for (bb = b[Ssl::CertificateDb::cnlSerial]; *bb == '0'; bb++);
+ return strcmp(aa, bb);
+}
+
+unsigned long Ssl::CertificateDb::index_name_hash(const char **a)
+{
+ return(lh_strhash(a[Ssl::CertificateDb::cnlName]));
+}
+
+int Ssl::CertificateDb::index_name_cmp(const char **a, const char **b)
+{
+ return(strcmp(a[Ssl::CertificateDb::cnlName], b[CertificateDb::cnlName]));
+}
+
+const std::string Ssl::CertificateDb::serial_file("serial");
+const std::string Ssl::CertificateDb::db_file("index.txt");
+const std::string Ssl::CertificateDb::cert_dir("certs");
+const std::string Ssl::CertificateDb::size_file("size");
+const size_t Ssl::CertificateDb::min_db_size(4096);
+
+Ssl::CertificateDb::CertificateDb(std::string const & aDb_path, size_t aMax_db_size, size_t aFs_block_size)
+ : db_path(aDb_path),
+ serial_full(aDb_path + "/" + serial_file),
+ db_full(aDb_path + "/" + db_file),
+ cert_full(aDb_path + "/" + cert_dir),
+ size_full(aDb_path + "/" + size_file),
+ db(NULL),
+ max_db_size(aMax_db_size),
+ fs_block_size(aFs_block_size),
+ enabled_disk_store(true)
+{
+ if (db_path.empty() && !max_db_size)
+ enabled_disk_store = false;
+ else if ((db_path.empty() && max_db_size) || (!db_path.empty() && !max_db_size))
+ throw std::runtime_error("ssl_crtd is missing the required parameter. There should be -s and -M parameters together.");
+ else
+ load();
+}
+
+bool Ssl::CertificateDb::find(std::string const & host_name, Ssl::X509_Pointer & cert, Ssl::EVP_PKEY_Pointer & pkey)
+{
+ FileLocker db_locker(db_full);
+ load();
+ return pure_find(host_name, cert, pkey);
+}
+
+bool Ssl::CertificateDb::addCertAndPrivateKey(Ssl::X509_Pointer & cert, Ssl::EVP_PKEY_Pointer & pkey)
+{
+ FileLocker db_locker(db_full);
+ load();
+ if (!db || !cert || !pkey || min_db_size > max_db_size)
+ return false;
+ Row row;
+ ASN1_INTEGER * ai = X509_get_serialNumber(cert.get());
+ std::string serial_string;
+ Ssl::BIGNUM_Pointer serial(ASN1_INTEGER_to_BN(ai, NULL));
+ {
+ TidyPointer hex_bn(BN_bn2hex(serial.get()));
+ serial_string = std::string(hex_bn.get());
+ }
+ row.setValue(cnlSerial, serial_string.c_str());
+ char ** rrow = TXT_DB_get_by_index(db.get(), cnlSerial, row.getRow());
+ if (rrow != NULL)
+ return false;
+
+ {
+ TidyPointer subject(X509_NAME_oneline(X509_get_subject_name(cert.get()), NULL, 0));
+ if (pure_find(subject.get(), cert, pkey))
+ return true;
+ }
+ // check db size.
+ while (max_db_size < size()) {
+ if (!deleteInvalidCertificate())
+ break;
+ }
+
+ while (max_db_size < size()) {
+ deleteOldestCertificate();
+ }
+
+ row.setValue(cnlType, "V");
+ ASN1_UTCTIME * tm = X509_get_notAfter(cert.get());
+ row.setValue(cnlExp_date, std::string(reinterpret_cast(tm->data), tm->length).c_str());
+ row.setValue(cnlFile, "unknown");
+ {
+ TidyPointer subject(X509_NAME_oneline(X509_get_subject_name(cert.get()), NULL, 0));
+ row.setValue(cnlName, subject.get());
+ }
+
+ if (!TXT_DB_insert(db.get(), row.getRow()))
+ return false;
+
+ row.reset();
+ std::string filename(cert_full + "/" + serial_string + ".pem");
+ FileLocker cert_locker(filename);
+ if (!writeCertAndPrivateKeyToFile(cert, pkey, filename.c_str()))
+ return false;
+ addSize(filename);
+
+ save();
+ return true;
+}
+
+BIGNUM * Ssl::CertificateDb::getCurrentSerialNumber()
+{
+ FileLocker serial_locker(serial_full);
+ // load serial number from file.
+ Ssl::BIO_Pointer file(BIO_new(BIO_s_file()));
+ if (!file)
+ return NULL;
+
+ if (BIO_rw_filename(file.get(), const_cast(serial_full.c_str())) <= 0)
+ return NULL;
+
+ Ssl::ASN1_INT_Pointer serial_ai(ASN1_INTEGER_new());
+ if (!serial_ai)
+ return NULL;
+
+ char buffer[1024];
+ if (!a2i_ASN1_INTEGER(file.get(), serial_ai.get(), buffer, sizeof(buffer)))
+ return NULL;
+
+ Ssl::BIGNUM_Pointer serial(ASN1_INTEGER_to_BN(serial_ai.get(), NULL));
+
+ if (!serial)
+ return NULL;
+
+ // increase serial number.
+ Ssl::BIGNUM_Pointer increased_serial(BN_dup(serial.get()));
+ if (!increased_serial)
+ return NULL;
+
+ BN_add_word(increased_serial.get(), 1);
+
+ // save increased serial number.
+ if (BIO_seek(file.get(), 0))
+ return NULL;
+
+ Ssl::ASN1_INT_Pointer increased_serial_ai(BN_to_ASN1_INTEGER(increased_serial.get(), NULL));
+ if (!increased_serial_ai)
+ return NULL;
+
+ i2a_ASN1_INTEGER(file.get(), increased_serial_ai.get());
+ BIO_puts(file.get(),"\n");
+
+ return serial.release();
+}
+
+void Ssl::CertificateDb::create(std::string const & db_path, int serial)
+{
+ if (db_path == "")
+ throw std::runtime_error("Path to db is empty");
+ std::string serial_full(db_path + "/" + serial_file);
+ std::string db_full(db_path + "/" + db_file);
+ std::string cert_full(db_path + "/" + cert_dir);
+ std::string size_full(db_path + "/" + size_file);
+
+#ifdef _SQUID_MSWIN_
+ if (mkdir(db_path.c_str()))
+#else
+ if (mkdir(db_path.c_str(), 0777))
+#endif
+ throw std::runtime_error("Cannot create " + db_path);
+
+#ifdef _SQUID_MSWIN_
+ if (mkdir(cert_full.c_str()))
+#else
+ if (mkdir(cert_full.c_str(), 0777))
+#endif
+ throw std::runtime_error("Cannot create " + cert_full);
+
+ Ssl::ASN1_INT_Pointer i(ASN1_INTEGER_new());
+ ASN1_INTEGER_set(i.get(), serial);
+
+ Ssl::BIO_Pointer file(BIO_new(BIO_s_file()));
+ if (!file)
+ throw std::runtime_error("SSL error");
+
+ if (BIO_write_filename(file.get(), const_cast(serial_full.c_str())) <= 0)
+ throw std::runtime_error("Cannot open " + cert_full + " to open");
+
+ i2a_ASN1_INTEGER(file.get(), i.get());
+
+ std::ofstream size(size_full.c_str());
+ if (size)
+ size << 0;
+ else
+ throw std::runtime_error("Cannot open " + size_full + " to open");
+ std::ofstream db(db_full.c_str());
+ if (!db)
+ throw std::runtime_error("Cannot open " + db_full + " to open");
+}
+
+void Ssl::CertificateDb::check(std::string const & db_path, size_t max_db_size)
+{
+ CertificateDb db(db_path, max_db_size, 0);
+}
+
+std::string Ssl::CertificateDb::getSNString() const
+{
+ FileLocker serial_locker(serial_full);
+ std::ifstream file(serial_full.c_str());
+ if (!file)
+ return "";
+ std::string serial;
+ file >> serial;
+ return serial;
+}
+
+bool Ssl::CertificateDb::pure_find(std::string const & host_name, Ssl::X509_Pointer & cert, Ssl::EVP_PKEY_Pointer & pkey)
+{
+ if (!db)
+ return false;
+
+ Row row;
+ row.setValue(cnlName, host_name.c_str());
+
+ char **rrow = TXT_DB_get_by_index(db.get(), cnlName, row.getRow());
+ if (rrow == NULL)
+ return false;
+
+ if (!sslDateIsInTheFuture(rrow[cnlExp_date])) {
+ deleteByHostname(rrow[cnlName]);
+ return false;
+ }
+
+ // read cert and pkey from file.
+ std::string filename(cert_full + "/" + rrow[cnlSerial] + ".pem");
+ FileLocker cert_locker(filename);
+ readCertAndPrivateKeyFromFiles(cert, pkey, filename.c_str(), NULL);
+ if (!cert || !pkey)
+ return false;
+ return true;
+}
+
+size_t Ssl::CertificateDb::size() const
+{
+ FileLocker size_locker(size_full);
+ return readSize();
+}
+
+void Ssl::CertificateDb::addSize(std::string const & filename)
+{
+ FileLocker size_locker(size_full);
+ writeSize(readSize() + getFileSize(filename));
+}
+
+void Ssl::CertificateDb::subSize(std::string const & filename)
+{
+ FileLocker size_locker(size_full);
+ writeSize(readSize() - getFileSize(filename));
+}
+
+size_t Ssl::CertificateDb::readSize() const
+{
+ size_t db_size;
+ std::ifstream size_file(size_full.c_str());
+ if (!size_file && enabled_disk_store)
+ throw std::runtime_error("cannot read \"" + size_full + "\" file");
+ size_file >> db_size;
+ return db_size;
+}
+
+void Ssl::CertificateDb::writeSize(size_t db_size)
+{
+ std::ofstream size_file(size_full.c_str());
+ if (!size_file && enabled_disk_store)
+ throw std::runtime_error("cannot write \"" + size_full + "\" file");
+ size_file << db_size;
+}
+
+size_t Ssl::CertificateDb::getFileSize(std::string const & filename)
+{
+ std::ifstream file(filename.c_str(), std::ios::binary);
+ file.seekg(0, std::ios_base::end);
+ size_t file_size = file.tellg();
+ return ((file_size + fs_block_size - 1) / fs_block_size) * fs_block_size;
+}
+
+void Ssl::CertificateDb::load()
+{
+ // Load db from file.
+ Ssl::BIO_Pointer in(BIO_new(BIO_s_file()));
+ if (!in || BIO_read_filename(in.get(), db_full.c_str()) <= 0)
+ throw std::runtime_error("Uninitialized SSL certificate database directory: " + db_path + ". To initialize, run \"ssl_crtd -c -s " + db_path + "\".");
+
+ bool corrupt = false;
+ Ssl::TXT_DB_Pointer temp_db(TXT_DB_read(in.get(), cnlNumber));
+ if (!temp_db)
+ corrupt = true;
+
+ // Create indexes in db.
+ if (!corrupt && !TXT_DB_create_index(temp_db.get(), cnlSerial, NULL, LHASH_HASH_FN(index_serial_hash), LHASH_COMP_FN(index_serial_cmp)))
+ corrupt = true;
+
+ if (!corrupt && !TXT_DB_create_index(temp_db.get(), cnlName, NULL, LHASH_HASH_FN(index_name_hash), LHASH_COMP_FN(index_name_cmp)))
+ corrupt = true;
+
+ if (corrupt)
+ throw std::runtime_error("The SSL certificate database " + db_path + " is curruted. Please rebuild");
+
+ db.reset(temp_db.release());
+}
+
+void Ssl::CertificateDb::save()
+{
+ if (!db)
+ throw std::runtime_error("The certificates database is not loaded");;
+
+ // To save the db to file, create a new BIO with BIO file methods.
+ Ssl::BIO_Pointer out(BIO_new(BIO_s_file()));
+ if (!out || !BIO_write_filename(out.get(), const_cast(db_full.c_str())))
+ throw std::runtime_error("Failed to initialize " + db_full + " file for writing");;
+
+ if (TXT_DB_write(out.get(), db.get()) < 0)
+ throw std::runtime_error("Failed to write " + db_full + " file");
+}
+
+bool Ssl::CertificateDb::deleteInvalidCertificate()
+{
+ if (!db)
+ return false;
+
+ bool removed_one = false;
+ for (int i = 0; i < sk_num(db.get()->data); i++) {
+ const char ** current_row = ((const char **)sk_value(db.get()->data, i));
+
+ if (!sslDateIsInTheFuture(current_row[cnlExp_date])) {
+ std::string filename(cert_full + "/" + current_row[cnlSerial] + ".pem");
+ FileLocker cert_locker(filename);
+ sk_delete(db.get()->data, i);
+ subSize(filename);
+ remove(filename.c_str());
+ removed_one = true;
+ break;
+ }
+ }
+
+ if (!removed_one)
+ return false;
+ return true;
+}
+
+bool Ssl::CertificateDb::deleteOldestCertificate()
+{
+ if (!db)
+ return false;
+
+ if (sk_num(db.get()->data) == 0)
+ return false;
+
+ std::string filename(cert_full + "/" + ((const char **)sk_value(db.get()->data, 0))[cnlSerial] + ".pem");
+ FileLocker cert_locker(filename);
+ sk_delete(db.get()->data, 0);
+ subSize(filename);
+ remove(filename.c_str());
+
+ return true;
+}
+
+bool Ssl::CertificateDb::deleteByHostname(std::string const & host)
+{
+ if (!db)
+ return false;
+
+ for (int i = 0; i < sk_num(db.get()->data); i++) {
+ const char ** current_row = ((const char **)sk_value(db.get()->data, i));
+ if (host == current_row[cnlName]) {
+ std::string filename(cert_full + "/" + current_row[cnlSerial] + ".pem");
+ FileLocker cert_locker(filename);
+ sk_delete(db.get()->data, i);
+ subSize(filename);
+ remove(filename.c_str());
+ return true;
+ }
+ }
+ return false;
+}
+
+bool Ssl::CertificateDb::IsEnabledDiskStore() const
+{
+ return enabled_disk_store;
+}
diff -u -r -N squid-3.1.12/src/ssl/certificate_db.h squid-3.1.12.1/src/ssl/certificate_db.h
--- squid-3.1.12/src/ssl/certificate_db.h 1970-01-01 12:00:00.000000000 +1200
+++ squid-3.1.12.1/src/ssl/certificate_db.h 2011-04-19 17:27:09.000000000 +1200
@@ -0,0 +1,139 @@
+/*
+ * $Id$
+ */
+
+#ifndef SQUID_SSL_CERTIFICATE_DB_H
+#define SQUID_SSL_CERTIFICATE_DB_H
+
+#include "ssl/gadgets.h"
+#include "ssl_support.h"
+#if HAVE_STRING
+#include
+#endif
+
+namespace Ssl
+{
+/// Cross platform file locker.
+class FileLocker
+{
+public:
+ /// Lock file
+ FileLocker(std::string const & aFilename);
+ /// Unlock file
+ ~FileLocker();
+private:
+#ifdef _SQUID_MSWIN_
+ HANDLE hFile; ///< Windows file handle.
+#else
+ int fd; ///< Linux file descriptor.
+#endif
+};
+
+/**
+ * Database class for storing SSL certificates and their private keys.
+ * A database consist by:
+ * - A disk file to store current serial number
+ * - A disk file to store the current database size
+ * - A disk file which is a normal TXT_DB openSSL database
+ * - A directory under which the certificates and their private keys stored.
+ * The database before used must initialized with CertificateDb::create static method.
+ */
+class CertificateDb
+{
+public:
+ /// Names of db columns.
+ enum Columns {
+ cnlType = 0,
+ cnlExp_date,
+ cnlRev_date,
+ cnlSerial,
+ cnlFile,
+ cnlName,
+ cnlNumber
+ };
+
+ /// A wrapper for OpenSSL database row of TXT_DB database.
+ class Row
+ {
+ public:
+ /// Create row wrapper.
+ Row();
+ /// Delete all row.
+ ~Row();
+ void setValue(size_t number, char const * value); ///< Set cell's value in row
+ char ** getRow(); ///< Raw row
+ void reset(); ///< Abandon row and don't free memory
+ private:
+ char **row; ///< Raw row
+ size_t width; ///< Number of cells in the row
+ };
+
+ CertificateDb(std::string const & db_path, size_t aMax_db_size, size_t aFs_block_size);
+ /// Find certificate and private key for host name
+ bool find(std::string const & host_name, Ssl::X509_Pointer & cert, Ssl::EVP_PKEY_Pointer & pkey);
+ /// Save certificate to disk.
+ bool addCertAndPrivateKey(Ssl::X509_Pointer & cert, Ssl::EVP_PKEY_Pointer & pkey);
+ /// Get a serial number to use for generating a new certificate.
+ BIGNUM * getCurrentSerialNumber();
+ /// Create and initialize a database under the db_path
+ static void create(std::string const & db_path, int serial);
+ /// Check the database stored under the db_path.
+ static void check(std::string const & db_path, size_t max_db_size);
+ std::string getSNString() const; ///< Get serial number as string.
+ bool IsEnabledDiskStore() const; ///< Check enabled of dist store.
+private:
+ void load(); ///< Load db from disk.
+ void save(); ///< Save db to disk.
+ size_t size() const; ///< Get db size on disk in bytes.
+ /// Increase db size by the given file size and update size_file
+ void addSize(std::string const & filename);
+ /// Decrease db size by the given file size and update size_file
+ void subSize(std::string const & filename);
+ size_t readSize() const; ///< Read size from file size_file
+ void writeSize(size_t db_size); ///< Write size to file size_file.
+ size_t getFileSize(std::string const & filename); ///< get file size on disk.
+ /// Only find certificate in current db and return it.
+ bool pure_find(std::string const & host_name, Ssl::X509_Pointer & cert, Ssl::EVP_PKEY_Pointer & pkey);
+
+ bool deleteInvalidCertificate(); ///< Delete invalid certificate.
+ bool deleteOldestCertificate(); ///< Delete oldest certificate.
+ bool deleteByHostname(std::string const & host); ///< Delete using host name.
+
+ /// Callback hash function for serials. Used to create TXT_DB index of serials.
+ static unsigned long index_serial_hash(const char **a);
+ /// Callback compare function for serials. Used to create TXT_DB index of serials.
+ static int index_serial_cmp(const char **a, const char **b);
+ /// Callback hash function for names. Used to create TXT_DB index of names..
+ static unsigned long index_name_hash(const char **a);
+ /// Callback compare function for names. Used to create TXT_DB index of names..
+ static int index_name_cmp(const char **a, const char **b);
+
+ /// Definitions required by openSSL, to use the index_* functions defined above
+ ///with TXT_DB_create_index.
+ static IMPLEMENT_LHASH_HASH_FN(index_serial_hash,const char **)
+ static IMPLEMENT_LHASH_COMP_FN(index_serial_cmp,const char **)
+ static IMPLEMENT_LHASH_HASH_FN(index_name_hash,const char **)
+ static IMPLEMENT_LHASH_COMP_FN(index_name_cmp,const char **)
+
+ static const std::string serial_file; ///< Base name of the file to store serial number.
+ static const std::string db_file; ///< Base name of the database index file.
+ static const std::string cert_dir; ///< Base name of the directory to store the certs.
+ static const std::string size_file; ///< Base name of the file to store db size.
+ /// Min size of disk db. If real size < min_db_size the db will be disabled.
+ static const size_t min_db_size;
+
+ const std::string db_path; ///< The database directory.
+ const std::string serial_full; ///< Full path of the file to store serial number.
+ const std::string db_full; ///< Full path of the database index file.
+ const std::string cert_full; ///< Full path of the directory to store the certs.
+ const std::string size_full; ///< Full path of the file to store the db size.
+
+ TXT_DB_Pointer db; ///< Database with certificates info.
+ const size_t max_db_size; ///< Max size of db.
+ const size_t fs_block_size; ///< File system block size.
+
+ bool enabled_disk_store; ///< The storage on the disk is enabled.
+};
+
+} // namespace Ssl
+#endif // SQUID_SSL_CERTIFICATE_DB_H
diff -u -r -N squid-3.1.12/src/ssl/Config.cc squid-3.1.12.1/src/ssl/Config.cc
--- squid-3.1.12/src/ssl/Config.cc 1970-01-01 12:00:00.000000000 +1200
+++ squid-3.1.12.1/src/ssl/Config.cc 2011-04-19 17:27:09.000000000 +1200
@@ -0,0 +1,23 @@
+/*
+ * $Id$
+ */
+#include "squid.h"
+#include "ssl/Config.h"
+
+Ssl::Config Ssl::TheConfig;
+
+Ssl::Config::Config()
+#if USE_SSL_CRTD
+ :
+ ssl_crtd(NULL),
+ ssl_crtd_n_running(5)
+#endif
+{
+}
+
+Ssl::Config::~Config()
+{
+#if USE_SSL_CRTD
+ xfree(ssl_crtd);
+#endif
+}
diff -u -r -N squid-3.1.12/src/ssl/Config.h squid-3.1.12.1/src/ssl/Config.h
--- squid-3.1.12/src/ssl/Config.h 1970-01-01 12:00:00.000000000 +1200
+++ squid-3.1.12.1/src/ssl/Config.h 2011-04-19 17:27:09.000000000 +1200
@@ -0,0 +1,29 @@
+/*
+ * $Id$
+ */
+
+#ifndef SQUID_SSL_CONFIG_H
+#define SQUID_SSL_CONFIG_H
+
+namespace Ssl
+{
+
+class Config
+{
+public:
+#if USE_SSL_CRTD
+ char *ssl_crtd; ///< Name of external ssl_crtd application.
+ /// The number of processes spawn for ssl_crtd.
+ int ssl_crtd_n_running;
+#endif
+ Config();
+ ~Config();
+private:
+ Config(const Config &); // not implemented
+ Config &operator =(const Config &); // not implemented
+};
+
+extern Config TheConfig;
+
+} // namespace Ssl
+#endif
diff -u -r -N squid-3.1.12/src/ssl/context_storage.cc squid-3.1.12.1/src/ssl/context_storage.cc
--- squid-3.1.12/src/ssl/context_storage.cc 1970-01-01 12:00:00.000000000 +1200
+++ squid-3.1.12.1/src/ssl/context_storage.cc 2011-04-19 17:27:09.000000000 +1200
@@ -0,0 +1,176 @@
+/*
+ * $Id$
+ */
+#include "config.h"
+#include "Store.h"
+#include "StoreEntryStream.h"
+#include "ssl/context_storage.h"
+#if HAVE_LIMITS
+#include
+#endif
+
+Ssl::CertificateStorageAction::CertificateStorageAction()
+ : CacheManagerAction("cached_ssl_cert", "Statistic of cached generated ssl certificates", 1, 1)
+{}
+
+void Ssl::CertificateStorageAction::run (StoreEntry *sentry)
+{
+ StoreEntryStream stream(sentry);
+ const char delimiter = '\t';
+ const char endString = '\n';
+ // Page title.
+ stream << "Cached ssl certificates statistic.\n";
+ // Title of statistic table.
+ stream << "Port" << delimiter << "Max mem(KB)" << delimiter << "Cert number" << delimiter << "KB/cert" << delimiter << "Mem used(KB)" << delimiter << "Mem free(KB)" << endString;
+
+ // Add info for each port.
+ for (std::map::iterator i = TheGlobalContextStorage.storage.begin(); i != TheGlobalContextStorage.storage.end(); i++) {
+ stream << i->first << delimiter;
+ LocalContextStorage & ssl_store_policy(*(i->second));
+ stream << ssl_store_policy.max_memory / 1024 << delimiter;
+ stream << ssl_store_policy.memory_used / SSL_CTX_SIZE << delimiter;
+ stream << SSL_CTX_SIZE / 1024 << delimiter;
+ stream << ssl_store_policy.memory_used / 1024 << delimiter;
+ stream << (ssl_store_policy.max_memory - ssl_store_policy.memory_used) / 1024 << endString;
+ }
+ stream << endString;
+ stream.flush();
+}
+
+Ssl::LocalContextStorage::LocalContextStorage(size_t aMax_memory)
+ : max_memory(aMax_memory), memory_used(0)
+{}
+
+Ssl::LocalContextStorage::~LocalContextStorage()
+{
+ for (QueueIterator i = lru_queue.begin(); i != lru_queue.end(); i++) {
+ delete *i;
+ }
+}
+
+SSL_CTX * Ssl::LocalContextStorage::add(const char * host_name, SSL_CTX * ssl_ctx)
+{
+ if (max_memory < SSL_CTX_SIZE) {
+ return NULL;
+ }
+ remove(host_name);
+ while (SSL_CTX_SIZE + memory_used > max_memory) {
+ purgeOne();
+ }
+ lru_queue.push_front(new Item(ssl_ctx, host_name));
+ storage.insert(MapPair(host_name, lru_queue.begin()));
+ memory_used += SSL_CTX_SIZE;
+ return ssl_ctx;
+}
+
+SSL_CTX * Ssl::LocalContextStorage::find(char const * host_name)
+{
+ MapIterator i = storage.find(host_name);
+ if (i == storage.end()) {
+ return NULL;
+ }
+ lru_queue.push_front(*(i->second));
+ lru_queue.erase(i->second);
+ i->second = lru_queue.begin();
+ return (*lru_queue.begin())->ssl_ctx;
+}
+
+void Ssl::LocalContextStorage::remove(char const * host_name)
+{
+ deleteAt(storage.find(host_name));
+}
+
+void Ssl::LocalContextStorage::purgeOne()
+{
+ QueueIterator i = lru_queue.end();
+ i--;
+ if (i != lru_queue.end()) {
+ remove((*i)->host_name.c_str());
+ }
+}
+
+void Ssl::LocalContextStorage::deleteAt(LocalContextStorage::MapIterator i)
+{
+ if (i != storage.end()) {
+
+ delete *(i->second);
+ lru_queue.erase(i->second);
+ storage.erase(i);
+ memory_used -= SSL_CTX_SIZE;
+ }
+}
+
+void Ssl::LocalContextStorage::SetSize(size_t aMax_memory)
+{
+ max_memory = aMax_memory;
+}
+
+Ssl::LocalContextStorage::Item::Item(SSL_CTX * aSsl_ctx, std::string const & aName)
+ : ssl_ctx(aSsl_ctx), host_name(aName)
+{}
+
+Ssl::LocalContextStorage::Item::~Item()
+{
+ SSL_CTX_free(ssl_ctx);
+}
+
+///////////////////////////////////////////////////////
+
+Ssl::GlobalContextStorage::GlobalContextStorage()
+ : reconfiguring(true)
+{
+// RegisterAction("cached_ssl_cert", "Statistic of cached generated ssl certificates", &CertificateStorageAction::Create, 0, 1);
+ CacheManager::GetInstance()->registerAction(new CertificateStorageAction);
+}
+
+Ssl::GlobalContextStorage::~GlobalContextStorage()
+{
+ for (std::map::iterator i = storage.begin(); i != storage.end(); i++) {
+ delete i->second;
+ }
+}
+
+void Ssl::GlobalContextStorage::addLocalStorage(IpAddress const & address, size_t size_of_store)
+{
+ assert(reconfiguring);
+ configureStorage.insert(std::pair(address, size_of_store));
+}
+
+Ssl::LocalContextStorage & Ssl::GlobalContextStorage::getLocalStorage(IpAddress const & address)
+{
+ reconfigureFinish();
+ std::map::iterator i = storage.find(address);
+ assert (i != storage.end());
+ return *(i->second);
+}
+
+void Ssl::GlobalContextStorage::reconfigureStart()
+{
+ reconfiguring = true;
+}
+
+void Ssl::GlobalContextStorage::reconfigureFinish()
+{
+ if (reconfiguring) {
+ reconfiguring = false;
+
+ // remove or change old local storages.
+ for (std::map::iterator i = storage.begin(); i != storage.end(); i++) {
+ std::map::iterator conf_i = configureStorage.find(i->first);
+ if (conf_i == configureStorage.end()) {
+ storage.erase(i);
+ } else {
+ i->second->SetSize(conf_i->second);
+ }
+ }
+
+ // add new local storages.
+ for (std::map::iterator conf_i = configureStorage.begin(); conf_i != configureStorage.end(); conf_i++ ) {
+ if (storage.find(conf_i->first) == storage.end()) {
+ storage.insert(std::pair(conf_i->first, new LocalContextStorage(conf_i->second)));
+ }
+ }
+ }
+}
+
+Ssl::GlobalContextStorage Ssl::TheGlobalContextStorage;
diff -u -r -N squid-3.1.12/src/ssl/context_storage.h squid-3.1.12.1/src/ssl/context_storage.h
--- squid-3.1.12/src/ssl/context_storage.h 1970-01-01 12:00:00.000000000 +1200
+++ squid-3.1.12.1/src/ssl/context_storage.h 2011-04-19 17:27:09.000000000 +1200
@@ -0,0 +1,113 @@
+/*
+ * $Id$
+ */
+
+#ifndef SQUID_SSL_CONTEXT_STORAGE_H
+#define SQUID_SSL_CONTEXT_STORAGE_H
+
+#if USE_SSL
+
+#include "SquidTime.h"
+#include "CacheManager.h"
+#if HAVE_MAP
+#include