diff -u -r ../apache_1.3.33/Makefile.tmpl ./Makefile.tmpl
--- ../apache_1.3.33/Makefile.tmpl	Fri Feb 20 22:40:50 2004
+++ ./Makefile.tmpl	Fri Nov  5 11:07:03 2004
@@ -247,6 +247,7 @@
 #   shared object files.
 install-programs:
 	@echo "===> [programs: Installing Apache $(TARGET) program and shared objects]"
+	$(INSTALL_PROGRAM) $(TOP)/$(SRC)/modules/ssl/gcache $(root)$(sbindir)/gcache
 	-@if [ ".`grep '^[ 	]*AddModule.*mod_so\.o' $(TOP)/$(SRC)/Configuration.apaci`" != . ]; then \
 		echo "$(INSTALL_CORE) $(TOP)/$(SRC)/$(TARGET) $(root)$(sbindir)/$(TARGET)"; \
 		$(INSTALL_CORE) $(TOP)/$(SRC)/$(TARGET) $(root)$(sbindir)/$(TARGET); \
diff -u -r ../apache_1.3.33/configure ./configure
--- ../apache_1.3.33/configure	Fri Feb 20 22:40:50 2004
+++ ./configure	Fri Nov  5 11:07:03 2004
@@ -789,7 +789,9 @@
                            OOIFS="$IFS"
                            IFS=':'
                            for module in $modules; do
-                               eval "shared_${module}=yes" 
+#			       if [ $module != apache_ssl ]; then
+				   eval "shared_${module}=yes"
+#			       fi
                            done
                            IFS="$OOIFS"
                            shared_so=no        # because of bootstrapping
@@ -1057,8 +1059,10 @@
 ##
 if [ "x$TARGET" != "x" ]; then
     thetarget="$TARGET"
+    theconfig="$thetarget"
 else
-    thetarget=httpd
+    thetarget=httpsd
+    theconfig=httpd
 fi
 
 ##
@@ -1477,6 +1481,7 @@
     eval "share=\$shared_$module"
     if [ "x$share" = "xyes" ]; then
         echo $SEO "s%^\\(.*\\)AddModule\\(.*mod_$module\\.\\)[oam].*\\(.*\\)%\\1SharedModule\\2so\\3%g" >>$sedsubst
+        echo $SEO "s%^\\(.*\\)AddModule\\(.*$module\\.\\)[oam].*\\(.*\\)%\\1SharedModule\\2so\\3%g" >>$sedsubst
         echo $SEO "s%^\\(.*\\)AddModule\\(.*lib$module\\.\\)[oam].*\\(.*\\)%\\1SharedModule\\2so\\3%g" >>$sedsubst
         m="$m [shared]"
     fi
diff -u -r ../apache_1.3.33/src/Configuration ./src/Configuration
--- ../apache_1.3.33/src/Configuration	Wed Oct 27 16:46:00 2004
+++ ./src/Configuration	Fri Nov  5 11:34:01 2004
@@ -62,6 +62,21 @@
 #OPTIM=
 #RANLIB=
 
+TARGET=httpsd
+
+#
+# SSL Related stuff. N.B. This is set up to use the SSLeay source, NOT an
+# installed version.
+#
+KEYNOTE_BASE=/home/ben/work/KeyNote
+SSL_BASE=/usr/local/ssl
+SSL_INCLUDE= -I$(SSL_BASE)/include
+SSL_CFLAGS= -DAPACHE_SSL
+SSL_LIB_DIR=/usr/local/ssl/lib
+SSL_LIBS= -L$(SSL_LIB_DIR) -lssl -lcrypto
+SSL_APP_DIR=/usr/local/ssl/bin
+SSL_APP=/usr/local/ssl/bin/openssl
+
 ################################################################
 # Name of the installed Apache HTTP webserver.
 #
@@ -235,6 +250,11 @@
 # is and the more memory it will take, so if you are unlikely to use the
 # functionality of a particular module you might wish to leave it out.
 
+##
+## Experimental Apache-SSL KeyNote support.
+
+# AddModule modules/ssl-keynote/apache_ssl_keynote.o
+
 ## mod_mmap_static is an experimental module, you almost certainly
 ## don't need it.  It can make some webservers faster.  No further
 ## documentation is provided here because you'd be foolish
@@ -460,3 +480,7 @@
 
 AddModule modules/standard/mod_setenvif.o
 
+## Damn damn damn. Apache inverts the module list. SSL must go first to fake
+## basic authorization (that is, last in this file).
+
+AddModule modules/ssl/apache_ssl.a
diff -u -r ../apache_1.3.33/src/Configuration.tmpl ./src/Configuration.tmpl
--- ../apache_1.3.33/src/Configuration.tmpl	Wed Dec 31 11:58:21 2003
+++ ./src/Configuration.tmpl	Fri Nov  5 11:07:03 2004
@@ -62,6 +62,21 @@
 #OPTIM=
 #RANLIB=
 
+TARGET=httpsd
+
+#
+# SSL Related stuff. N.B. This is set up to use the SSLeay source, NOT an
+# installed version.
+#
+KEYNOTE_BASE=/home/ben/work/KeyNote
+SSL_BASE=/usr/local/ssl
+SSL_INCLUDE= -I$(SSL_BASE)/include
+SSL_CFLAGS= -DAPACHE_SSL
+SSL_LIB_DIR=/usr/local/ssl/lib
+SSL_LIBS= -L$(SSL_LIB_DIR) -lssl -lcrypto
+SSL_APP_DIR=/usr/local/ssl/bin
+SSL_APP=/usr/local/ssl/bin/openssl
+
 ################################################################
 # Name of the installed Apache HTTP webserver.
 #
@@ -235,6 +250,11 @@
 # is and the more memory it will take, so if you are unlikely to use the
 # functionality of a particular module you might wish to leave it out.
 
+##
+## Experimental Apache-SSL KeyNote support.
+
+# AddModule modules/ssl-keynote/apache_ssl_keynote.o
+
 ## mod_mmap_static is an experimental module, you almost certainly
 ## don't need it.  It can make some webservers faster.  No further
 ## documentation is provided here because you'd be foolish
@@ -460,3 +480,7 @@
 
 AddModule modules/standard/mod_setenvif.o
 
+## Damn damn damn. Apache inverts the module list. SSL must go first to fake
+## basic authorization (that is, last in this file).
+
+AddModule modules/ssl/apache_ssl.a
diff -u -r ../apache_1.3.33/src/Configure ./src/Configure
--- ../apache_1.3.33/src/Configure	Mon Oct 18 16:39:37 2004
+++ ./src/Configure	Fri Nov  5 11:07:04 2004
@@ -873,7 +873,7 @@
 ##
 echo >>Makefile.config "OSDIR=\$(SRCDIR)/$OSDIR"
 echo >>Makefile.config "INCDIR=\$(SRCDIR)/include"
