aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xautogen.sh4
-rw-r--r--configure.ac21
-rw-r--r--include/mod_gnutls.h.in4
-rw-r--r--src/Makefile.am16
-rw-r--r--src/gnutls_cache.c88
-rw-r--r--src/mod_gnutls.c4
6 files changed, 76 insertions, 61 deletions
diff --git a/autogen.sh b/autogen.sh
index 6c8e11f..20db562 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -3,8 +3,8 @@
3# $Id: autogen.sh,v 1.1 2004/03/04 08:12:13 firechipmunk Exp $ 3# $Id: autogen.sh,v 1.1 2004/03/04 08:12:13 firechipmunk Exp $
4libtoolize --force --copy 4libtoolize --force --copy
5#libtoolize14 --force --copy 5#libtoolize14 --force --copy
6aclocal -I m4 6aclocal-1.9 -I m4
7autoheader 7autoheader
8automake --add-missing --copy --foreign 8automake-1.9 --add-missing --copy --foreign
9autoconf 9autoconf
10rm -rf autom4te.cache 10rm -rf autom4te.cache
diff --git a/configure.ac b/configure.ac
index 001f145..086b9f5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,16 +1,18 @@
1AC_INIT 1
2AC_INIT(mod_gnutls, 0.1.0)
2OOO_CONFIG_NICE(config.nice) 3OOO_CONFIG_NICE(config.nice)
4AC_PREREQ(2.53)
3AC_CONFIG_SRCDIR([src/mod_gnutls.c]) 5AC_CONFIG_SRCDIR([src/mod_gnutls.c])
6AC_CONFIG_AUX_DIR(config)
4AM_MAINTAINER_MODE 7AM_MAINTAINER_MODE
5AC_CANONICAL_TARGET 8AC_CANONICAL_TARGET
6AM_INIT_AUTOMAKE(mod_gnutls, 0.1.0) 9AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
7AM_CONFIG_HEADER([include/mod_gnutls_config.h:config.in]) 10AM_CONFIG_HEADER(include/mod_gnutls_config.h:config.in)
8 11
9 12
10AC_PROG_CC 13AC_PROG_CC
11AC_PROG_LD 14AC_PROG_LD
12AC_PROG_INSTALL 15AC_PROG_INSTALL
13AM_PROG_LIBTOOL
14 16
15 17
16AP_VERSION=2.0.40 18AP_VERSION=2.0.40
@@ -19,10 +21,15 @@ CHECK_APACHE(,$AP_VERSION,
19 AC_MSG_ERROR([*** Apache version $AP_VERSION not found!]) 21 AC_MSG_ERROR([*** Apache version $AP_VERSION not found!])
20) 22)
21 23
22MIN_TLS_VERSION=1.1.0 24LIBTOOL="`${APR_CONFIG} --apr-libtool`"
25AC_SUBST(LIBTOOL)
26
27MIN_TLS_VERSION=1.2.0
23CHECK_LIBGNUTLS($MIN_TLS_VERSION) 28CHECK_LIBGNUTLS($MIN_TLS_VERSION)
24 29
25CHECK_APR_MEMCACHE() 30have_apr_memcache=0
31CHECK_APR_MEMCACHE([have_apr_memcache=1], [have_apr_memcache=0])
32AC_SUBST(have_apr_memcache)
26 33
27MODULE_CFLAGS="${LIBGNUTLS_CFLAGS} ${APR_MEMCACHE_CFLAGS} ${APXS_CFLAGS} ${AP_INCLUDES} ${APR_INCLUDES} ${APU_INCLUDES}" 34MODULE_CFLAGS="${LIBGNUTLS_CFLAGS} ${APR_MEMCACHE_CFLAGS} ${APXS_CFLAGS} ${AP_INCLUDES} ${APR_INCLUDES} ${APU_INCLUDES}"
28MODULE_LIBS="${APR_MEMCACHE_LIBS} ${LIBGNUTLS_LIBS}" 35MODULE_LIBS="${APR_MEMCACHE_LIBS} ${LIBGNUTLS_LIBS}"
@@ -30,7 +37,7 @@ MODULE_LIBS="${APR_MEMCACHE_LIBS} ${LIBGNUTLS_LIBS}"
30AC_SUBST(MODULE_CFLAGS) 37AC_SUBST(MODULE_CFLAGS)
31AC_SUBST(MODULE_LIBS) 38AC_SUBST(MODULE_LIBS)
32 39
33AC_CONFIG_FILES([Makefile src/Makefile]) 40AC_CONFIG_FILES([Makefile src/Makefile include/mod_gnutls.h])
34AC_OUTPUT 41AC_OUTPUT
35 42
36echo "---" 43echo "---"
diff --git a/include/mod_gnutls.h.in b/include/mod_gnutls.h.in
index 03ba4d1..469e678 100644
--- a/include/mod_gnutls.h.in
+++ b/include/mod_gnutls.h.in
@@ -29,9 +29,7 @@
29#ifndef __mod_gnutls_h_inc 29#ifndef __mod_gnutls_h_inc
30#define __mod_gnutls_h_inc 30#define __mod_gnutls_h_inc
31 31
32#if HAVE_APR_MEMCACHE 32#define HAVE_APR_MEMCACHE @have_apr_memcache@
33#include "apr_memcache.h"
34#endif
35 33
36#include <gcrypt.h> 34#include <gcrypt.h>
37#include <gnutls/gnutls.h> 35#include <gnutls/gnutls.h>
diff --git a/src/Makefile.am b/src/Makefile.am
index 1f1860b..30315a1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,13 +9,13 @@ lib_LTLIBRARIES = libmod_gnutls.la
9make_so: $(lib_LTLIBRARIES) 9make_so: $(lib_LTLIBRARIES)
10 @if test ! -L mod_gnutls.so ; then ln -s .libs/libmod_gnutls.so mod_gnutls.so ; fi 10 @if test ! -L mod_gnutls.so ; then ln -s .libs/libmod_gnutls.so mod_gnutls.so ; fi
11 11
12clean: 12clean:
13 rm -f mod_gnutls.so 13 rm -f mod_gnutls.so
14 rm -f *.o *.lo *.la 14 rm -f *.o *.lo *.la
15 rm -fr .libs 15 rm -fr .libs
16 16
17install: make_so 17install: make_so
18 @${APXS_BIN} -i -n svn_view mod_gnutls.so 18 @${APXS_BIN} -i -n gnutls mod_gnutls.so
19 @echo "" 19 @echo ""
20 @echo "" 20 @echo ""
21 @echo "***********************************************" 21 @echo "***********************************************"
@@ -27,15 +27,3 @@ install: make_so
27 @echo "***********************************************" 27 @echo "***********************************************"
28 @echo "" 28 @echo ""
29 29
30activate: make_so
31 @${APXS_BIN} -i -a -n svn_view mod_gnutls.so
32 @echo ""
33 @echo ""
34 @echo "***********************************************"
35 @echo ""
36 @echo " Please read the documentation at "
37 @echo " http://www.outoforder.cc/ for "
38 @echo " details on configuration of this module "
39 @echo ""
40 @echo "***********************************************"
41 @echo ""
diff --git a/src/gnutls_cache.c b/src/gnutls_cache.c
index cee30fa..c1a6f37 100644
--- a/src/gnutls_cache.c
+++ b/src/gnutls_cache.c
@@ -16,8 +16,38 @@
16 */ 16 */
17 17
18#include "mod_gnutls.h" 18#include "mod_gnutls.h"
19
20#if HAVE_APR_MEMCACHE
21#include "apr_memcache.h"
22#endif
23
19#include "ap_mpm.h" 24#include "ap_mpm.h"
20 25
26#define GNUTLS_SESSION_ID_STRING_LEN \
27 ((GNUTLS_MAX_SESSION_ID + 1) * 2)
28#define MC_TAG "mod_gnutls:"
29#define MC_TAG_LEN \
30 (sizeof(MC_TAG))
31#define STR_SESSION_LEN (GNUTLS_SESSION_ID_STRING_LEN + MC_TAG_LEN)
32
33static char *gnutls_session_id2sz(unsigned char *id, int idlen,
34 char *str, int strsize)
35{
36 char *cp;
37 int n;
38
39 cp = apr_cpystrn(str, MC_TAG, MC_TAG_LEN);
40 for (n = 0; n < idlen && n < GNUTLS_MAX_SESSION_ID; n++) {
41 apr_snprintf(cp, strsize - (cp-str), "%02X", id[n]);
42 cp += 2;
43 }
44 *cp = '\0';
45 return str;
46}
47
48
49#if HAVE_APR_MEMCACHE
50
21/** 51/**
22 * GnuTLS Session Cache using libmemcached 52 * GnuTLS Session Cache using libmemcached
23 * 53 *
@@ -26,7 +56,7 @@
26/* The underlying apr_memcache system is thread safe... woohoo */ 56/* The underlying apr_memcache system is thread safe... woohoo */
27static apr_memcache_t* mc; 57static apr_memcache_t* mc;
28 58
29int mod_gnutls_cache_child_init(apr_pool_t *p, server_rec *s, 59int mc_cache_child_init(apr_pool_t *p, server_rec *s,
30 mod_gnutls_srvconf_rec *sc) 60 mod_gnutls_srvconf_rec *sc)
31{ 61{
32 apr_status_t rv = APR_SUCCESS; 62 apr_status_t rv = APR_SUCCESS;
@@ -109,32 +139,8 @@ int mod_gnutls_cache_child_init(apr_pool_t *p, server_rec *s,
109 return rv; 139 return rv;
110} 140}
111 141
112/* thanks mod_ssl */ 142static int mc_cache_store(void* baton, gnutls_datum_t key,
113#define GNUTLS_SESSION_ID_STRING_LEN \ 143 gnutls_datum_t data)
114 ((GNUTLS_MAX_SESSION_ID + 1) * 2)
115#define MC_TAG "mod_gnutls:"
116#define MC_TAG_LEN \
117 (sizeof(MC_TAG))
118#define STR_SESSION_LEN (GNUTLS_SESSION_ID_STRING_LEN + MC_TAG_LEN)
119
120
121static char *gnutls_session_id2sz(unsigned char *id, int idlen,
122 char *str, int strsize)
123{
124 char *cp;
125 int n;
126
127 cp = apr_cpystrn(str, MC_TAG, MC_TAG_LEN);
128 for (n = 0; n < idlen && n < GNUTLS_MAX_SESSION_ID; n++) {
129 apr_snprintf(cp, strsize - (cp-str), "%02X", id[n]);
130 cp += 2;
131 }
132 *cp = '\0';
133 return str;
134}
135
136
137static int cache_store(void* baton, gnutls_datum_t key, gnutls_datum_t data)
138{ 144{
139 apr_status_t rv = APR_SUCCESS; 145 apr_status_t rv = APR_SUCCESS;
140 mod_gnutls_handle_t *ctxt = baton; 146 mod_gnutls_handle_t *ctxt = baton;
@@ -161,7 +167,7 @@ static int cache_store(void* baton, gnutls_datum_t key, gnutls_datum_t data)
161 return 0; 167 return 0;
162} 168}
163 169
164static gnutls_datum_t cache_fetch(void* baton, gnutls_datum_t key) 170static gnutls_datum_t mc_cache_fetch(void* baton, gnutls_datum_t key)
165{ 171{
166 apr_status_t rv = APR_SUCCESS; 172 apr_status_t rv = APR_SUCCESS;
167 mod_gnutls_handle_t *ctxt = baton; 173 mod_gnutls_handle_t *ctxt = baton;
@@ -190,7 +196,7 @@ static gnutls_datum_t cache_fetch(void* baton, gnutls_datum_t key)
190 return data; 196 return data;
191 } 197 }
192 198
193 /* TODO: Eliminate this memcpy. ffs. gnutls-- */ 199 /* TODO: Eliminate this memcpy. gnutls-- */
194 data.data = gnutls_malloc(value_len); 200 data.data = gnutls_malloc(value_len);
195 if (data.data == NULL) 201 if (data.data == NULL)
196 return data; 202 return data;
@@ -201,7 +207,7 @@ static gnutls_datum_t cache_fetch(void* baton, gnutls_datum_t key)
201 return data; 207 return data;
202} 208}
203 209
204static int cache_delete(void* baton, gnutls_datum_t key) 210static int mc_cache_delete(void* baton, gnutls_datum_t key)
205{ 211{
206 apr_status_t rv = APR_SUCCESS; 212 apr_status_t rv = APR_SUCCESS;
207 mod_gnutls_handle_t *ctxt = baton; 213 mod_gnutls_handle_t *ctxt = baton;
@@ -225,11 +231,27 @@ static int cache_delete(void* baton, gnutls_datum_t key)
225 return 0; 231 return 0;
226} 232}
227 233
234#endif /* have_apr_memcache */
235
236int mod_gnutls_cache_child_init(apr_pool_t *p, server_rec *s,
237 mod_gnutls_srvconf_rec *sc)
238{
239#if HAVE_APR_MEMCACHE
240 return mc_cache_child_init(p, s, sc);
241#else
242 return 0;
243#endif
244}
245
228int mod_gnutls_cache_session_init(mod_gnutls_handle_t *ctxt) 246int mod_gnutls_cache_session_init(mod_gnutls_handle_t *ctxt)
229{ 247{
230 gnutls_db_set_retrieve_function(ctxt->session, cache_fetch); 248#if HAVE_APR_MEMCACHE
231 gnutls_db_set_remove_function(ctxt->session, cache_delete); 249 gnutls_db_set_retrieve_function(ctxt->session, mc_cache_fetch);
232 gnutls_db_set_store_function(ctxt->session, cache_store); 250 gnutls_db_set_remove_function(ctxt->session, mc_cache_delete);
251 gnutls_db_set_store_function(ctxt->session, mc_cache_store);
233 gnutls_db_set_ptr(ctxt->session, ctxt); 252 gnutls_db_set_ptr(ctxt->session, ctxt);
253#else
254 /* TODO: Alternative Cache Backends */
255#endif
234 return 0; 256 return 0;
235} 257}
diff --git a/src/mod_gnutls.c b/src/mod_gnutls.c
index 833edc2..a1668f3 100644
--- a/src/mod_gnutls.c
+++ b/src/mod_gnutls.c
@@ -124,7 +124,7 @@ static void mod_gnutls_hook_child_init(apr_pool_t *p, server_rec *s)
124 } 124 }
125} 125}
126 126
127static const char *mod_gnutls_hook_http_method(const request_rec * r) 127static const char *mod_gnutls_hook_http_scheme(const request_rec * r)
128{ 128{
129 mod_gnutls_srvconf_rec *sc = 129 mod_gnutls_srvconf_rec *sc =
130 (mod_gnutls_srvconf_rec *) ap_get_module_config(r->server-> 130 (mod_gnutls_srvconf_rec *) ap_get_module_config(r->server->
@@ -340,7 +340,7 @@ static void gnutls_hooks(apr_pool_t * p)
340 APR_HOOK_MIDDLE); 340 APR_HOOK_MIDDLE);
341 ap_hook_child_init(mod_gnutls_hook_child_init, NULL, NULL, 341 ap_hook_child_init(mod_gnutls_hook_child_init, NULL, NULL,
342 APR_HOOK_MIDDLE); 342 APR_HOOK_MIDDLE);
343 ap_hook_http_method(mod_gnutls_hook_http_method, NULL, NULL, 343 ap_hook_http_scheme(mod_gnutls_hook_http_scheme, NULL, NULL,
344 APR_HOOK_MIDDLE); 344 APR_HOOK_MIDDLE);
345 ap_hook_default_port(mod_gnutls_hook_default_port, NULL, NULL, 345 ap_hook_default_port(mod_gnutls_hook_default_port, NULL, NULL,
346 APR_HOOK_MIDDLE); 346 APR_HOOK_MIDDLE);