source: mod_gnutls/include/mod_gnutls.h.in @ 7d1ab49

debian/masterdebian/stretch-backportsjessie-backportsmsvaupstream
Last change on this file since 7d1ab49 was 7d1ab49, checked in by Daniel Kahn Gillmor <dkg@…>, 7 years ago

restore GnuTLSExportCertificate directive

It looks to me like this option was mistakenly removed when the the
RSA-EXPORT configuration parameters were ripped out, possibly due to
confusion over the term Export.

GnuTLSExportCertificate is a useful configuration directive, and some
users might be relying on it.

  • Property mode set to 100644
File size: 12.1 KB
Line 
1/**
2 *  Copyright 2004-2005 Paul Querna
3 *
4 *  Licensed under the Apache License, Version 2.0 (the "License");
5 *  you may not use this file except in compliance with the License.
6 *  You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 *  Unless required by applicable law or agreed to in writing, software
11 *  distributed under the License is distributed on an "AS IS" BASIS,
12 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 *  See the License for the specific language governing permissions and
14 *  limitations under the License.
15 *
16 */
17
18/* Apache Runtime Headers */
19#include "httpd.h"
20#include "http_config.h"
21#include "http_protocol.h"
22#include "http_connection.h"
23#include "http_request.h"
24#include "http_core.h"
25#include "http_log.h"
26#include "apr_buckets.h"
27#include "apr_strings.h"
28#include "apr_tables.h"
29#include "ap_release.h"
30#include "apr_fnmatch.h"
31/* GnuTLS Library Headers */
32#include <gnutls/gnutls.h>
33#if GNUTLS_VERSION_MAJOR == 2
34#include <gnutls/extra.h>
35#endif
36#include <gnutls/openpgp.h>
37#include <gnutls/x509.h>
38
39#ifndef __mod_gnutls_h_inc
40#define __mod_gnutls_h_inc
41
42#define HAVE_APR_MEMCACHE    @have_apr_memcache@
43
44extern module AP_MODULE_DECLARE_DATA gnutls_module;
45
46/* IO Filter names */
47#define GNUTLS_OUTPUT_FILTER_NAME "gnutls_output_filter"
48#define GNUTLS_INPUT_FILTER_NAME "gnutls_input_filter"
49/* GnuTLS Constants */
50#define GNUTLS_ENABLED_FALSE 0
51#define GNUTLS_ENABLED_TRUE  1
52#define GNUTLS_ENABLED_UNSET  2
53/* Current module version */
54#define MOD_GNUTLS_VERSION "@MOD_GNUTLS_VERSION@"
55
56/* Module Debug Mode */
57#define MOD_GNUTLS_DEBUG @OOO_MAINTAIN@
58
59/*
60 * Recent Versions of 2.1 renamed several hooks.
61 * This allows us to compile on 2.0.xx 
62 */
63#if AP_SERVER_MINORVERSION_NUMBER >= 2 || (AP_SERVER_MINORVERSION_NUMBER == 1 && AP_SERVER_PATCHLEVEL_NUMBER >= 3)
64        #define USING_2_1_RECENT 1
65#else
66        #define USING_2_1_RECENT 0
67#endif
68
69/* mod_gnutls Cache Types */
70typedef enum {
71        /* No Cache */
72    mgs_cache_none,
73        /* Use Old Berkley DB */
74    mgs_cache_dbm,
75        /* Use Gnu's version of Berkley DB */
76    mgs_cache_gdbm,
77#if HAVE_APR_MEMCACHE
78        /* Use Memcache */
79    mgs_cache_memcache,
80#endif
81    mgs_cache_unset
82} mgs_cache_e;
83
84/* Directory Configuration Record */
85typedef struct {
86    int client_verify_mode;
87    const char* lua_bytecode;
88    apr_size_t lua_bytecode_len;
89} mgs_dirconf_rec;
90
91
92/* The maximum number of certificates to send in a chain */
93#define MAX_CHAIN_SIZE 8
94/* The maximum number of SANs to read from a x509 certificate */
95#define MAX_CERT_SAN 5
96
97/* Server Configuration Record */
98typedef struct {
99        /* x509 Certificate Structure */
100    gnutls_certificate_credentials_t certs;
101        /* SRP Certificate Structure*/
102    gnutls_srp_server_credentials_t srp_creds;
103        /* Annonymous Certificate Structure */
104    gnutls_anon_server_credentials_t anon_creds;
105        /* Current x509 Certificate CN [Common Name] */
106    char* cert_cn;
107        /* Current x509 Certificate SAN [Subject Alternate Name]s*/
108        char* cert_san[MAX_CERT_SAN];
109        /* A x509 Certificate Chain */
110    gnutls_x509_crt_t *certs_x509_chain;
111        /* Current x509 Certificate Private Key */
112    gnutls_x509_privkey_t privkey_x509;
113        /* OpenPGP Certificate */
114    gnutls_openpgp_crt_t cert_pgp;
115        /* OpenPGP Certificate Private Key */
116    gnutls_openpgp_privkey_t privkey_pgp;
117        /* Number of Certificates in Chain */
118    unsigned int certs_x509_chain_num;
119        /* Is the module enabled? */
120    int enabled;
121    /* Export full certificates to CGI environment: */
122    int export_certificates_enabled;
123        /* GnuTLS Priorities */
124    gnutls_priority_t priorities;
125        /* GnuTLS DH Parameters */
126    gnutls_dh_params_t dh_params;
127        /* Cache timeout value */
128    int cache_timeout;
129        /* Chose Cache Type */
130    mgs_cache_e cache_type;
131    const char* cache_config;
132    const char* srp_tpasswd_file;
133    const char* srp_tpasswd_conf_file;
134        /* A list of CA Certificates */
135    gnutls_x509_crt_t *ca_list;
136        /* OpenPGP Key Ring */
137    gnutls_openpgp_keyring_t pgp_list;
138        /* CA Certificate list size */
139    unsigned int ca_list_size;
140        /* Client Certificate Verification Mode */
141    int client_verify_mode;
142        /* Last Cache timestamp */
143    apr_time_t last_cache_check;
144        /* GnuTLS uses Session Tickets */
145    int tickets;
146        /* Is mod_proxy enabled? */
147    int proxy_enabled;
148        /* A Plain HTTP request */
149    int non_ssl_request;
150} mgs_srvconf_rec;
151
152/* Character Buffer */
153typedef struct {
154    int length;
155    char *value;
156} mgs_char_buffer_t;
157
158/* GnuTLS Handle */
159typedef struct {
160        /* Server configuration record */
161    mgs_srvconf_rec *sc;
162        /* Connection record */
163    conn_rec* c;
164        /* GnuTLS Session handle */
165    gnutls_session_t session;
166        /* module input status */
167    apr_status_t input_rc;
168        /* Input filter */
169    ap_filter_t *input_filter;
170        /* Input Bucket Brigade */
171    apr_bucket_brigade *input_bb;
172        /* Input Read Type */
173    apr_read_type_e input_block;
174        /* Input Mode */
175    ap_input_mode_t input_mode;
176        /* Input Character Buffer */
177    mgs_char_buffer_t input_cbuf;
178        /* Input Character Array */
179    char input_buffer[AP_IOBUFSIZE];
180        /* module Output status */
181    apr_status_t output_rc;
182        /* Output filter */
183    ap_filter_t *output_filter;
184        /* Output Bucket Brigade */
185    apr_bucket_brigade *output_bb;
186        /* Output character array */
187    char output_buffer[AP_IOBUFSIZE];
188        /* Output buffer length */
189    apr_size_t output_blen;
190        /* Output length */
191    apr_size_t output_length;
192        /* General Status */
193    int status;
194} mgs_handle_t;
195
196
197
198/** Functions in gnutls_io.c **/
199
200/* apr_signal_block() for blocking SIGPIPE */
201apr_status_t apr_signal_block(int signum);
202
203 /* Proxy Support */
204/* An optional function which returns non-zero if the given connection
205is using SSL/TLS. */
206APR_DECLARE_OPTIONAL_FN(int, ssl_is_https, (conn_rec *));
207/* The ssl_proxy_enable() and ssl_engine_disable() optional functions
208 * are used by mod_proxy to enable use of SSL for outgoing
209 * connections. */
210APR_DECLARE_OPTIONAL_FN(int, ssl_proxy_enable, (conn_rec *));
211APR_DECLARE_OPTIONAL_FN(int, ssl_engine_disable, (conn_rec *));
212int ssl_is_https(conn_rec *c);
213int ssl_proxy_enable(conn_rec *c);
214int ssl_engine_disable(conn_rec *c);
215const char *mgs_set_proxy_engine(cmd_parms * parms, void *dummy,
216    const char *arg);
217apr_status_t mgs_cleanup_pre_config(void *data);
218
219/**
220 * mgs_filter_input will filter the input data
221 * by decrypting it using GnuTLS and passes it cleartext.
222 *
223 * @param f     the filter info record
224 * @param bb    the bucket brigade, where to store the result to
225 * @param mode  what shall we read?
226 * @param block a block index we shall read from?
227 * @return result status
228 */
229apr_status_t mgs_filter_input(ap_filter_t * f,
230                                     apr_bucket_brigade * bb,
231                                     ap_input_mode_t mode,
232                                     apr_read_type_e block,
233                                     apr_off_t readbytes);
234
235/**
236 * mgs_filter_output will filter the encrypt
237 * the incoming bucket using GnuTLS and passes it onto the next filter.
238 *
239 * @param f     the filter info record
240 * @param bb    the bucket brigade, where to store the result to
241 * @return result status
242 */
243apr_status_t mgs_filter_output(ap_filter_t * f,
244                                      apr_bucket_brigade * bb);
245
246
247/**
248 * mgs_transport_read is called from GnuTLS to provide encrypted
249 * data from the client.
250 *
251 * @param ptr     pointer to the filter context
252 * @param buffer  place to put data
253 * @param len     maximum size
254 * @return size   length of the data stored in buffer
255 */
256ssize_t mgs_transport_read(gnutls_transport_ptr_t ptr,
257                                  void *buffer, size_t len);
258
259/**
260 * mgs_transport_write is called from GnuTLS to
261 * write data to the client.
262 *
263 * @param ptr     pointer to the filter context
264 * @param buffer  buffer to write to the client
265 * @param len     size of the buffer
266 * @return size   length of the data written
267 */
268ssize_t mgs_transport_write(gnutls_transport_ptr_t ptr,
269                                   const void *buffer, size_t len);
270
271
272int mgs_rehandshake(mgs_handle_t * ctxt);
273
274
275
276/**
277 * Init the Cache after Configuration is done
278 */
279int mgs_cache_post_config(apr_pool_t *p, server_rec *s,
280                                 mgs_srvconf_rec *sc);
281/**
282 * Init the Cache inside each Process
283 */
284int mgs_cache_child_init(apr_pool_t *p, server_rec *s,
285                                mgs_srvconf_rec *sc);
286/**
287 * Setup the Session Caching
288 */
289int mgs_cache_session_init(mgs_handle_t *ctxt);
290
291#define GNUTLS_SESSION_ID_STRING_LEN \
292    ((GNUTLS_MAX_SESSION_ID + 1) * 2)
293   
294/**
295 * Convert a SSL Session ID into a Null Terminated Hex Encoded String
296 * @param id raw SSL Session ID
297 * @param idlen Length of the raw Session ID
298 * @param str Location to store the Hex Encoded String
299 * @param strsize The Maximum Length that can be stored in str
300 */
301char *mgs_session_id2sz(unsigned char *id, int idlen,
302                                char *str, int strsize);
303
304/**
305 * Convert a time_t into a Null Terminated String
306 * @param t time_t time
307 * @param str Location to store the Hex Encoded String
308 * @param strsize The Maximum Length that can be stored in str
309 */
310char *mgs_time2sz(time_t t, char *str, int strsize);
311
312
313/* Configuration Functions */
314
315const char *mgs_set_srp_tpasswd_conf_file(cmd_parms * parms, void *dummy,
316                                        const char *arg);
317const char *mgs_set_srp_tpasswd_file(cmd_parms * parms, void *dummy,
318                                        const char *arg);
319const char *mgs_set_dh_file(cmd_parms * parms, void *dummy,
320                                        const char *arg);
321const char *mgs_set_cert_file(cmd_parms * parms, void *dummy,
322                                        const char *arg);
323
324const char *mgs_set_key_file(cmd_parms * parms, void *dummy,
325                             const char *arg);
326
327const char *mgs_set_pgpcert_file(cmd_parms * parms, void *dummy,
328                                        const char *arg);
329
330const char *mgs_set_pgpkey_file(cmd_parms * parms, void *dummy,
331                             const char *arg);
332
333const char *mgs_set_cache(cmd_parms * parms, void *dummy,
334                          const char *type, const char* arg);
335
336const char *mgs_set_cache_timeout(cmd_parms * parms, void *dummy,
337                                  const char *arg);
338
339const char *mgs_set_client_verify(cmd_parms * parms, void *dummy,
340                                  const char *arg);
341
342const char *mgs_set_client_ca_file(cmd_parms * parms, void *dummy,
343                                   const char *arg);
344
345const char *mgs_set_keyring_file(cmd_parms * parms, void *dummy,
346                                   const char *arg);
347
348const char *mgs_set_enabled(cmd_parms * parms, void *dummy,
349                            const char *arg);
350const char *mgs_set_export_certificates_enabled(cmd_parms * parms, void *dummy,
351                            const char *arg);
352const char *mgs_set_priorities(cmd_parms * parms, void *dummy,
353                            const char *arg);
354const char *mgs_set_tickets(cmd_parms * parms, void *dummy,
355                            const char *arg);
356                           
357const char *mgs_set_require_section(cmd_parms *cmd,
358                                    void *mconfig, const char *arg);
359void *mgs_config_server_create(apr_pool_t * p, server_rec * s);
360void *mgs_config_server_merge(apr_pool_t *p, void *BASE, void *ADD);
361
362void *mgs_config_dir_merge(apr_pool_t *p, void *basev, void *addv);
363
364void *mgs_config_dir_create(apr_pool_t *p, char *dir);
365
366const char *mgs_set_require_bytecode(cmd_parms *cmd,
367                                    void *mconfig, const char *arg);
368
369mgs_srvconf_rec* mgs_find_sni_server(gnutls_session_t session);
370
371/* mod_gnutls Hooks. */
372
373int mgs_hook_pre_config(apr_pool_t * pconf,
374                        apr_pool_t * plog, apr_pool_t * ptemp);
375
376int mgs_hook_post_config(apr_pool_t * p, apr_pool_t * plog,
377                         apr_pool_t * ptemp,
378                         server_rec * base_server);
379
380void mgs_hook_child_init(apr_pool_t *p, server_rec *s);
381
382const char *mgs_hook_http_scheme(const request_rec * r);
383
384apr_port_t mgs_hook_default_port(const request_rec * r);
385
386int mgs_hook_pre_connection(conn_rec * c, void *csd);
387
388int mgs_hook_fixups(request_rec *r);
389
390int mgs_hook_authz(request_rec *r);
391
392#endif /*  __mod_gnutls_h_inc */
Note: See TracBrowser for help on using the repository browser.