-echo >>Makefile.config "INCLUDES0=-I\$(OSDIR) -I\$(INCDIR)"
+echo >>Makefile.config "INCLUDES0=-I\$(OSDIR) -I\$(INCDIR) \$(SSL_INCLUDE)"
 echo >>Makefile.config "SHELL=$SHELL"
 echo >>Makefile.config "OS=$OS"
 
@@ -1833,6 +1833,10 @@
 		    echo "    o $modbase adds libraries: $modlibs1"
 		    modlibs="$modlibs $modlibs1"
 		fi
+		if grep "Libs:" $tmpfile2 > /dev/null; then
+		    modlibs=`grep Libs: $tmpfile2 | sed 's/^.*Libs:[ 	]*//'`
+		    echo "    o $modbase adds libraries: $modlibs"
+		fi
 		rm -f $tmpfile2 $tmpfile3
 		if [ "x$ext" != "x$SHMOD_SUFFIX_NAME" ]; then
 		    ext=o
@@ -2151,7 +2155,7 @@
 ## for $LIBS at this point. This implies that anything below
 ## can only alter $LIBS
 ##
-echo "CFLAGS1=$CFLAGS" >>Makefile.config
+echo "CFLAGS1=$CFLAGS \$(SSL_CFLAGS)" >>Makefile.config
 echo "INCLUDES1=$INCLUDES" >>Makefile.config
 echo "LIBS_SHLIB=$LIBS_SHLIB" >>Makefile.config
 echo "LDFLAGS1=$LDFLAGS" >>Makefile.config
@@ -2371,7 +2375,7 @@
 ####################################################################
 ## Finish creating the Makefile.config file
 ##
-echo "LIBS1=$modlibs $LIBS">> Makefile.config
+echo "LIBS1=$modlibs $LIBS \$(SSL_LIBS)">> Makefile.config
 echo "##" >> Makefile.config
 echo "##  (End of automatically generated section)">> Makefile.config
 echo "##" >> Makefile.config
diff -u -r ../apache_1.3.33/src/Makefile.tmpl ./src/Makefile.tmpl
--- ../apache_1.3.33/src/Makefile.tmpl	Tue Jan 14 21:21:41 2003
+++ ./src/Makefile.tmpl	Fri Nov  5 11:07:04 2004
@@ -30,6 +30,15 @@
 
 $(TARGET): $(EXTRA_DEPS) $(SUBTARGET)
 
+certificate:
+	ps > /tmp/ssl-rand; date >> /tmp/ssl-rand; \
+	RANDFILE=/tmp/ssl-rand $(SSL_APP) req -config ../SSLconf/conf/ssleay.cnf \
+	-new -x509 -nodes -out ../SSLconf/conf/httpsd.pem \
+	-keyout ../SSLconf/conf/httpsd.pem; \
+	ln -sf httpsd.pem ../SSLconf/conf/`$(SSL_APP) \
+	x509 -noout -hash < ../SSLconf/conf/httpsd.pem`.0; \
+	rm /tmp/ssl-rand
+
 target_static: subdirs modules.o
 	$(CC) -c $(INCLUDES) $(CFLAGS) buildmark.c
 	$(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SHLIB_EXPORT) \
@@ -125,10 +134,10 @@
 
 # DO NOT REMOVE
 buildmark.o: buildmark.c include/ap_config.h include/ap_mmn.h \
- include/ap_config_auto.h $(OSDIR)/os.h include/ap_ctype.h \
- include/hsregex.h include/httpd.h include/ap_alloc.h include/buff.h \
+ include/ap_config_auto.h os/unix/os.h os/unix/os-inline.c \
+ include/ap_ctype.h include/httpd.h include/ap_alloc.h include/buff.h \
  include/ap.h include/util_uri.h
 modules.o: modules.c include/httpd.h include/ap_config.h \
- include/ap_mmn.h include/ap_config_auto.h $(OSDIR)/os.h \
- include/ap_ctype.h include/hsregex.h include/ap_alloc.h include/buff.h \
- include/ap.h include/util_uri.h include/http_config.h
+ include/ap_mmn.h include/ap_config_auto.h os/unix/os.h \
+ os/unix/os-inline.c include/ap_ctype.h include/ap_alloc.h \
+ include/buff.h include/ap.h include/util_uri.h include/http_config.h
diff -u -r ../apache_1.3.33/src/ap/Makefile.tmpl ./src/ap/Makefile.tmpl
--- ../apache_1.3.33/src/ap/Makefile.tmpl	Tue Jun 18 00:34:35 2002
+++ ./src/ap/Makefile.tmpl	Fri Nov  5 11:07:04 2004
@@ -40,45 +40,52 @@
 	    && rm Makefile.new
 
 # DO NOT REMOVE
+ap_base64.o: ap_base64.c $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
+ $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h $(OSDIR)/os-inline.c \
+ $(INCDIR)/ap_ctype.h $(INCDIR)/ap.h
+ap_checkpass.o: ap_checkpass.c $(INCDIR)/ap_config.h \
+ $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/ap_md5.h \
+ $(INCDIR)/ap_sha1.h $(INCDIR)/ap.h
 ap_cpystrn.o: ap_cpystrn.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
- $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
- $(INCDIR)/util_uri.h
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/ap_alloc.h \
+ $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h
+ap_ebcdic.o: ap_ebcdic.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
+ $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/ap_alloc.h \
+ $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \
+ $(INCDIR)/http_core.h $(INCDIR)/http_config.h
 ap_execve.o: ap_execve.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
- $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
- $(INCDIR)/util_uri.h
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/ap_alloc.h \
+ $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h
 ap_fnmatch.o: ap_fnmatch.c $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h $(OSDIR)/os-inline.c \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h $(INCDIR)/fnmatch.h
+ $(INCDIR)/ap_ctype.h $(INCDIR)/fnmatch.h
 ap_getpass.o: ap_getpass.c $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h $(OSDIR)/os-inline.c \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h $(INCDIR)/ap.h
+ $(INCDIR)/ap_ctype.h $(INCDIR)/ap.h
 ap_md5c.o: ap_md5c.c $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h $(OSDIR)/os-inline.c \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h $(INCDIR)/ap_md5.h \
- $(INCDIR)/ap.h
-ap_sha1.o: ap_sha1.c $(INCDIR)/ap_config.h $(INCDIR)/ap_sha1.h \
- $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h $(OSDIR)/os-inline.c
+ $(INCDIR)/ap_ctype.h $(INCDIR)/ap_md5.h $(INCDIR)/ap.h
+ap_sha1.o: ap_sha1.c $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
+ $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h $(OSDIR)/os-inline.c \
+ $(INCDIR)/ap_ctype.h $(INCDIR)/ap_sha1.h $(INCDIR)/ap.h
 ap_signal.o: ap_signal.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
- $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
- $(INCDIR)/util_uri.h
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/ap_alloc.h \
+ $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h
 ap_slack.o: ap_slack.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
