]> granicus.if.org Git - apache/blob - modules/ssl/mod_ssl.h
Add the openssl/include/openssl directory to the INCLUDES variable.
[apache] / modules / ssl / mod_ssl.h
1 /*                      _             _
2 **  _ __ ___   ___   __| |    ___ ___| |  mod_ssl
3 ** | '_ ` _ \ / _ \ / _` |   / __/ __| |  Apache Interface to OpenSSL
4 ** | | | | | | (_) | (_| |   \__ \__ \ |  www.modssl.org
5 ** |_| |_| |_|\___/ \__,_|___|___/___/_|  ftp.modssl.org
6 **                      |_____|
7 **  mod_ssl.h
8 **  Global header
9 */
10
11 /* ====================================================================
12  * The Apache Software License, Version 1.1
13  *
14  * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
15  * reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions
19  * are met:
20  *
21  * 1. Redistributions of source code must retain the above copyright
22  *    notice, this list of conditions and the following disclaimer.
23  *
24  * 2. Redistributions in binary form must reproduce the above copyright
25  *    notice, this list of conditions and the following disclaimer in
26  *    the documentation and/or other materials provided with the
27  *    distribution.
28  *
29  * 3. The end-user documentation included with the redistribution,
30  *    if any, must include the following acknowledgment:
31  *       "This product includes software developed by the
32  *        Apache Software Foundation (http://www.apache.org/)."
33  *    Alternately, this acknowledgment may appear in the software itself,
34  *    if and wherever such third-party acknowledgments normally appear.
35  *
36  * 4. The names "Apache" and "Apache Software Foundation" must
37  *    not be used to endorse or promote products derived from this
38  *    software without prior written permission. For written
39  *    permission, please contact apache@apache.org.
40  *
41  * 5. Products derived from this software may not be called "Apache",
42  *    nor may "Apache" appear in their name, without prior written
43  *    permission of the Apache Software Foundation.
44  *
45  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
46  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
47  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
48  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
49  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
50  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
51  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
52  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
53  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
54  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
55  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56  * SUCH DAMAGE.
57  * ====================================================================
58  */
59                              /* ``The Apache Group: a collection
60                                   of talented individuals who are
61                                   trying to perfect the art of
62                                   never finishing something.''
63                                              -- Rob Hartill         */
64 #ifndef __MOD_SSL_H__
65 #define __MOD_SSL_H__
66
67 #define MOD_SSL_VERSION "3.0a0"
68
69 /* 
70  * Optionally enable the experimental stuff, but allow the user to
71  * override the decision which experimental parts are included by using
72  * CFLAGS="-DSSL_EXPERIMENTAL_xxxx_IGNORE".
73  */
74 #ifdef SSL_EXPERIMENTAL
75 #ifndef SSL_EXPERIMENTAL_PERDIRCA_IGNORE
76 #define SSL_EXPERIMENTAL_PERDIRCA
77 #endif
78 #ifndef SSL_EXPERIMENTAL_PROXY_IGNORE
79 #define SSL_EXPERIMENTAL_PROXY
80 #endif
81 #ifdef SSL_ENGINE
82 #ifndef SSL_EXPERIMENTAL_ENGINE_IGNORE
83 #define SSL_EXPERIMENTAL_ENGINE
84 #endif
85 #endif
86 #endif /* SSL_EXPERIMENTAL */
87
88 /*
89  * Power up our brain...
90  */
91
92 /* OS headers */
93 #include <stdio.h>
94 #include <stdlib.h>
95 #include <stdarg.h>
96 #include <errno.h>
97 #include <sys/types.h>
98 #include <sys/stat.h>
99 #include <time.h>
100 #if APR_HAVE_SYS_TIME_H
101 #include <sys/time.h>
102 #endif
103 /* XXX: these better go away */
104 #include <assert.h>
105
106 /* OpenSSL headers */
107 #include <ssl.h>
108 #include <err.h>
109 #include <x509.h>
110 #include <x509v3.h>
111 #include <pem.h>
112 #include <crypto.h>
113 #include <evp.h>
114 #include <rand.h>
115 #ifdef SSL_EXPERIMENTAL_ENGINE
116 #include <engine.h>
117 #endif
118
119 /* Apache headers */
120 #define CORE_PRIVATE
121 #include "httpd.h"
122 #include "http_config.h"
123 #include "http_core.h"
124 #include "http_log.h"
125 #include "http_main.h"
126 #include "http_connection.h"
127 #include "http_request.h"
128 #include "http_protocol.h"
129 #include "util_script.h"
130 #include "util_filter.h"
131 #include "mpm.h"
132 #include "apr_strings.h"
133 #include "apr_tables.h"
134 #include "apr_lib.h"
135 #include "apr_fnmatch.h"
136 #include "apr_strings.h"
137 #include "apr_dbm.h"
138 #undef CORE_PRIVATE
139
140 /* mod_ssl headers */
141 #include "ssl_expr.h"
142 #include "ssl_util_ssl.h"
143 #include "ssl_util_table.h"
144
145 /*
146  * Provide reasonable default for some defines
147  */
148 #ifndef FALSE
149 #define FALSE (0)
150 #endif
151 #ifndef TRUE
152 #define TRUE (!FALSE)
153 #endif
154 #ifndef PFALSE
155 #define PFALSE ((void *)FALSE)
156 #endif
157 #ifndef PTRUE
158 #define PTRUE ((void *)TRUE)
159 #endif
160 #ifndef UNSET
161 #define UNSET (-1)
162 #endif
163 #ifndef NUL
164 #define NUL '\0'
165 #endif
166 #ifndef RAND_MAX
167 #include <limits.h>
168 #define RAND_MAX INT_MAX
169 #endif
170
171 /*
172  * Provide reasonable defines for some types
173  */
174 #ifndef BOOL
175 #define BOOL unsigned int
176 #endif
177 #ifndef UCHAR
178 #define UCHAR unsigned char
179 #endif
180
181 /*
182  * Provide useful shorthands
183  */
184 #define strEQ(s1,s2)     (strcmp(s1,s2)        == 0)
185 #define strNE(s1,s2)     (strcmp(s1,s2)        != 0)
186 #define strEQn(s1,s2,n)  (strncmp(s1,s2,n)     == 0)
187 #define strNEn(s1,s2,n)  (strncmp(s1,s2,n)     != 0)
188
189 #define strcEQ(s1,s2)    (strcasecmp(s1,s2)    == 0)
190 #define strcNE(s1,s2)    (strcasecmp(s1,s2)    != 0)
191 #define strcEQn(s1,s2,n) (strncasecmp(s1,s2,n) == 0)
192 #define strcNEn(s1,s2,n) (strncasecmp(s1,s2,n) != 0)
193
194 #define strIsEmpty(s)    (s == NULL || s[0] == NUL)
195
196 #define cfgMerge(el,unset)  new->el = add->el == unset ? base->el : add->el
197 #define cfgMergeArray(el)   new->el = apr_array_append(p, add->el, base->el)
198 #define cfgMergeTable(el)   new->el = apr_table_overlay(p, add->el, base->el)
199 #define cfgMergeCtx(el)     new->el = apr_table_overlay(p, add->el, base->el)
200 #define cfgMergeString(el)  cfgMerge(el, NULL)
201 #define cfgMergeBool(el)    cfgMerge(el, UNSET)
202 #define cfgMergeInt(el)     cfgMerge(el, UNSET)
203
204 #define myModConfig(srv) (SSLModConfigRec *)ssl_util_getmodconfig(srv, "ssl_module")
205 #define mySrvConfig(srv) (SSLSrvConfigRec *)ap_get_module_config(srv->module_config,  &ssl_module)
206 #define myDirConfig(req) (SSLDirConfigRec *)ap_get_module_config(req->per_dir_config, &ssl_module)
207
208 #define myCtxVarSet(mc,num,val)  mc->rCtx.pV##num = val
209 #define myCtxVarGet(mc,num,type) (type)(mc->rCtx.pV##num)
210
211 #define AP_CTX_NUM2PTR(n) (void *)(((unsigned long)(n))+1)
212 #define AP_CTX_PTR2NUM(p) (unsigned long)(((char *)(p))-1)
213
214 #define AP_CTX_MAX_ENTRIES 1024
215
216 /*
217  * SSL Logging
218  */
219 #define SSL_LOG_NONE    (1<<0)
220 #define SSL_LOG_ERROR   (1<<1)
221 #define SSL_LOG_WARN    (1<<2)
222 #define SSL_LOG_INFO    (1<<3)
223 #define SSL_LOG_TRACE   (1<<4)
224 #define SSL_LOG_DEBUG   (1<<5)
225 #define SSL_LOG_MASK    (SSL_LOG_ERROR|SSL_LOG_WARN|SSL_LOG_INFO|SSL_LOG_TRACE|SSL_LOG_DEBUG)
226
227 #define SSL_ADD_NONE     (1<<8)
228 #define SSL_ADD_ERRNO    (1<<9)
229 #define SSL_ADD_SSLERR   (1<<10)
230 #define SSL_NO_TIMESTAMP (1<<11)
231 #define SSL_NO_LEVELID   (1<<12)
232 #define SSL_NO_NEWLINE   (1<<13)
233
234 /*
235  * Defaults for the configuration
236  */
237 #ifndef SSL_SESSION_CACHE_TIMEOUT
238 #define SSL_SESSION_CACHE_TIMEOUT  300
239 #endif
240
241 /*
242  * Support for MM library
243  */
244 #define SSL_MM_FILE_MODE ( APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD )
245
246 /*
247  * Support for DBM library
248  */
249 #define SSL_DBM_FILE_MODE ( APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD )
250
251 #if !defined(SSL_DBM_FILE_SUFFIX_DIR) && !defined(SSL_DBM_FILE_SUFFIX_PAG)
252 #if defined(DBM_SUFFIX)
253 #define SSL_DBM_FILE_SUFFIX_DIR DBM_SUFFIX
254 #define SSL_DBM_FILE_SUFFIX_PAG DBM_SUFFIX
255 #elif defined(__FreeBSD__) || (defined(DB_LOCK) && defined(DB_SHMEM))
256 #define SSL_DBM_FILE_SUFFIX_DIR ".db"
257 #define SSL_DBM_FILE_SUFFIX_PAG ".db"
258 #else
259 #define SSL_DBM_FILE_SUFFIX_DIR ".dir"
260 #define SSL_DBM_FILE_SUFFIX_PAG ".pag"
261 #endif
262 #endif
263
264 /*
265  * Check for OpenSSL version 
266  */
267 #if SSL_LIBRARY_VERSION < 0x00903100
268 #error "mod_ssl requires OpenSSL 0.9.3 or higher"
269 #endif
270
271 /*
272  * The own data structures
273  */
274 typedef struct {
275     apr_pool_t *pPool;
276     apr_pool_t *pSubPool;
277     apr_array_header_t *aData;
278 } ssl_ds_array;
279
280 typedef struct {
281     apr_pool_t *pPool;
282     apr_pool_t *pSubPool;
283     apr_array_header_t *aKey;
284     apr_array_header_t *aData;
285 } ssl_ds_table;
286
287 /*
288  * Define the certificate algorithm types
289  */
290
291 typedef int ssl_algo_t;
292
293 #define SSL_ALGO_UNKNOWN (0)
294 #define SSL_ALGO_RSA     (1<<0)
295 #define SSL_ALGO_DSA     (1<<1)
296 #define SSL_ALGO_ALL     (SSL_ALGO_RSA|SSL_ALGO_DSA)
297
298 #define SSL_AIDX_RSA     (0)
299 #define SSL_AIDX_DSA     (1)
300 #define SSL_AIDX_MAX     (2)
301
302
303 /*
304  * Define IDs for the temporary RSA keys and DH params
305  */
306
307 #define SSL_TKP_GEN        (0)
308 #define SSL_TKP_ALLOC      (1)
309 #define SSL_TKP_FREE       (2)
310
311 #define SSL_TKPIDX_RSA512  (0)
312 #define SSL_TKPIDX_RSA1024 (1)
313 #define SSL_TKPIDX_DH512   (2)
314 #define SSL_TKPIDX_DH1024  (3)
315 #define SSL_TKPIDX_MAX     (4)
316
317 /*
318  * Define the SSL options
319  */
320 #define SSL_OPT_NONE           (0)
321 #define SSL_OPT_RELSET         (1<<0)
322 #define SSL_OPT_STDENVVARS     (1<<1)
323 #define SSL_OPT_COMPATENVVARS  (1<<2)
324 #define SSL_OPT_EXPORTCERTDATA (1<<3)
325 #define SSL_OPT_FAKEBASICAUTH  (1<<4)
326 #define SSL_OPT_STRICTREQUIRE  (1<<5)
327 #define SSL_OPT_OPTRENEGOTIATE (1<<6)
328 #define SSL_OPT_ALL            (SSL_OPT_STDENVVARS|SSL_OPT_COMPATENVVAR|SSL_OPT_EXPORTCERTDATA|SSL_OPT_FAKEBASICAUTH|SSL_OPT_STRICTREQUIRE|SSL_OPT_OPTRENEGOTIATE)
329 typedef int ssl_opt_t;
330
331 /*
332  * Define the SSL Protocol options
333  */
334 #define SSL_PROTOCOL_NONE  (0)
335 #define SSL_PROTOCOL_SSLV2 (1<<0)
336 #define SSL_PROTOCOL_SSLV3 (1<<1)
337 #define SSL_PROTOCOL_TLSV1 (1<<2)
338 #define SSL_PROTOCOL_ALL   (SSL_PROTOCOL_SSLV2|SSL_PROTOCOL_SSLV3|SSL_PROTOCOL_TLSV1)
339 typedef int ssl_proto_t;
340
341 /*
342  * Define the SSL verify levels
343  */
344 typedef enum {
345     SSL_CVERIFY_UNSET           = UNSET,
346     SSL_CVERIFY_NONE            = 0,
347     SSL_CVERIFY_OPTIONAL        = 1,
348     SSL_CVERIFY_REQUIRE         = 2,
349     SSL_CVERIFY_OPTIONAL_NO_CA  = 3
350 } ssl_verify_t;
351
352 /*
353  * Define the SSL pass phrase dialog types
354  */
355 typedef enum {
356     SSL_PPTYPE_UNSET   = UNSET,
357     SSL_PPTYPE_BUILTIN = 0,
358     SSL_PPTYPE_FILTER  = 1
359 } ssl_pphrase_t;
360
361 /*
362  * Define the Path Checking modes
363  */
364 #define SSL_PCM_EXISTS     1
365 #define SSL_PCM_ISREG      2
366 #define SSL_PCM_ISDIR      4
367 #define SSL_PCM_ISNONZERO  8
368 typedef unsigned int ssl_pathcheck_t;
369
370 /*
371  * Define the SSL session cache modes and structures
372  */
373 typedef enum {
374     SSL_SCMODE_UNSET = UNSET,
375     SSL_SCMODE_NONE  = 0,
376     SSL_SCMODE_DBM   = 1,
377     SSL_SCMODE_SHMHT = 2,
378     SSL_SCMODE_SHMCB = 3
379 } ssl_scmode_t;
380
381 /*
382  * Define the SSL mutex modes
383  */
384 typedef enum {
385     SSL_MUTEXMODE_UNSET  = UNSET,
386     SSL_MUTEXMODE_NONE   = 0,
387     SSL_MUTEXMODE_USED   = 1
388 } ssl_mutexmode_t;
389
390 /*
391  * Define the SSL requirement structure
392  */
393 typedef struct {
394     char     *cpExpr;
395     ssl_expr *mpExpr;
396 } ssl_require_t;
397
398 /*
399  * Define the SSL random number generator seeding source
400  */
401 typedef enum {
402     SSL_RSCTX_STARTUP = 1,
403     SSL_RSCTX_CONNECT = 2
404 } ssl_rsctx_t;
405 typedef enum {
406     SSL_RSSRC_BUILTIN = 1,
407     SSL_RSSRC_FILE    = 2,
408     SSL_RSSRC_EXEC    = 3
409 #if SSL_LIBRARY_VERSION >= 0x00905100
410    ,SSL_RSSRC_EGD     = 4
411 #endif
412 } ssl_rssrc_t;
413 typedef struct {
414     ssl_rsctx_t  nCtx;
415     ssl_rssrc_t  nSrc;
416     char        *cpPath;
417     int          nBytes;
418 } ssl_randseed_t;
419
420 /*
421  * Define the structure of an ASN.1 anything
422  */
423 typedef struct {
424     long int       nData;
425     unsigned char *cpData;
426 } ssl_asn1_t;
427
428 /*
429  * Define the mod_ssl per-module configuration structure
430  * (i.e. the global configuration for each httpd process)
431  */
432
433 typedef struct {
434     SSL                *pssl;
435     BIO                *pbioRead;
436     BIO                *pbioWrite;
437     ap_filter_t        *pInputFilter;
438     ap_filter_t        *pOutputFilter;
439     apr_bucket_brigade *pbbInput;        /* encrypted input */
440     apr_bucket_brigade *pbbPendingInput; /* decrypted input */
441 } SSLFilterRec;
442
443 typedef struct {
444     apr_pool_t     *pPool;
445     BOOL            bFixed;
446     int             nInitCount;
447     int             nSessionCacheMode;
448     char           *szSessionCacheDataFile;
449     int             nSessionCacheDataSize;
450 #if 0 /* XXX */
451     AP_MM          *pSessionCacheDataMM;
452 #endif
453     apr_table_t    *tSessionCacheDataTable;
454     ssl_mutexmode_t nMutexMode;
455     char           *szMutexFile;
456     apr_lock_t     *pMutex;
457     apr_array_header_t   *aRandSeed;
458     ssl_ds_table   *tTmpKeys;
459     void           *pTmpKeys[SSL_TKPIDX_MAX];
460     ssl_ds_table   *tPublicCert;
461     ssl_ds_table   *tPrivateKey;
462 #ifdef SSL_EXPERIMENTAL_ENGINE
463     char           *szCryptoDevice;
464 #endif
465     struct {
466         void *pV1, *pV2, *pV3, *pV4, *pV5, *pV6, *pV7, *pV8, *pV9, *pV10;
467     } rCtx;
468 } SSLModConfigRec;
469
470 /*
471  * Define the mod_ssl per-server configuration structure
472  * (i.e. the configuration for the main server
473  *  and all <VirtualHost> contexts)
474  */
475 typedef struct {
476     BOOL         bEnabled;
477     apr_table_t *ap_server_ctx;
478     char        *szPublicCertFile[SSL_AIDX_MAX];
479     char        *szPrivateKeyFile[SSL_AIDX_MAX];
480     char        *szCertificateChain;
481     char        *szCACertificatePath;
482     char        *szCACertificateFile;
483     char        *szLogFile;
484     char        *szCipherSuite;
485     apr_file_t  *fileLogFile;
486     int          nLogLevel;
487     int          nVerifyDepth;
488     ssl_verify_t nVerifyClient;
489     X509        *pPublicCert[SSL_AIDX_MAX];
490     EVP_PKEY    *pPrivateKey[SSL_AIDX_MAX];
491     SSL_CTX     *pSSLCtx;
492     int          nSessionCacheTimeout;
493     int          nPassPhraseDialogType;
494     char        *szPassPhraseDialogPath;
495     ssl_proto_t  nProtocol;
496     char        *szCARevocationPath;
497     char        *szCARevocationFile;
498     X509_STORE  *pRevocationStore;
499 #ifdef SSL_EXPERIMENTAL_PROXY
500     /* Configuration details for proxy operation */
501     ssl_proto_t  nProxyProtocol;
502     int          bProxyVerify;
503     int          nProxyVerifyDepth;
504     char        *szProxyCACertificatePath;
505     char        *szProxyCACertificateFile;
506     char        *szProxyClientCertificateFile;
507     char        *szProxyClientCertificatePath;
508     char        *szProxyCipherSuite;
509     SSL_CTX     *pSSLProxyCtx;
510     STACK_OF(X509_INFO) *skProxyClientCerts;
511 #endif
512 } SSLSrvConfigRec;
513
514 /*
515  * Define the mod_ssl per-directory configuration structure
516  * (i.e. the local configuration for all <Directory>
517  *  and .htaccess contexts)
518  */
519 typedef struct {
520     BOOL          bSSLRequired;
521     apr_array_header_t *aRequirement;
522     ssl_opt_t     nOptions;
523     ssl_opt_t     nOptionsAdd;
524     ssl_opt_t     nOptionsDel;
525     char         *szCipherSuite;
526     ssl_verify_t  nVerifyClient;
527     int           nVerifyDepth;
528 #ifdef SSL_EXPERIMENTAL_PERDIRCA
529     char         *szCACertificatePath;
530     char         *szCACertificateFile;
531 #endif
532 } SSLDirConfigRec;
533
534 /*
535  *  function prototypes
536  */
537
538 /*  API glue structures  */
539 extern module AP_MODULE_DECLARE_DATA ssl_module;
540
541 /*  configuration handling   */
542 void         ssl_config_global_create(server_rec *);
543 void         ssl_config_global_fix(SSLModConfigRec *);
544 BOOL         ssl_config_global_isfixed(SSLModConfigRec *);
545 void        *ssl_config_server_create(apr_pool_t *, server_rec *);
546 void        *ssl_config_server_merge(apr_pool_t *, void *, void *);
547 void        *ssl_config_perdir_create(apr_pool_t *, char *);
548 void        *ssl_config_perdir_merge(apr_pool_t *, void *, void *);
549 const char  *ssl_cmd_SSLMutex(cmd_parms *, void *, const char *);
550 const char  *ssl_cmd_SSLPassPhraseDialog(cmd_parms *, void *, const char *);
551 const char  *ssl_cmd_SSLCryptoDevice(cmd_parms *, void *, const char *);
552 const char  *ssl_cmd_SSLRandomSeed(cmd_parms *, void *, const char *, const char *, const char *);
553 const char  *ssl_cmd_SSLEngine(cmd_parms *, void *, int);
554 const char  *ssl_cmd_SSLCipherSuite(cmd_parms *, void *, const char *);
555 const char  *ssl_cmd_SSLCertificateFile(cmd_parms *, void *, const char *);
556 const char  *ssl_cmd_SSLCertificateKeyFile(cmd_parms *, void *, const char *);
557 const char  *ssl_cmd_SSLCertificateChainFile(cmd_parms *, void *, const char *);
558 const char  *ssl_cmd_SSLCACertificatePath(cmd_parms *, void *, const char *);
559 const char  *ssl_cmd_SSLCACertificateFile(cmd_parms *, void *, const char *);
560 const char  *ssl_cmd_SSLCARevocationPath(cmd_parms *, void *, const char *);
561 const char  *ssl_cmd_SSLCARevocationFile(cmd_parms *, void *, const char *);
562 const char  *ssl_cmd_SSLVerifyClient(cmd_parms *, void *, const char *);
563 const char  *ssl_cmd_SSLVerifyDepth(cmd_parms *, void *, const char *);
564 const char  *ssl_cmd_SSLSessionCache(cmd_parms *, void *, const char *);
565 const char  *ssl_cmd_SSLSessionCacheTimeout(cmd_parms *, void *, const char *);
566 const char  *ssl_cmd_SSLLog(cmd_parms *, void *, const char *);
567 const char  *ssl_cmd_SSLLogLevel(cmd_parms *, void *, const char *);
568 const char  *ssl_cmd_SSLProtocol(cmd_parms *, void *, const char *);
569 const char  *ssl_cmd_SSLOptions(cmd_parms *, void *, const char *);
570 const char  *ssl_cmd_SSLRequireSSL(cmd_parms *, void *);
571 const char  *ssl_cmd_SSLRequire(cmd_parms *, void *, const char *);
572 #ifdef SSL_EXPERIMENTAL_PROXY
573 const char  *ssl_cmd_SSLProxyProtocol(cmd_parms *, char *, const char *);
574 const char  *ssl_cmd_SSLProxyCipherSuite(cmd_parms *, char *, char *);
575 const char  *ssl_cmd_SSLProxyVerify(cmd_parms *, char *, int);
576 const char  *ssl_cmd_SSLProxyVerifyDepth(cmd_parms *, char *, char *);
577 const char  *ssl_cmd_SSLProxyCACertificatePath(cmd_parms *, char *, char *);
578 const char  *ssl_cmd_SSLProxyCACertificateFile(cmd_parms *, char *, char *);
579 const char  *ssl_cmd_SSLProxyMachineCertificatePath(cmd_parms *, char *, char *);
580 const char  *ssl_cmd_SSLProxyMachineCertificateFile(cmd_parms *, char *, char *);
581 #endif
582
583 /*  module initialization  */
584 void         ssl_init_Module(apr_pool_t *, apr_pool_t *, apr_pool_t *, server_rec *);
585 void         ssl_init_SSLLibrary(void);
586 void         ssl_init_Engine(server_rec *, apr_pool_t *);
587 void         ssl_init_TmpKeysHandle(int, server_rec *, apr_pool_t *);
588 void         ssl_init_ConfigureServer(server_rec *, apr_pool_t *, SSLSrvConfigRec *);
589 void         ssl_init_CheckServers(server_rec *, apr_pool_t *);
590 STACK_OF(X509_NAME) 
591             *ssl_init_FindCAList(server_rec *, apr_pool_t *, char *, char *);
592 void         ssl_init_Child(apr_pool_t *, server_rec *);
593 apr_status_t ssl_init_ChildKill(void *data);
594 apr_status_t ssl_init_ModuleKill(void *data);
595
596 /*  Apache API hooks  */
597 void         ssl_hook_NewConnection(conn_rec *);
598 void         ssl_hook_TimeoutConnection(int);
599 int          ssl_hook_process_connection(SSLFilterRec *pRec);
600 apr_status_t ssl_hook_CloseConnection(SSLFilterRec *);
601 int          ssl_hook_Translate(request_rec *);
602 int          ssl_hook_Auth(request_rec *);
603 int          ssl_hook_UserCheck(request_rec *);
604 int          ssl_hook_Access(request_rec *);
605 int          ssl_hook_Fixup(request_rec *);
606 int          ssl_hook_ReadReq(request_rec *);
607 int          ssl_hook_Handler(request_rec *);
608
609 /*  OpenSSL callbacks */
610 RSA         *ssl_callback_TmpRSA(SSL *, int, int);
611 DH          *ssl_callback_TmpDH(SSL *, int, int);
612 int          ssl_callback_SSLVerify(int, X509_STORE_CTX *);
613 int          ssl_callback_SSLVerify_CRL(int, X509_STORE_CTX *, server_rec *);
614 int          ssl_callback_NewSessionCacheEntry(SSL *, SSL_SESSION *);
615 SSL_SESSION *ssl_callback_GetSessionCacheEntry(SSL *, unsigned char *, int, int *);
616 void         ssl_callback_DelSessionCacheEntry(SSL_CTX *, SSL_SESSION *);
617 void         ssl_callback_LogTracingState(SSL *, int, int);
618
619 /*  Session Cache Support  */
620 void         ssl_scache_init(server_rec *, apr_pool_t *);
621 void         ssl_scache_kill(server_rec *);
622 BOOL         ssl_scache_store(server_rec *, UCHAR *, int, time_t, SSL_SESSION *);
623 SSL_SESSION *ssl_scache_retrieve(server_rec *, UCHAR *, int);
624 void         ssl_scache_remove(server_rec *, UCHAR *, int);
625 void         ssl_scache_expire(server_rec *);
626 void         ssl_scache_status(server_rec *, apr_pool_t *, void (*)(char *, void *), void *);
627 char        *ssl_scache_id2sz(UCHAR *, int);
628 void         ssl_scache_dbm_init(server_rec *, apr_pool_t *);
629 void         ssl_scache_dbm_kill(server_rec *);
630 BOOL         ssl_scache_dbm_store(server_rec *, UCHAR *, int, time_t, SSL_SESSION *);
631 SSL_SESSION *ssl_scache_dbm_retrieve(server_rec *, UCHAR *, int);
632 void         ssl_scache_dbm_remove(server_rec *, UCHAR *, int);
633 void         ssl_scache_dbm_expire(server_rec *);
634 void         ssl_scache_dbm_status(server_rec *, apr_pool_t *, void (*)(char *, void *), void *);
635 #if 0 /* XXX */
636 void         ssl_scache_shmht_init(server_rec *, pool *);
637 void         ssl_scache_shmht_kill(server_rec *);
638 BOOL         ssl_scache_shmht_store(server_rec *, UCHAR *, int, time_t, SSL_SESSION *);
639 SSL_SESSION *ssl_scache_shmht_retrieve(server_rec *, UCHAR *, int);
640 void         ssl_scache_shmht_remove(server_rec *, UCHAR *, int);
641 void         ssl_scache_shmht_expire(server_rec *);
642 void         ssl_scache_shmht_status(server_rec *, pool *, void (*)(char *, void *), void *);
643 void         ssl_scache_shmcb_init(server_rec *, pool *);
644 void         ssl_scache_shmcb_kill(server_rec *);
645 BOOL         ssl_scache_shmcb_store(server_rec *, UCHAR *, int, time_t, SSL_SESSION *);
646 SSL_SESSION *ssl_scache_shmcb_retrieve(server_rec *, UCHAR *, int);
647 void         ssl_scache_shmcb_remove(server_rec *, UCHAR *, int);
648 void         ssl_scache_shmcb_expire(server_rec *);
649 void         ssl_scache_shmcb_status(server_rec *, pool *, void (*)(char *, void *), void *);
650 #endif
651
652 /*  Pass Phrase Support  */
653 void         ssl_pphrase_Handle(server_rec *, apr_pool_t *);
654 int          ssl_pphrase_Handle_CB(char *, int, int, void *);
655
656 /*  Diffie-Hellman Parameter Support  */
657 DH           *ssl_dh_GetTmpParam(int);
658 DH           *ssl_dh_GetParamFromFile(char *);
659
660 /*  Data Structures */
661 ssl_ds_array *ssl_ds_array_make(apr_pool_t *, int);
662 BOOL          ssl_ds_array_isempty(ssl_ds_array *);
663 void         *ssl_ds_array_push(ssl_ds_array *);
664 void         *ssl_ds_array_get(ssl_ds_array *, int);
665 void          ssl_ds_array_wipeout(ssl_ds_array *);
666 void          ssl_ds_array_kill(ssl_ds_array *);
667 ssl_ds_table *ssl_ds_table_make(apr_pool_t *, int);
668 BOOL          ssl_ds_table_isempty(ssl_ds_table *);
669 void         *ssl_ds_table_push(ssl_ds_table *, char *);
670 void         *ssl_ds_table_get(ssl_ds_table *, char *);
671 void          ssl_ds_table_wipeout(ssl_ds_table *);
672 void          ssl_ds_table_kill(ssl_ds_table *);
673
674 /*  Mutex Support  */
675 int          ssl_mutex_init(server_rec *, apr_pool_t *);
676 int          ssl_mutex_reinit(server_rec *, apr_pool_t *);
677 int          ssl_mutex_on(server_rec *);
678 int          ssl_mutex_off(server_rec *);
679 int          ssl_mutex_kill(server_rec *);
680
681 /*  Logfile Support  */
682 void         ssl_log_open(server_rec *, server_rec *, apr_pool_t *);
683 BOOL         ssl_log_applies(server_rec *, int);
684 void         ssl_log(server_rec *, int, const char *, ...);
685 void         ssl_die(void);
686
687 /*  Variables  */
688 void         ssl_var_register(void);
689 #if 0 /* XXX */
690 void         ssl_var_unregister(void);
691 #endif /* XXX */
692 char        *ssl_var_lookup(apr_pool_t *, server_rec *, conn_rec *, request_rec *, char *);
693
694 /*  I/O  */
695 void         ssl_io_register(void);
696 void         ssl_io_unregister(void);
697 void         ssl_io_filter_init(conn_rec *, SSL *);
698 void         ssl_io_filter_register(apr_pool_t *);
699 long         ssl_io_data_cb(BIO *, int, const char *, int, long, long);
700
701 /*  PRNG  */
702 int          ssl_rand_seed(server_rec *, apr_pool_t *, ssl_rsctx_t, char *);
703
704 /*  Extensions  */
705 void         ssl_ext_register(apr_pool_t *p);
706 #if 0 /* XXX */
707 void         ssl_ext_unregister(void);
708 #endif
709
710 /*  Utility Functions  */
711 char        *ssl_util_vhostid(apr_pool_t *, server_rec *);
712 void         ssl_util_strupper(char *);
713 void         ssl_util_uuencode(char *, const char *, BOOL);
714 void         ssl_util_uuencode_binary(unsigned char *, const unsigned char *, int, BOOL);
715 apr_file_t  *ssl_util_ppopen(server_rec *, apr_pool_t *, char *);
716 void         ssl_util_ppclose(server_rec *, apr_pool_t *, apr_file_t *);
717 char        *ssl_util_readfilter(server_rec *, apr_pool_t *, char *);
718 BOOL         ssl_util_path_check(ssl_pathcheck_t, char *, apr_pool_t *);
719 ssl_algo_t   ssl_util_algotypeof(X509 *, EVP_PKEY *); 
720 char        *ssl_util_algotypestr(ssl_algo_t);
721 char        *ssl_util_ptxtsub(apr_pool_t *, const char *, const char *, char *);
722 void         ssl_util_thread_setup(void);
723 apr_status_t     ssl_util_setmodconfig(server_rec *, const char *, SSLModConfigRec *);
724 SSLModConfigRec *ssl_util_getmodconfig(server_rec *, const char *);
725 SSLModConfigRec *ssl_util_getmodconfig_ssl(SSL *, const char *);
726
727 #endif /* __MOD_SSL_H__ */