From 2cb49bd5137176e1445550399b6e9592607858a3 Mon Sep 17 00:00:00 2001 From: Nokis Mavrogiannopoulos Date: Wed, 5 Mar 2008 17:38:09 +0000 Subject: --- src/gnutls_cache.c | 9 ++++++++- src/gnutls_config.c | 7 +++++++ src/gnutls_hooks.c | 6 ++++++ src/mod_gnutls.c | 3 ++- 4 files changed, 23 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gnutls_cache.c b/src/gnutls_cache.c index 83e7bb5..90f5a86 100644 --- a/src/gnutls_cache.c +++ b/src/gnutls_cache.c @@ -1,5 +1,6 @@ /** * Copyright 2004-2005 Paul Querna + * Portions Copyright 2008 Nikos Mavrogiannopoulos * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -345,6 +346,7 @@ static int dbm_cache_expire(mgs_handle_t *ctxt) break; } } + apr_dbm_freedatum( dbm, dbmval); } apr_dbm_nextkey(dbm, &dbmkey); @@ -401,20 +403,25 @@ static gnutls_datum_t dbm_cache_fetch(void* baton, gnutls_datum_t key) } if (dbmval.dptr == NULL || dbmval.dsize <= sizeof(apr_time_t)) { + apr_dbm_freedatum( dbm, dbmval); apr_dbm_close(dbm); return data; } - apr_dbm_close(dbm); data.size = dbmval.dsize - sizeof(apr_time_t); data.data = gnutls_malloc(data.size); if (data.data == NULL) { + apr_dbm_freedatum( dbm, dbmval); + apr_dbm_close(dbm); return data; } memcpy(data.data, dbmval.dptr+sizeof(apr_time_t), data.size); + apr_dbm_freedatum( dbm, dbmval); + apr_dbm_close(dbm); + return data; } diff --git a/src/gnutls_config.c b/src/gnutls_config.c index 8d6308a..4786f6d 100644 --- a/src/gnutls_config.c +++ b/src/gnutls_config.c @@ -202,6 +202,8 @@ const char *mgs_set_key_file(cmd_parms * parms, void *dummy, return NULL; } +#ifdef ENABLE_SRP + const char *mgs_set_srp_tpasswd_file(cmd_parms * parms, void *dummy, const char *arg) { @@ -228,6 +230,8 @@ const char *mgs_set_srp_tpasswd_conf_file(cmd_parms * parms, void *dummy, return NULL; } +#endif + const char *mgs_set_cache(cmd_parms * parms, void *dummy, const char *type, const char *arg) { @@ -426,6 +430,7 @@ void *mgs_config_server_create(apr_pool_t * p, server_rec * s) ": (%d) %s", ret, gnutls_strerror(ret)); } +#ifdef ENABLE_SRP ret = gnutls_srp_allocate_server_credentials(&sc->srp_creds); if (ret < 0) { return apr_psprintf(p, "GnuTLS: Failed to initialize" @@ -434,6 +439,8 @@ void *mgs_config_server_create(apr_pool_t * p, server_rec * s) sc->srp_tpasswd_conf_file = NULL; sc->srp_tpasswd_file = NULL; +#endif + sc->privkey_x509 = NULL; memset( sc->certs_x509, 0, sizeof(sc->certs_x509)); sc->certs_x509_num = 0; diff --git a/src/gnutls_hooks.c b/src/gnutls_hooks.c index 55a1120..0483602 100644 --- a/src/gnutls_hooks.c +++ b/src/gnutls_hooks.c @@ -115,11 +115,13 @@ static int mgs_select_virtual_server_cb(gnutls_session_t session) gnutls_credentials_set(session, GNUTLS_CRD_ANON, ctxt->sc->anon_creds); +#ifdef ENABLE_SRP if (ctxt->sc->srp_tpasswd_conf_file != NULL && ctxt->sc->srp_tpasswd_file != NULL) { gnutls_credentials_set(session, GNUTLS_CRD_SRP, ctxt->sc->srp_creds); } +#endif /* update the priorities - to avoid negotiating a ciphersuite that is not * enabled on this virtual server. Note that here we ignore the version @@ -313,6 +315,7 @@ mgs_hook_post_config(apr_pool_t * p, apr_pool_t * plog, gnutls_certificate_server_set_retrieve_function(sc->certs, cert_retrieve_fn); +#ifdef ENABLE_SRP if (sc->srp_tpasswd_conf_file != NULL && sc->srp_tpasswd_file != NULL) { rv = gnutls_srp_set_server_credentials_file(sc->srp_creds, @@ -329,6 +332,7 @@ mgs_hook_post_config(apr_pool_t * p, apr_pool_t * plog, exit(-1); } } +#endif if (sc->certs_x509[0] == NULL && sc->enabled == GNUTLS_ENABLED_TRUE) { @@ -662,8 +666,10 @@ int mgs_hook_fixups(request_rec * r) gnutls_compression_get_name(gnutls_compression_get (ctxt->session))); +#ifdef ENABLE_SRP apr_table_setn(env, "SSL_SRP_USER", gnutls_srp_server_get_username(ctxt->session)); +#endif if (apr_table_get(env, "SSL_CLIENT_VERIFY") == NULL) apr_table_setn(env, "SSL_CLIENT_VERIFY", "NONE"); diff --git a/src/mod_gnutls.c b/src/mod_gnutls.c index a6e5528..cc760e6 100644 --- a/src/mod_gnutls.c +++ b/src/mod_gnutls.c @@ -17,7 +17,6 @@ #include "mod_gnutls.h" - static void gnutls_hooks(apr_pool_t * p) { ap_hook_pre_connection(mgs_hook_pre_connection, NULL, NULL, @@ -80,6 +79,7 @@ static const command_rec mgs_config_cmds[] = { NULL, RSRC_CONF, "SSL Server SRP Password file"), +#ifdef ENABLE_SRP AP_INIT_TAKE1("GnuTLSSRPPasswdFile", mgs_set_srp_tpasswd_file, NULL, RSRC_CONF, @@ -88,6 +88,7 @@ static const command_rec mgs_config_cmds[] = { NULL, RSRC_CONF, "SSL Server SRP Parameters file"), +#endif AP_INIT_TAKE1("GnuTLSCacheTimeout", mgs_set_cache_timeout, NULL, RSRC_CONF, -- cgit