- $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
- $(INCDIR)/util_uri.h $(INCDIR)/http_log.h
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/ap_alloc.h \
+ $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \
+ $(INCDIR)/http_log.h
 ap_snprintf.o: ap_snprintf.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
- $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
- $(INCDIR)/util_uri.h
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/ap_alloc.h \
+ $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h
 ap_strtol.o: ap_strtol.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
- $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
- $(INCDIR)/util_uri.h
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/ap_alloc.h \
+ $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h
diff -u -r ../apache_1.3.33/src/include/ap_config.h ./src/include/ap_config.h
--- ../apache_1.3.33/src/include/ap_config.h	Wed Sep 15 23:45:17 2004
+++ ./src/include/ap_config.h	Fri Nov  5 11:07:04 2004
@@ -432,7 +432,17 @@
  * all glibc based systems need crypt.h
  */
 #if defined(__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1
-#include <crypt.h>
+
+# ifdef APACHE_SSL
+#  define des_encrypt BASE_des_encrypt
+# endif
+
+# include <crypt.h>
+
+# ifdef APACHE_SSL
+#  undef des_encrypt
+# endif
+
 #endif
 
 /* glibc 2.0.0 through 2.0.4 need size_t * here, where 2.0.5 needs socklen_t *
@@ -1452,6 +1462,10 @@
 
 #ifndef ap_wait_t
 #define ap_wait_t int
+#endif
+
+#ifdef APACHE_SSL
+# define NO_WRITEV
 #endif
 
 #ifdef __cplusplus
diff -u -r ../apache_1.3.33/src/include/ap_mmn.h ./src/include/ap_mmn.h
--- ../apache_1.3.33/src/include/ap_mmn.h	Thu Apr 15 15:51:51 2004
+++ ./src/include/ap_mmn.h	Fri Nov  5 11:07:04 2004
@@ -206,6 +206,7 @@
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503133UL /* "AP13" */
+#define SSL_MAGIC_COOKIE 0x53533133UL /* "SS13" */
 
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 19990320
diff -u -r ../apache_1.3.33/src/include/buff.h ./src/include/buff.h
--- ../apache_1.3.33/src/include/buff.h	Mon Feb 16 22:25:08 2004
+++ ./src/include/buff.h	Fri Nov  5 11:07:05 2004
@@ -19,13 +19,30 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
-
 #ifdef B_SFIO
+
 #include "sfio.h"
 #endif
 
 #include <stdarg.h>
 
+#ifdef APACHE_SSL
+
+# include <stdio.h>
+# include <openssl/ssl.h>
+
+#if SSLEAY_VERSION_NUMBER < 0x0920
+# error "Don't use OpenSSL/SSLeay versions less than 0.9.2b, they have a serious security problem!"
+#endif
+
+# define APACHE_SSL_EXPORT_CERTS	FALSE
+# if APACHE_SSL_EXPORT_CERTS
+/* SSLeay doesn't, so we must! */
+#  define APACHE_SSL_KEEP_CERTS		TRUE
+# endif
+
+#endif
+
 /* Reading is buffered */
 #define B_RD     (1)
 /* Writing is buffered */
@@ -85,6 +102,19 @@
 #ifdef B_SFIO
     Sfio_t *sf_in;
     Sfio_t *sf_out;
+#endif
+
+#ifdef APACHE_SSL
+    /* Add some context for SSL */
+    SSL *ssl;
+    char *szClientX509;
+    int nVerifyError;
+    BOOL bRevoked;
+    BOOL bCRLExpired;
+    BOOL bNoCRL;
+# if APACHE_SSL_KEEP_CERTS
+    table *tableCertChain;
+# endif
 #endif
 
     void *callback_data;
diff -u -r ../apache_1.3.33/src/include/http_config.h ./src/include/http_config.h
--- ../apache_1.3.33/src/include/http_config.h	Mon Feb 16 22:25:08 2004
+++ ./src/include/http_config.h	Fri Nov  5 11:07:05 2004
@@ -233,6 +233,11 @@
     void (*child_exit) (server_rec *, pool *);
 #endif
     int (*post_read_request) (request_rec *);
+#ifdef APACHE_SSL
+/* These are only present if the cookie is SSL_MAGIC_COOKIE */
+    void (*setup_connection)(conn_rec *);
+    void (*add_common_vars)(request_rec *);
+#endif
 } module;
 
 /* Initializer for the first few module slots, which are only
@@ -253,6 +258,14 @@
 				NULL, \
 				MODULE_MAGIC_COOKIE
 
+#define SSL_MODULE_STUFF	MODULE_MAGIC_NUMBER_MAJOR, \
+				MODULE_MAGIC_NUMBER_MINOR, \
+				-1, \
+				__FILE__, \
+				NULL, \
+				NULL, \
+				SSL_MAGIC_COOKIE
+
 /* Generic accessors for other modules to get at their own module-specific
  * data
  */
@@ -363,6 +376,11 @@
 CORE_EXPORT(const command_rec *) ap_find_command_in_modules(const char *cmd_name, module **mod);
 CORE_EXPORT(void *) ap_set_config_vectors(cmd_parms *parms, void *config, module *mod);
 CORE_EXPORT(const char *) ap_handle_command(cmd_parms *parms, void *config, const char *l);
+
+#ifdef APACHE_SSL
+CORE_EXPORT(void) ap_add_common_vars2(request_rec *r);
+CORE_EXPORT(void) ap_setup_connection(conn_rec *c);
+#endif
 
 #endif
 
diff -u -r ../apache_1.3.33/src/include/http_main.h ./src/include/http_main.h
--- ../apache_1.3.33/src/include/http_main.h	Mon Feb 16 22:25:08 2004
+++ ./src/include/http_main.h	Fri Nov  5 11:07:05 2004
@@ -73,6 +73,7 @@
 API_EXPORT(void) ap_start_shutdown(void);
 API_EXPORT(void) ap_start_restart(int);
 API_EXPORT(void) ap_hard_timeout(char *, request_rec *);
+void ap_conn_timeout(char *name,conn_rec *conn);
 API_EXPORT(void) ap_keepalive_timeout(char *, request_rec *);
 API_EXPORT(void) ap_soft_timeout(char *, request_rec *);
 API_EXPORT(void) ap_kill_timeout(request_rec *);
@@ -128,6 +129,8 @@
  * write_fd are possibly killed off separately.
  */
 API_EXPORT(void) ap_unregister_other_child(void *data);
+/* Check for debug-level logging */
+API_EXPORT(int) LogLevelIsDebug(void);
 
 #endif
 
diff -u -r ../apache_1.3.33/src/include/httpd.h ./src/include/httpd.h
--- ../apache_1.3.33/src/include/httpd.h	Wed Oct 27 16:34:01 2004
+++ ./src/include/httpd.h	Fri Nov  5 11:14:12 2004
@@ -24,6 +24,11 @@
  * httpd.h: header for simple (ha! not anymore) http daemon
  */
 
