1 | /** |
---|
2 | * Copyright 2004-2005 Paul Querna |
---|
3 | * Copyright 2008 Nikos Mavrogiannopoulos |
---|
4 | * Copyright 2011 Dash Shendy |
---|
5 | * |
---|
6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
---|
7 | * you may not use this file except in compliance with the License. |
---|
8 | * You may obtain a copy of the License at |
---|
9 | * |
---|
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
11 | * |
---|
12 | * Unless required by applicable law or agreed to in writing, software |
---|
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
15 | * See the License for the specific language governing permissions and |
---|
16 | * limitations under the License. |
---|
17 | * |
---|
18 | */ |
---|
19 | |
---|
20 | #include "mod_gnutls.h" |
---|
21 | |
---|
22 | static void gnutls_hooks(apr_pool_t * p) { |
---|
23 | ap_hook_pre_connection(mgs_hook_pre_connection, NULL, NULL, |
---|
24 | APR_HOOK_MIDDLE); |
---|
25 | ap_hook_post_config(mgs_hook_post_config, NULL, NULL, |
---|
26 | APR_HOOK_MIDDLE); |
---|
27 | ap_hook_child_init(mgs_hook_child_init, NULL, NULL, |
---|
28 | APR_HOOK_MIDDLE); |
---|
29 | #if USING_2_1_RECENT |
---|
30 | ap_hook_http_scheme(mgs_hook_http_scheme, NULL, NULL, |
---|
31 | APR_HOOK_MIDDLE); |
---|
32 | #else |
---|
33 | ap_hook_http_method(mgs_hook_http_scheme, NULL, NULL, |
---|
34 | APR_HOOK_MIDDLE); |
---|
35 | #endif |
---|
36 | ap_hook_default_port(mgs_hook_default_port, NULL, NULL, |
---|
37 | APR_HOOK_MIDDLE); |
---|
38 | ap_hook_pre_config(mgs_hook_pre_config, NULL, NULL, |
---|
39 | APR_HOOK_MIDDLE); |
---|
40 | |
---|
41 | ap_hook_access_checker(mgs_hook_authz, NULL, NULL, |
---|
42 | APR_HOOK_REALLY_FIRST); |
---|
43 | |
---|
44 | ap_hook_fixups(mgs_hook_fixups, NULL, NULL, APR_HOOK_REALLY_FIRST); |
---|
45 | |
---|
46 | /* TODO: HTTP Upgrade Filter */ |
---|
47 | /* ap_register_output_filter ("UPGRADE_FILTER", |
---|
48 | * ssl_io_filter_Upgrade, NULL, AP_FTYPE_PROTOCOL + 5); |
---|
49 | */ |
---|
50 | |
---|
51 | ap_register_input_filter(GNUTLS_INPUT_FILTER_NAME, |
---|
52 | mgs_filter_input, NULL, |
---|
53 | AP_FTYPE_CONNECTION + 5); |
---|
54 | ap_register_output_filter(GNUTLS_OUTPUT_FILTER_NAME, |
---|
55 | mgs_filter_output, NULL, |
---|
56 | AP_FTYPE_CONNECTION + 5); |
---|
57 | } |
---|
58 | |
---|
59 | static const command_rec mgs_config_cmds[] = { |
---|
60 | AP_INIT_TAKE1("GnuTLSClientVerify", mgs_set_client_verify, |
---|
61 | NULL, |
---|
62 | RSRC_CONF | OR_AUTHCFG, |
---|
63 | "Set Verification Requirements of the Client Certificate"), |
---|
64 | AP_INIT_TAKE1("GnuTLSClientCAFile", mgs_set_client_ca_file, |
---|
65 | NULL, |
---|
66 | RSRC_CONF, |
---|
67 | "Set the CA File to verify Client Certificates"), |
---|
68 | AP_INIT_TAKE1("GnuTLSX509CAFile", mgs_set_client_ca_file, |
---|
69 | NULL, |
---|
70 | RSRC_CONF, |
---|
71 | "Set the CA File to verify Client Certificates"), |
---|
72 | AP_INIT_TAKE1("GnuTLSPGPKeyringFile", mgs_set_keyring_file, |
---|
73 | NULL, |
---|
74 | RSRC_CONF, |
---|
75 | "Set the Keyring File to verify Client Certificates"), |
---|
76 | AP_INIT_TAKE1("GnuTLSDHFile", mgs_set_dh_file, |
---|
77 | NULL, |
---|
78 | RSRC_CONF, |
---|
79 | "Set the file to read Diffie Hellman parameters from"), |
---|
80 | AP_INIT_TAKE1("GnuTLSRSAFile", mgs_set_rsa_export_file, |
---|
81 | NULL, |
---|
82 | RSRC_CONF, |
---|
83 | "Set the file to read RSA-EXPORT parameters from"), |
---|
84 | AP_INIT_TAKE1("GnuTLSCertificateFile", mgs_set_cert_file, |
---|
85 | NULL, |
---|
86 | RSRC_CONF, |
---|
87 | "SSL Server X509 Certificate file"), |
---|
88 | AP_INIT_TAKE1("GnuTLSKeyFile", mgs_set_key_file, |
---|
89 | NULL, |
---|
90 | RSRC_CONF, |
---|
91 | "SSL Server X509 Private Key file"), |
---|
92 | AP_INIT_TAKE1("GnuTLSX509CertificateFile", mgs_set_cert_file, |
---|
93 | NULL, |
---|
94 | RSRC_CONF, |
---|
95 | "SSL Server X509 Certificate file"), |
---|
96 | AP_INIT_TAKE1("GnuTLSX509KeyFile", mgs_set_key_file, |
---|
97 | NULL, |
---|
98 | RSRC_CONF, |
---|
99 | "SSL Server X509 Private Key file"), |
---|
100 | AP_INIT_TAKE1("GnuTLSPGPCertificateFile", mgs_set_pgpcert_file, |
---|
101 | NULL, |
---|
102 | RSRC_CONF, |
---|
103 | "SSL Server PGP Certificate file"), |
---|
104 | AP_INIT_TAKE1("GnuTLSPGPKeyFile", mgs_set_pgpkey_file, |
---|
105 | NULL, |
---|
106 | RSRC_CONF, |
---|
107 | "SSL Server PGP Private key file"), |
---|
108 | #ifdef ENABLE_SRP |
---|
109 | AP_INIT_TAKE1("GnuTLSSRPPasswdFile", mgs_set_srp_tpasswd_file, |
---|
110 | NULL, |
---|
111 | RSRC_CONF, |
---|
112 | "SSL Server SRP Password Conf file"), |
---|
113 | AP_INIT_TAKE1("GnuTLSSRPPasswdConfFile", |
---|
114 | mgs_set_srp_tpasswd_conf_file, |
---|
115 | NULL, |
---|
116 | RSRC_CONF, |
---|
117 | "SSL Server SRP Parameters file"), |
---|
118 | #endif |
---|
119 | AP_INIT_TAKE1("GnuTLSCacheTimeout", mgs_set_cache_timeout, |
---|
120 | NULL, |
---|
121 | RSRC_CONF, |
---|
122 | "Cache Timeout"), |
---|
123 | AP_INIT_TAKE12("GnuTLSCache", mgs_set_cache, |
---|
124 | NULL, |
---|
125 | RSRC_CONF, |
---|
126 | "Cache Configuration"), |
---|
127 | AP_INIT_TAKE1("GnuTLSSessionTickets", mgs_set_tickets, |
---|
128 | NULL, |
---|
129 | RSRC_CONF, |
---|
130 | "Session Tickets Configuration"), |
---|
131 | AP_INIT_RAW_ARGS("GnuTLSPriorities", mgs_set_priorities, |
---|
132 | NULL, |
---|
133 | RSRC_CONF, |
---|
134 | "The priorities to enable (ciphers, Key exchange, macs, compression)."), |
---|
135 | AP_INIT_TAKE1("GnuTLSEnable", mgs_set_enabled, |
---|
136 | NULL, |
---|
137 | RSRC_CONF, |
---|
138 | "Whether this server has GnuTLS Enabled. Default: Off"), |
---|
139 | AP_INIT_TAKE1("GnuTLSExportCertificates", |
---|
140 | mgs_set_export_certificates_enabled, |
---|
141 | NULL, |
---|
142 | RSRC_CONF, |
---|
143 | "Whether to export PEM encoded certificates to CGIs. Default: Off"), |
---|
144 | { NULL } |
---|
145 | }; |
---|
146 | |
---|
147 | module AP_MODULE_DECLARE_DATA gnutls_module = { |
---|
148 | STANDARD20_MODULE_STUFF, |
---|
149 | mgs_config_dir_create, |
---|
150 | mgs_config_dir_merge, |
---|
151 | mgs_config_server_create, |
---|
152 | NULL, |
---|
153 | mgs_config_cmds, |
---|
154 | gnutls_hooks |
---|
155 | }; |
---|