summaryrefslogtreecommitdiffstats
path: root/mod_log_sql_ssl.c
blob: 3346d2f4f0149c5a0e2de4876dcfed45dbcbf45c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/* $Header: /home/cvs/mod_log_sql/mod_log_sql_ssl.c,v 1.1 2004/01/20 19:38:08 urkle Exp $ */
/* mod_log_sql_ssl */

#if defined(WITH_APACHE20)
#	include "apache20.h"
#elif defined(WITH_APACHE13)
#	include "apache13.h"
#else
#	error Unsupported Apache version
#endif

#ifdef HAVE_CONFIG_H
/* Undefine these to prevent conflicts between Apache ap_config_auto.h and 
 * my config.h. Only really needed for Apache < 2.0.48, but it can't hurt.
 */
#undef PACKAGE_BUGREPORT
#undef PACKAGE_NAME
#undef PACKAGE_STRING
#undef PACKAGE_TARNAME
#undef PACKAGE_VERSION

#include "config.h"
#endif

#include "mod_ssl.h"

static const char *extract_ssl_keysize(request_rec *r, char *a)
{
	char *result = NULL;
#if defined(APACHE20)
	SSLConnRec *scc = myConnConfig(r->connection);
	SSLSrvConfigRec *ssc = mySrvConfig(r->server);
	if (myCtxConfig(scc,ssc) != NULL
#elif defined(APACHE13)
	if (ap_ctx_get(r->connection->client->ctx, "ssl") != NULL) 
#endif
	{
	    result = ssl_var_lookup(r->pool, r->server, r->connection, r, "SSL_CIPHER_USEKEYSIZE");
		#ifdef DEBUG
    	    log_error(APLOG_MARK,APLOG_DEBUG,0,r->server,"SSL_KEYSIZE: %s", result);
		#endif
		if (result != NULL && result[0] == '\0')
	      result = NULL;
		return result;
	} else {
		return "0";
	}
}

static const char *extract_ssl_maxkeysize(request_rec *r, char *a)
{
	char *result = NULL;
#if defined(APACHE20)
	SSLConnRec *scc = myConnConfig(r->connection);
	SSLSrvConfigRec *ssc = mySrvConfig(r->server);
	if (myCtxConfig(scc,ssc) != NULL
#elif defined(APACHE13)
	if (ap_ctx_get(r->connection->client->ctx, "ssl") != NULL) 
#endif
	{
		result = ssl_var_lookup(r->pool, r->server, r->connection, r, "SSL_CIPHER_ALGKEYSIZE");
		#ifdef DEBUG
    	    log_error(APLOG_MARK,APLOG_DEBUG,0,r->server,"SSL_ALGKEYSIZE: %s", result);
		#endif
		if (result != NULL && result[0] == '\0')
	      result = NULL;
		return result;
	} else {
		return "0";
	}
}

static const char *extract_ssl_cipher(request_rec *r, char *a)
{
	char *result = NULL;
#if defined(APACHE20)
	SSLConnRec *scc = myConnConfig(r->connection);
	SSLSrvConfigRec *ssc = mySrvConfig(r->server);
	if (myCtxConfig(scc,ssc) != NULL
#elif defined(APACHE13)
	if (ap_ctx_get(r->connection->client->ctx, "ssl") != NULL) 
#endif
	{
	    result = ssl_var_lookup(r->pool, r->server, r->connection, r, "SSL_CIPHER");
		#ifdef DEBUG
    	    log_error(APLOG_MARK,APLOG_DEBUG,0,r->server,"SSL_CIPHER: %s", result);
		#endif
		if (result != NULL && result[0] == '\0')
	      result = NULL;
		return result;
	} else {
		return "-";
	}
}

#ifdef WANT_SSL_LOGGING
	{   'q', extract_ssl_keysize,       "ssl_keysize",      0, 1    },
	{   'Q', extract_ssl_maxkeysize,    "ssl_maxkeysize",   0, 1    },
	{   'z', extract_ssl_cipher,        "ssl_cipher",       0, 1    },
#endif