+/* Needed all over the place */
+typedef unsigned int BOOL;
+#define TRUE 		1
+#define FALSE 		0
+
 /* Headers in which EVERYONE has an interest... */
 
 #include "ap_config.h"
@@ -102,8 +107,13 @@
 #define ap_http_method(r) ap_os_http_method((void*)r)
 #define ap_default_port(r) ap_os_default_port((void*)r)
 #else
-#define ap_http_method(r)	"http"
-#define ap_default_port(r)	DEFAULT_HTTP_PORT
+# ifdef APACHE_SSL
+#  define ap_http_method(r)	((r)->connection->client->ssl ? "https" : "http")
+#  define ap_default_port(r)	((r)->connection->client->ssl ? DEFAULT_HTTPS_PORT : DEFAULT_HTTP_PORT)
+# else
+#  define ap_http_method(r)	"http"
+#  define ap_default_port(r)	DEFAULT_HTTP_PORT
+# endif
 #endif
 
 /* --------- Default user name and group name running standalone ---------- */
@@ -389,7 +399,11 @@
 #define SERVER_BASEVENDOR   "Apache Group"
 #define SERVER_BASEPRODUCT  "Apache"
 #define SERVER_BASEREVISION "1.3.33"
-#define SERVER_BASEVERSION  SERVER_BASEPRODUCT "/" SERVER_BASEREVISION
+#ifdef APACHE_SSL
+# define SERVER_BASEVERSION  SERVER_BASEPRODUCT "/" SERVER_BASEREVISION " Ben-SSL/1.55"
+#else
+# define SERVER_BASEVERSION  SERVER_BASEPRODUCT "/" SERVER_BASEREVISION
+#endif
 
 #define SERVER_PRODUCT  SERVER_BASEPRODUCT
 #define SERVER_REVISION SERVER_BASEREVISION
@@ -865,6 +879,11 @@
 #define DEFAULT_VHOST_ADDR 0xfffffffful
 
 typedef struct server_addr_rec server_addr_rec;
+
+#ifdef APACHE_SSL
+int ApacheSSLSetupConnection(conn_rec *conn);
+void ApacheSSLAddCommonVars(request_rec *r);
+#endif
 struct server_addr_rec {
     server_addr_rec *next;
     struct in_addr host_addr;	/* The bound address, for this server */
diff -u -r ../apache_1.3.33/src/main/Makefile.tmpl ./src/main/Makefile.tmpl
--- ../apache_1.3.33/src/main/Makefile.tmpl	Thu Jun 22 23:22:27 2000
+++ ./src/main/Makefile.tmpl	Fri Nov  5 11:07:05 2004
@@ -14,7 +14,7 @@
       rfc1413.o
 
 .c.o:
-	$(CC) -c $(INCLUDES) $(CFLAGS) $<
+	$(CC) -c $(INCLUDES) $(CFLAGS) $(SSL_CFLAGS) $<
 
 all: $(HEADERS) $(LIB)
 
@@ -60,30 +60,30 @@
 # DO NOT REMOVE
 alloc.o: alloc.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h $(INCDIR)/ap_alloc.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/ap_alloc.h \
  $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \
  $(INCDIR)/multithread.h $(INCDIR)/http_log.h
 buff.o: buff.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h $(INCDIR)/ap_alloc.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/ap_alloc.h \
  $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \
  $(INCDIR)/http_main.h $(INCDIR)/http_log.h
 gen_test_char.o: gen_test_char.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
- $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h $(INCDIR)/ap_ctype.h \
- $(INCDIR)/hsregex.h $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h \
+ $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h $(OSDIR)/os-inline.c \
+ $(INCDIR)/ap_ctype.h $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h \
  $(INCDIR)/ap.h $(INCDIR)/util_uri.h
 gen_uri_delims.o: gen_uri_delims.c
 http_config.o: http_config.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h $(INCDIR)/ap_alloc.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/ap_alloc.h \
  $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \
  $(INCDIR)/http_config.h $(INCDIR)/http_core.h $(INCDIR)/http_log.h \
  $(INCDIR)/http_request.h $(INCDIR)/http_conf_globals.h \
- $(INCDIR)/http_vhost.h $(INCDIR)/explain.h
+ $(INCDIR)/http_vhost.h $(INCDIR)/explain.h $(INCDIR)/fnmatch.h
 http_core.o: http_core.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h $(INCDIR)/ap_alloc.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/ap_alloc.h \
  $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \
  $(INCDIR)/http_config.h $(INCDIR)/http_core.h \
  $(INCDIR)/http_protocol.h $(INCDIR)/http_request.h \
@@ -93,23 +93,24 @@
  $(INCDIR)/fnmatch.h
 http_log.o: http_log.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h $(INCDIR)/ap_alloc.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/ap_alloc.h \
  $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \
- $(INCDIR)/http_config.h $(INCDIR)/http_core.h $(INCDIR)/http_log.h \
- $(INCDIR)/http_main.h
+ $(INCDIR)/http_conf_globals.h $(INCDIR)/http_config.h \
+ $(INCDIR)/http_core.h $(INCDIR)/http_log.h $(INCDIR)/http_main.h
 http_main.o: http_main.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h $(INCDIR)/ap_alloc.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/ap_alloc.h \
  $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \
  $(INCDIR)/http_main.h $(INCDIR)/http_log.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_protocol.h $(INCDIR)/http_request.h \
  $(INCDIR)/http_conf_globals.h $(INCDIR)/http_core.h \
  $(INCDIR)/http_vhost.h $(INCDIR)/util_script.h \
- $(INCDIR)/scoreboard.h $(INCDIR)/multithread.h $(INCDIR)/explain.h
+ $(INCDIR)/scoreboard.h $(INCDIR)/multithread.h $(INCDIR)/explain.h \
+ ../lib/expat-lite/xmlparse.h
 http_protocol.o: http_protocol.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
- $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h $(INCDIR)/ap_ctype.h \
- $(INCDIR)/hsregex.h $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h \
+ $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h $(OSDIR)/os-inline.c \
+ $(INCDIR)/ap_ctype.h $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h \
  $(INCDIR)/ap.h $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_core.h $(INCDIR)/http_protocol.h \
  $(INCDIR)/http_main.h $(INCDIR)/http_request.h \
@@ -117,8 +118,8 @@
  $(INCDIR)/http_conf_globals.h
 http_request.o: http_request.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
- $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h $(INCDIR)/ap_ctype.h \
- $(INCDIR)/hsregex.h $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h \
+ $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h $(OSDIR)/os-inline.c \
+ $(INCDIR)/ap_ctype.h $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h \
  $(INCDIR)/ap.h $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_request.h $(INCDIR)/http_core.h \
  $(INCDIR)/http_protocol.h $(INCDIR)/http_conf_globals.h \
@@ -126,32 +127,32 @@
  $(INCDIR)/fnmatch.h
 http_vhost.o: http_vhost.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h $(INCDIR)/ap_alloc.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/ap_alloc.h \
  $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \
  $(INCDIR)/http_config.h $(INCDIR)/http_conf_globals.h \
  $(INCDIR)/http_log.h $(INCDIR)/http_vhost.h \
  $(INCDIR)/http_protocol.h
 rfc1413.o: rfc1413.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h $(INCDIR)/ap_alloc.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/ap_alloc.h \
  $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \
  $(INCDIR)/http_log.h $(INCDIR)/rfc1413.h $(INCDIR)/http_main.h
 util.o: util.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h $(INCDIR)/ap_alloc.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/ap_alloc.h \
  $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \
  $(INCDIR)/http_conf_globals.h $(INCDIR)/http_log.h test_char.h
 util_date.o: util_date.c $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
- $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h $(INCDIR)/ap_ctype.h \
- $(INCDIR)/hsregex.h $(INCDIR)/util_date.h
+ $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h $(OSDIR)/os-inline.c \
+ $(INCDIR)/ap_ctype.h $(INCDIR)/util_date.h
 util_md5.o: util_md5.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h $(INCDIR)/ap_alloc.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/ap_alloc.h \
  $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \
  $(INCDIR)/util_md5.h $(INCDIR)/ap_md5.h
 util_script.o: util_script.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h $(INCDIR)/ap_alloc.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/ap_alloc.h \
  $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \
  $(INCDIR)/http_config.h $(INCDIR)/http_conf_globals.h \
  $(INCDIR)/http_main.h $(INCDIR)/http_log.h \
@@ -160,6 +161,6 @@
  $(INCDIR)/util_date.h
 util_uri.o: util_uri.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h $(INCDIR)/ap_alloc.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h $(INCDIR)/ap_alloc.h \
  $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \
  $(INCDIR)/http_log.h $(INCDIR)/http_conf_globals.h uri_delims.h
diff -u -r ../apache_1.3.33/src/main/buff.c ./src/main/buff.c
--- ../apache_1.3.33/src/main/buff.c	Mon Feb 16 22:29:32 2004
+++ ./src/main/buff.c	Fri Nov  5 11:07:06 2004
@@ -31,6 +31,10 @@
 #include <bstring.h>		/* for IRIX, FD_SET calls bzero() */
 #endif
 
+#ifdef APACHE_SSL
+# include <openssl/err.h>
+#endif
+
 #ifndef DEFAULT_BUFSIZE
 #define DEFAULT_BUFSIZE (4096)
 #endif
@@ -250,6 +254,46 @@
     }
     else
 #endif
+#ifdef APACHE_SSL
+    if(fb->ssl)
+	{
+	int pa;
+
+	do
+	    {
+	    /* A horrible hack: an increase in this stat indicates that the
+	       client renegotiated. Is there a better way? Ben 10 Apr 1999
+	    */
+	    pa=fb->ssl->ctx->stats.sess_accept;
+
+	    rv=SSL_read(fb->ssl,buf,nbyte);
+
+	    ap_log_error(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,NULL,
+			 "read returned %d rwstate=%d state=%d rstate=%d "
+			 "cren=%d aren=%d accept=%d",
+			 rv,fb->ssl->rwstate,fb->ssl->state,fb->ssl->rstate,
+			 fb->ssl->ctx->stats.sess_connect_renegotiate,
+			 fb->ssl->ctx->stats.sess_accept_renegotiate,
+			 fb->ssl->ctx->stats.sess_accept);
+	    }
+	while(rv < 0 && fb->ssl->ctx->stats.sess_accept != pa);
+
+	if(rv < 0)
+	    {
+	    int l;
+
+	    while((l=ERR_get_error()))
+		{
+		char buf[MAX_STRING_LEN];
+
+		ERR_error_string(l,buf);
+		ap_log_error(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,NULL,"%s",
+			     buf);
+		}
+	    }
+	}
+    else
+#endif
 	rv = read(fb->fd_in, buf, nbyte);
     
     return rv;
@@ -291,6 +335,7 @@
 #else
     rv = ap_read(fb, buf, nbyte);
 #endif /* WIN32 */
+
     return rv;
 }
 
@@ -308,6 +353,27 @@
     }
     else
 #endif
+#ifdef APACHE_SSL
+    if(fb->ssl)
+	{
+	rv=SSL_write(fb->ssl,buf,nbyte);
+
+	if(rv < 0)
+	    {
+	    int l;
+
+	    while((l=ERR_get_error()))
+		{
+		char buf[MAX_STRING_LEN];
+
+		ERR_error_string(l,buf);
+		ap_log_error(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,NULL,"%s",
+			     buf);
+		}
+	    }
+	}
+    else
+#endif
 #if defined (B_SFIO)
 	rv = sfwrite(fb->sf_out, buf, nbyte);
 #else
@@ -421,6 +487,11 @@
     fb->callback_data = NULL;
     fb->filter_callback = NULL;
 
+#ifdef APACHE_SSL
+    fb->ssl = NULL;
+    fb->szClientX509 = NULL;
+#endif
+
     return fb;
 }
 
@@ -1151,7 +1222,7 @@
 	return write_with_errors(fb, buf, nbyte);
     }
 
-#ifdef NO_WRITEV
+#if defined(NO_WRITEV)
     /* without writev() this has poor performance, too bad */
 
     ap_snprintf(chunksize, sizeof(chunksize), "%x" CRLF, nbyte);
diff -u -r ../apache_1.3.33/src/main/http_config.c ./src/main/http_config.c
--- ../apache_1.3.33/src/main/http_config.c	Mon May 10 19:30:43 2004
+++ ./src/main/http_config.c	Fri Nov  5 11:07:06 2004
@@ -334,6 +334,26 @@
     return run_all ? OK : DECLINED;
 }
 
+#ifdef APACHE_SSL
+void ap_add_common_vars2(request_rec *r)
+    {
+    module *m;
+
+    for (m = top_module; m; m = m->next)
+	if (m->magic == SSL_MAGIC_COOKIE && m->add_common_vars)
+	    (*m->add_common_vars)(r);
+    }
+
+void ap_setup_connection(conn_rec *c)
+    {
+    module *m;
+
+    for (m = top_module; m; m = m->next)
+	if (m->magic == SSL_MAGIC_COOKIE && m->setup_connection)
+	    (*m->setup_connection)(c);
+    }
+#endif
+
 API_EXPORT(int) ap_translate_name(request_rec *r)
 {
     return run_method(r, offsets_into_method_ptrs.translate_handler, 0);
diff -u -r ../apache_1.3.33/src/main/http_log.c ./src/main/http_log.c
--- ../apache_1.3.33/src/main/http_log.c	Wed Sep 15 23:45:17 2004
+++ ./src/main/http_log.c	Fri Nov  5 11:07:06 2004
@@ -285,7 +285,8 @@
 	 * notice
 	 */
 	if (((level & APLOG_LEVELMASK) != APLOG_NOTICE) &&
-	    ((level & APLOG_LEVELMASK) > DEFAULT_LOGLEVEL))
+	    ((level & APLOG_LEVELMASK) > DEFAULT_LOGLEVEL)
+	    && !LogLevelIsDebug())
 	    return;
 	logf = stderr;
     }
diff -u -r ../apache_1.3.33/src/main/http_main.c ./src/main/http_main.c
--- ../apache_1.3.33/src/main/http_main.c	Wed Sep 15 23:45:17 2004
+++ ./src/main/http_main.c	Fri Nov  5 11:07:06 2004
@@ -370,6 +370,9 @@
 
 API_VAR_EXPORT int ap_change_shmem_uid = 0;
 
+int LogLevelIsDebug()
+    { return server_conf && server_conf->loglevel == APLOG_DEBUG; }
+
 /*
  * This routine is called when the pconf pool is vacuumed.  It resets the
  * server version string to a known value and [re]enables modifications
@@ -1705,8 +1708,21 @@
     }
 }
 
+/* Essentially the same as ap_keepalive_timeout, but used if you have no
+   request_rec */
+void ap_conn_timeout(char *name,conn_rec *conn)
+    {
+    unsigned int to;
 
+    timeout_req=NULL;
+    timeout_name=name;
 
+    if(conn->keptalive)
+	to=conn->server->keep_alive_timeout;
+    else
+	to=conn->server->timeout;
+    ap_set_callback_and_alarm(timeout, to);
+    }
 
 API_EXPORT(void) ap_keepalive_timeout(char *name, request_rec *r)
 {
@@ -4767,6 +4783,16 @@
 				          (struct sockaddr_in *) &sa_server,
 				          my_child_num);
 
+#ifdef APACHE_SSL
+	/* 
+	 * This could return false if the connection cannot be setup,
+	 * so maybe we should do something with this here...
+	 * however it also blocks the BUFF connections
+	 * so the next bit should fall out anyway!
+	 */
+	ap_setup_connection(current_conn);
+#endif
+
 	/*
 	 * Read and process each request found on our connection
 	 * until no requests are left or we decide to close.
@@ -5775,6 +5801,16 @@
 			          (struct sockaddr_in *) &sa_client,
 			          (struct sockaddr_in *) &sa_server, -1);
 
+#ifdef APACHE_SSL
+      /*
+       * This could return false if the connection cannot be setup,
+       * so maybe we should do something with this here...
+       * however it also blocks the BUFF connections
+       * so the next bit should fall out anyway!
+       */
+      ap_setup_connection(conn);
+#endif
+
 	while ((r = ap_read_request(conn)) != NULL) {
 
 	    if (r->status == HTTP_OK)
@@ -6085,6 +6121,16 @@
 	requests_this_child++;
 
 	ap_note_cleanups_for_socket_ex(ptrans, csd, 1);
+
+#ifdef APACHE_SSL
+	/* 
+	 * This returns false if the connection cannot be setup,
+	 * so maybe we should do something with this here...
+	 * however it also blocks the BUFF connections
+	 * so the next bit should fall out anyway!
+	 */
+	ApacheSSLSetupConnection(current_conn);
+#endif
 
 	/*
 	 * We now have a connection, so set it up with the appropriate
diff -u -r ../apache_1.3.33/src/main/util_script.c ./src/main/util_script.c
--- ../apache_1.3.33/src/main/util_script.c	Mon Feb 16 22:29:33 2004
+++ ./src/main/util_script.c	Fri Nov  5 11:07:07 2004
@@ -277,6 +277,10 @@
     }
 
     ap_overlap_tables(r->subprocess_env, e, AP_OVERLAP_TABLES_SET);
+
+#ifdef APACHE_SSL
+    ap_add_common_vars2(r);
+#endif
 }
 
 /* This "cute" little function comes about because the path info on
diff -u -r ../apache_1.3.33/src/modules/standard/Makefile.tmpl ./src/modules/standard/Makefile.tmpl
--- ../apache_1.3.33/src/modules/standard/Makefile.tmpl	Thu Jun 22 23:22:40 2000
+++ ./src/modules/standard/Makefile.tmpl	Fri Nov  5 11:07:07 2004
@@ -7,7 +7,7 @@
 mod_access.o: mod_access.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_core.h \
  $(INCDIR)/http_config.h $(INCDIR)/http_log.h \
@@ -15,7 +15,7 @@
 mod_actions.o: mod_actions.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_request.h $(INCDIR)/http_core.h \
@@ -24,12 +24,13 @@
 mod_alias.o: mod_alias.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
- $(INCDIR)/util_uri.h $(INCDIR)/http_config.h
+ $(INCDIR)/util_uri.h $(INCDIR)/http_core.h \
+ $(INCDIR)/http_config.h $(INCDIR)/http_log.h
 mod_asis.o: mod_asis.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h \
- $(OSDIR)/os.h $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os.h $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_protocol.h $(INCDIR)/http_log.h \
@@ -37,7 +38,7 @@
  $(INCDIR)/http_request.h
 mod_auth.o: mod_auth.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h \
- $(OSDIR)/os.h $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os.h $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_core.h $(INCDIR)/http_log.h \
@@ -45,7 +46,7 @@
 mod_auth_anon.o: mod_auth_anon.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_core.h $(INCDIR)/http_log.h \
@@ -53,7 +54,7 @@
 mod_auth_db.o: mod_auth_db.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_core.h $(INCDIR)/http_log.h \
@@ -61,7 +62,7 @@
 mod_auth_dbm.o: mod_auth_dbm.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_core.h $(INCDIR)/http_log.h \
@@ -69,23 +70,24 @@
 mod_autoindex.o: mod_autoindex.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_core.h $(INCDIR)/http_request.h \
  $(INCDIR)/http_protocol.h $(INCDIR)/http_log.h \
- $(INCDIR)/http_main.h $(INCDIR)/util_script.h
+ $(INCDIR)/http_main.h $(INCDIR)/util_script.h \
+ $(INCDIR)/fnmatch.h
 mod_cern_meta.o: mod_cern_meta.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/util_script.h $(INCDIR)/http_log.h \
  $(INCDIR)/http_request.h
 mod_cgi.o: mod_cgi.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h \
- $(OSDIR)/os.h $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os.h $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_request.h $(INCDIR)/http_core.h \
@@ -95,7 +97,7 @@
 mod_digest.o: mod_digest.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_core.h $(INCDIR)/http_log.h \
@@ -103,7 +105,7 @@
  $(INCDIR)/ap_md5.h
 mod_dir.o: mod_dir.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h \
- $(OSDIR)/os.h $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os.h $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_core.h $(INCDIR)/http_request.h \
@@ -111,25 +113,25 @@
  $(INCDIR)/http_main.h $(INCDIR)/util_script.h
 mod_env.o: mod_env.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h \
- $(OSDIR)/os.h $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os.h $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h
 mod_expires.o: mod_expires.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_log.h
 mod_headers.o: mod_headers.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h
 mod_imap.o: mod_imap.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h \
- $(OSDIR)/os.h $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os.h $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_request.h $(INCDIR)/http_core.h \
@@ -138,7 +140,7 @@
 mod_include.o: mod_include.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_request.h $(INCDIR)/http_core.h \
@@ -146,7 +148,7 @@
  $(INCDIR)/http_main.h $(INCDIR)/util_script.h
 mod_info.o: mod_info.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h \
- $(OSDIR)/os.h $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os.h $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_core.h $(INCDIR)/http_log.h \
@@ -155,34 +157,34 @@
 mod_log_agent.o: mod_log_agent.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_log.h
 mod_log_config.o: mod_log_config.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_core.h $(INCDIR)/http_log.h
 mod_log_referer.o: mod_log_referer.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_log.h
 mod_mime.o: mod_mime.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h \
- $(OSDIR)/os.h $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os.h $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_log.h
 mod_mime_magic.o: mod_mime_magic.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_request.h $(INCDIR)/http_core.h \
@@ -190,15 +192,16 @@
 mod_negotiation.o: mod_negotiation.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
- $(INCDIR)/http_request.h $(INCDIR)/http_core.h \
- $(INCDIR)/http_log.h $(INCDIR)/util_script.h
+ $(INCDIR)/http_request.h $(INCDIR)/http_protocol.h \
+ $(INCDIR)/http_core.h $(INCDIR)/http_log.h \
+ $(INCDIR)/util_script.h
 mod_rewrite.o: mod_rewrite.c mod_rewrite.h $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_conf_globals.h $(INCDIR)/http_request.h \
@@ -207,27 +210,27 @@
 mod_setenvif.o: mod_setenvif.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_core.h $(INCDIR)/http_log.h
 mod_so.o: mod_so.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h \
- $(OSDIR)/os.h $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os.h $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_log.h
 mod_speling.o: mod_speling.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_core.h \
  $(INCDIR)/http_config.h $(INCDIR)/http_log.h
 mod_status.o: mod_status.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_core.h $(INCDIR)/http_protocol.h \
@@ -237,20 +240,27 @@
 mod_unique_id.o: mod_unique_id.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_log.h $(INCDIR)/multithread.h
 mod_userdir.o: mod_userdir.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h
 mod_usertrack.o: mod_usertrack.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
+ $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
+ $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
+ $(INCDIR)/http_core.h
+mod_vhost_alias.o: mod_vhost_alias.c $(INCDIR)/httpd.h \
+ $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
+ $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
  $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
  $(INCDIR)/http_core.h
diff -u -r ../apache_1.3.33/src/modules/standard/mod_log_config.c ./src/modules/standard/mod_log_config.c
--- ../apache_1.3.33/src/modules/standard/mod_log_config.c	Fri Feb 20 20:37:40 2004
+++ ./src/modules/standard/mod_log_config.c	Fri Nov  5 11:07:07 2004
@@ -94,6 +94,15 @@
  * %...m:  the request method
  * %...{Foobar}n:  The contents of note "Foobar" from another module.
  * %...{Foobar}o:  The contents of Foobar: header line(s) in the reply.
+ *
+ * Additional SSL directives:
+ *
+ * %...{cipher}c:  cipher used (SSL_get_cipher)
+ * %...{clientcert}c: client certificate information
+ * %...{errcode}c: X509 verify error code
+ * %...{errstr}c: X509 verify error string
+ * %...{version}c: SSL version (SSLeay 0.8.0 and above)
+ *
  * %...p:  the port the request was served to
  * %...P:  the process ID of the child that serviced the request.
  * %...q:  the query string prepended by "?", or empty if no query string
@@ -143,6 +152,10 @@
 #include "http_log.h"
 #include <limits.h>
 
+#ifdef APACHE_SSL
+# include <openssl/crypto.h>
+#endif
+
 module MODULE_VAR_EXPORT config_log_module;
 
 static int xfer_flags = (O_WRONLY | O_APPEND | O_CREAT);
@@ -452,6 +465,10 @@
  * Parsing the log format string
  */
 
+#ifdef APACHE_SSL
+extern const char *log_ssl_info(request_rec *r, char *a);
+#endif
+
 static struct log_item_list {
     char ch;
     item_key_func func;
@@ -515,6 +532,9 @@
     {
         's', log_status, 1
     },
+#ifdef APACHE_SSL
+    { 'c', log_ssl_info, 0 },
+#endif
     {
         't', log_request_time, 0
     },
@@ -982,6 +1002,71 @@
 
     return err_string;
 }
+
+#ifdef APACHE_SSL
+const char *log_ssl_info(request_rec *r, char *a)
+    {
+    char str[MAX_STRING_LEN];
+
+    if(!r->connection->client->ssl)
+	return NULL;
+
+    if(!strcmp(a, "cipher"))
+	return SSL_get_cipher(r->connection->client->ssl);
+
+    if(!strcmp(a, "clientcert"))
+	return r->connection->client->szClientX509;
+
+    if(!strcmp(a, "errcode"))
+	if(r->connection->client->nVerifyError)
+	    {
+	    sprintf(str, "%d", r->connection->client->nVerifyError);
+	    return ap_pstrdup(r->pool,str);
+	    }
+	else
+	    return NULL;
+
+    if(!strcmp(a, "errstr"))
+	if(r->connection->client->nVerifyError)
+#if SSLEAY_VERSION_NUMBER < 0x0800
+	    return X509_cert_verify_error_string(r->connection->client->nVerifyError);
+#else
+	    return X509_verify_cert_error_string(r->connection->client->nVerifyError);
+#endif
+	else
+	    return NULL;
+
+#if SSLEAY_VERSION_NUMBER >= 0x0800
+    if(!strcmp(a, "version"))
+	{
+#if SSLEAY_VERSION_NUMBER >= 0x0900
+	switch(r->connection->client->ssl->session->ssl_version)
+	    {
+	case TLS1_VERSION:
+	    return "TLS1";
+
+	case SSL3_VERSION:
+	    return "SSL3";
+
+	case SSL2_VERSION:
+	    return "SSL2";
+
+	default:
+	    return "?";
+	    }
+#else
+	static char v[2];
+
+	v[0]='0'+r->connection->client->ssl->session->ssl_version;
+	v[1]='\0';
+	return v;
+#endif
+	}
+#endif
+    
+    return NULL;
+}
+#endif
 
 static const char *set_transfer_log(cmd_parms *cmd, void *dummy, char *fn)
 {
diff -u -r ../apache_1.3.33/src/modules/standard/mod_so.c ./src/modules/standard/mod_so.c
--- ../apache_1.3.33/src/modules/standard/mod_so.c	Wed Sep  8 13:35:12 2004
+++ ./src/modules/standard/mod_so.c	Fri Nov  5 11:07:07 2004
@@ -266,7 +266,8 @@
      * Make sure the found module structure is really a module structure
      * 
      */
-    if (modp->magic != MODULE_MAGIC_COOKIE) {
+    if (modp->magic != MODULE_MAGIC_COOKIE
+	&& modp->magic != SSL_MAGIC_COOKIE) {
         return ap_pstrcat(cmd->pool, "API module structure `", modname,
                           "' in file ", szModuleFile, " is garbled -"
                           " perhaps this is not an Apache module DSO?", NULL);
diff -u -r ../apache_1.3.33/src/os/unix/Makefile.tmpl ./src/os/unix/Makefile.tmpl
--- ../apache_1.3.33/src/os/unix/Makefile.tmpl	Mon Sep  7 06:59:35 1998
+++ ./src/os/unix/Makefile.tmpl	Fri Nov  5 11:07:08 2004
@@ -41,7 +41,7 @@
 os-aix-dso.o: os-aix-dso.c
 os-inline.o: os-inline.c $(INCDIR)/ap_config.h \
  $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h \
- $(OSDIR)/os.h $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h
+ $(OSDIR)/os.h $(INCDIR)/ap_ctype.h
 os.o: os.c $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h os.h
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h os.h
diff -u -r ../apache_1.3.33/src/support/apachectl ./src/support/apachectl
--- ../apache_1.3.33/src/support/apachectl	Fri Feb 20 22:02:24 2004
+++ ./src/support/apachectl	Fri Nov  5 11:07:08 2004
@@ -22,11 +22,11 @@
 #	0 - operation completed successfully
 #	1 - 
 #	2 - usage error
-#	3 - httpd could not be started
-#	4 - httpd could not be stopped
-#	5 - httpd could not be started during a restart
-#	6 - httpd could not be restarted during a restart
-#	7 - httpd could not be restarted during a graceful restart
+#	3 - httpsd could not be started
+#	4 - httpsd could not be stopped
+#	5 - httpsd could not be started during a restart
+#	6 - httpsd could not be restarted during a restart
+#	7 - httpsd could not be restarted during a graceful restart
 #	8 - configuration syntax error
 #
 # When multiple arguments are given, only the error from the _last_
@@ -39,8 +39,8 @@
 # the path to your PID file
 PIDFILE=/usr/local/apache/logs/httpd.pid
 #
-# the path to your httpd binary, including options if necessary
-HTTPD='/usr/local/apache/src/httpd'
+# the path to your httpsd binary, including options if necessary
+HTTPD='/usr/local/apache/src/httpsd'
 #
 # a command that outputs a formatted text version of the HTML at the
 # url given on the command line.  Designed for lynx, however other
@@ -66,27 +66,27 @@
     if [ -f $PIDFILE ] ; then
 	PID=`cat $PIDFILE`
 	if [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null ; then
-	    STATUS="httpd (pid $PID) running"
+	    STATUS="httpsd (pid $PID) running"
 	    RUNNING=1
 	else
-	    STATUS="httpd (pid $PID?) not running"
+	    STATUS="httpsd (pid $PID?) not running"
 	    RUNNING=0
 	fi
     else
-	STATUS="httpd (no pid file) not running"
+	STATUS="httpsd (no pid file) not running"
 	RUNNING=0
     fi
 
     case $ARG in
     start)
 	if [ $RUNNING -eq 1 ]; then
-	    echo "$0 $ARG: httpd (pid $PID) already running"
+	    echo "$0 $ARG: httpsd (pid $PID) already running"
 	    continue
 	fi
 	if $HTTPD ; then
-	    echo "$0 $ARG: httpd started"
+	    echo "$0 $ARG: httpsd started"
 	else
-	    echo "$0 $ARG: httpd could not be started"
+	    echo "$0 $ARG: httpsd could not be started"
 	    ERROR=3
 	fi
 	;;
@@ -96,27 +96,27 @@
 	    continue
 	fi
 	if kill $PID ; then
-	    echo "$0 $ARG: httpd stopped"
+	    echo "$0 $ARG: httpsd stopped"
 	else
-	    echo "$0 $ARG: httpd could not be stopped"
+	    echo "$0 $ARG: httpsd could not be stopped"
 	    ERROR=4
 	fi
 	;;
     restart)
 	if [ $RUNNING -eq 0 ]; then
-	    echo "$0 $ARG: httpd not running, trying to start"
+	    echo "$0 $ARG: httpsd not running, trying to start"
 	    if $HTTPD ; then
-		echo "$0 $ARG: httpd started"
+		echo "$0 $ARG: httpsd started"
 	    else
-		echo "$0 $ARG: httpd could not be started"
+		echo "$0 $ARG: httpsd could not be started"
 		ERROR=5
 	    fi
 	else
 	    if $HTTPD -t >/dev/null 2>&1; then
 		if kill -HUP $PID ; then
-		    echo "$0 $ARG: httpd restarted"
+		    echo "$0 $ARG: httpsd restarted"
 		else
-		    echo "$0 $ARG: httpd could not be restarted"
+		    echo "$0 $ARG: httpsd could not be restarted"
 		    ERROR=6
 		fi
 	    else
@@ -128,19 +128,19 @@
 	;;
     graceful)
 	if [ $RUNNING -eq 0 ]; then
-	    echo "$0 $ARG: httpd not running, trying to start"
+	    echo "$0 $ARG: httpsd not running, trying to start"
 	    if $HTTPD ; then
-		echo "$0 $ARG: httpd started"
+		echo "$0 $ARG: httpsd started"
 	    else
-		echo "$0 $ARG: httpd could not be started"
+		echo "$0 $ARG: httpsd could not be started"
 		ERROR=5
 	    fi
 	else
 	    if $HTTPD -t >/dev/null 2>&1; then
 		if kill -USR1 $PID ; then
-		    echo "$0 $ARG: httpd gracefully restarted"
+		    echo "$0 $ARG: httpsd gracefully restarted"
 		else
-		    echo "$0 $ARG: httpd could not be restarted"
+		    echo "$0 $ARG: httpsd could not be restarted"
 		    ERROR=7
 		fi
 	    else
@@ -167,9 +167,9 @@
 	echo "usage: $0 (start|stop|restart|fullstatus|status|graceful|configtest|help)"
 	cat <<EOF
 
-start      - start httpd
-stop       - stop httpd
-restart    - restart httpd if running by sending a SIGHUP or start if 
+start      - start httpsd
+stop       - stop httpsd
+restart    - restart httpsd if running by sending a SIGHUP or start if 
              not running
 fullstatus - dump a full status screen; requires lynx and mod_status enabled
 status     - dump a short status screen; requires lynx and mod_status enabled
diff -u -r ../apache_1.3.33/src/support/suexec.c ./src/support/suexec.c
--- ../apache_1.3.33/src/support/suexec.c	Fri Feb 20 22:02:24 2004
+++ ./src/support/suexec.c	Fri Nov  5 11:07:08 2004
@@ -90,6 +90,8 @@
 {
     /* variable name starts with */
     "HTTP_",
+    "HTTPS",
+    "SSL_",
 
     /* variable name is */
     "AUTH_TYPE=",
