]> granicus.if.org Git - apache/blob - modules/ssl/ssl_private.h
Fix a lot of doxygen warnings. Thanks to Brad Hards for the patch.
[apache] / modules / ssl / ssl_private.h
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements.  See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License.  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 #ifndef SSL_PRIVATE_H
18 #define SSL_PRIVATE_H
19
20 /**
21  * @file  ssl_private.h 
22  * @brief Internal interfaces private to mod_ssl.
23  *
24  * @defgroup MOD_SSL_PRIVATE Private
25  * @ingroup MOD_SSL
26  * @{
27  */
28
29 /** Apache headers */
30 #include "httpd.h"
31 #include "http_config.h"
32 #include "http_core.h"
33 #include "http_log.h"
34 #include "http_main.h"
35 #include "http_connection.h"
36 #include "http_request.h"
37 #include "http_protocol.h"
38 #include "http_vhost.h"
39 #include "util_script.h"
40 #include "util_filter.h"
41 #include "util_ebcdic.h"
42 #include "apr.h"
43 #include "apr_strings.h"
44 #define APR_WANT_STRFUNC
45 #include "apr_want.h"
46 #include "apr_tables.h"
47 #include "apr_lib.h"
48 #include "apr_fnmatch.h"
49 #include "apr_strings.h"
50 #include "apr_global_mutex.h"
51 #include "apr_optional.h"
52 #include "ap_socache.h"
53
54 #define MOD_SSL_VERSION AP_SERVER_BASEREVISION
55
56 /* mod_ssl headers */
57 #include "ssl_toolkit_compat.h"
58 #include "ssl_expr.h"
59 #include "ssl_util_ssl.h"
60
61 /* The #ifdef macros are only defined AFTER including the above
62  * therefore we cannot include these system files at the top  :-(
63  */
64 #if APR_HAVE_SYS_TIME_H
65 #include <sys/time.h>
66 #endif
67 #if APR_HAVE_UNISTD_H
68 #include <unistd.h> /* needed for STDIN_FILENO et.al., at least on FreeBSD */
69 #endif
70
71 /*
72  * Provide reasonable default for some defines
73  */
74 #ifndef FALSE
75 #define FALSE (0)
76 #endif
77 #ifndef TRUE
78 #define TRUE (!FALSE)
79 #endif
80 #ifndef PFALSE
81 #define PFALSE ((void *)FALSE)
82 #endif
83 #ifndef PTRUE
84 #define PTRUE ((void *)TRUE)
85 #endif
86 #ifndef UNSET
87 #define UNSET (-1)
88 #endif
89 #ifndef NUL
90 #define NUL '\0'
91 #endif
92 #ifndef RAND_MAX
93 #include <limits.h>
94 #define RAND_MAX INT_MAX
95 #endif
96
97 /**
98  * Provide reasonable defines for some types
99  */
100 #ifndef BOOL
101 #define BOOL unsigned int
102 #endif
103 #ifndef UCHAR
104 #define UCHAR unsigned char
105 #endif
106
107 /**
108  * Provide useful shorthands
109  */
110 #define strEQ(s1,s2)     (strcmp(s1,s2)        == 0)
111 #define strNE(s1,s2)     (strcmp(s1,s2)        != 0)
112 #define strEQn(s1,s2,n)  (strncmp(s1,s2,n)     == 0)
113 #define strNEn(s1,s2,n)  (strncmp(s1,s2,n)     != 0)
114
115 #define strcEQ(s1,s2)    (strcasecmp(s1,s2)    == 0)
116 #define strcNE(s1,s2)    (strcasecmp(s1,s2)    != 0)
117 #define strcEQn(s1,s2,n) (strncasecmp(s1,s2,n) == 0)
118 #define strcNEn(s1,s2,n) (strncasecmp(s1,s2,n) != 0)
119
120 #define strIsEmpty(s)    (s == NULL || s[0] == NUL)
121
122 #define myConnConfig(c) \
123 (SSLConnRec *)ap_get_module_config(c->conn_config, &ssl_module)
124 #define myCtxConfig(sslconn, sc) (sslconn->is_proxy ? sc->proxy : sc->server)
125 #define myConnConfigSet(c, val) \
126 ap_set_module_config(c->conn_config, &ssl_module, val)
127 #define mySrvConfig(srv) (SSLSrvConfigRec *)ap_get_module_config(srv->module_config,  &ssl_module)
128 #define myDirConfig(req) (SSLDirConfigRec *)ap_get_module_config(req->per_dir_config, &ssl_module)
129 #define myModConfig(srv) (mySrvConfig((srv)))->mc
130 #define mySrvFromConn(c) (myConnConfig(c))->server
131 #define mySrvConfigFromConn(c) mySrvConfig(mySrvFromConn(c))
132 #define myModConfigFromConn(c) myModConfig(mySrvFromConn(c))
133
134 #define myCtxVarSet(mc,num,val)  mc->rCtx.pV##num = val
135 #define myCtxVarGet(mc,num,type) (type)(mc->rCtx.pV##num)
136
137 /**
138  * Defaults for the configuration
139  */
140 #ifndef SSL_SESSION_CACHE_TIMEOUT
141 #define SSL_SESSION_CACHE_TIMEOUT  300
142 #endif
143
144 /* Default setting for per-dir reneg buffer. */
145 #ifndef DEFAULT_RENEG_BUFFER_SIZE
146 #define DEFAULT_RENEG_BUFFER_SIZE (128 * 1024)
147 #endif
148
149 /**
150  * Define the per-server SSLLogLevel constants which provide
151  * finer-than-debug resolution to decide if logs are to be
152  * assulted with tens of thousands of characters per request.
153  */
154 typedef enum {
155     SSL_LOG_UNSET  = UNSET,
156     SSL_LOG_NONE   = 0,
157     SSL_LOG_IO     = 6,
158     SSL_LOG_BYTES  = 7
159 } ssl_log_level_e;
160
161 /**
162  * Support for MM library
163  */
164 #define SSL_MM_FILE_MODE ( APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD )
165
166 /**
167  * Define the certificate algorithm types
168  */
169
170 typedef int ssl_algo_t;
171
172 #define SSL_ALGO_UNKNOWN (0)
173 #define SSL_ALGO_RSA     (1<<0)
174 #define SSL_ALGO_DSA     (1<<1)
175 #define SSL_ALGO_ALL     (SSL_ALGO_RSA|SSL_ALGO_DSA)
176
177 #define SSL_AIDX_RSA     (0)
178 #define SSL_AIDX_DSA     (1)
179 #define SSL_AIDX_MAX     (2)
180
181
182 /**
183  * Define IDs for the temporary RSA keys and DH params
184  */
185
186 #define SSL_TMP_KEY_RSA_512  (0)
187 #define SSL_TMP_KEY_RSA_1024 (1)
188 #define SSL_TMP_KEY_DH_512   (2)
189 #define SSL_TMP_KEY_DH_1024  (3)
190 #define SSL_TMP_KEY_MAX      (4)
191
192 /**
193  * Define the SSL options
194  */
195 #define SSL_OPT_NONE           (0)
196 #define SSL_OPT_RELSET         (1<<0)
197 #define SSL_OPT_STDENVVARS     (1<<1)
198 #define SSL_OPT_EXPORTCERTDATA (1<<3)
199 #define SSL_OPT_FAKEBASICAUTH  (1<<4)
200 #define SSL_OPT_STRICTREQUIRE  (1<<5)
201 #define SSL_OPT_OPTRENEGOTIATE (1<<6)
202 #define SSL_OPT_ALL            (SSL_OPT_STDENVVARS|SSL_OPT_EXPORTCERTDATA|SSL_OPT_FAKEBASICAUTH|SSL_OPT_STRICTREQUIRE|SSL_OPT_OPTRENEGOTIATE)
203 typedef int ssl_opt_t;
204
205 /**
206  * Define the SSL Protocol options
207  */
208 #define SSL_PROTOCOL_NONE  (0)
209 #define SSL_PROTOCOL_SSLV2 (1<<0)
210 #define SSL_PROTOCOL_SSLV3 (1<<1)
211 #define SSL_PROTOCOL_TLSV1 (1<<2)
212 #define SSL_PROTOCOL_ALL   (SSL_PROTOCOL_SSLV2|SSL_PROTOCOL_SSLV3|SSL_PROTOCOL_TLSV1)
213 typedef int ssl_proto_t;
214
215 /**
216  * Define the SSL verify levels
217  */
218 typedef enum {
219     SSL_CVERIFY_UNSET           = UNSET,
220     SSL_CVERIFY_NONE            = 0,
221     SSL_CVERIFY_OPTIONAL        = 1,
222     SSL_CVERIFY_REQUIRE         = 2,
223     SSL_CVERIFY_OPTIONAL_NO_CA  = 3
224 } ssl_verify_t;
225
226 #define SSL_VERIFY_PEER_STRICT \
227      (SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT)
228
229 #ifndef X509_V_ERR_CERT_UNTRUSTED
230 #define X509_V_ERR_CERT_UNTRUSTED 27
231 #endif
232
233 #define ssl_verify_error_is_optional(errnum) \
234    ((errnum == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT) \
235     || (errnum == X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN) \
236     || (errnum == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY) \
237     || (errnum == X509_V_ERR_CERT_UNTRUSTED) \
238     || (errnum == X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE))
239
240 /**
241  * Define the SSL pass phrase dialog types
242  */
243 typedef enum {
244     SSL_PPTYPE_UNSET   = UNSET,
245     SSL_PPTYPE_BUILTIN = 0,
246     SSL_PPTYPE_FILTER  = 1,
247     SSL_PPTYPE_PIPE    = 2
248 } ssl_pphrase_t;
249
250 /**
251  * Define the Path Checking modes
252  */
253 #define SSL_PCM_EXISTS     1
254 #define SSL_PCM_ISREG      2
255 #define SSL_PCM_ISDIR      4
256 #define SSL_PCM_ISNONZERO  8
257 typedef unsigned int ssl_pathcheck_t;
258
259 /**
260  * Define the SSL mutex modes
261  */
262 typedef enum {
263     SSL_MUTEXMODE_UNSET  = UNSET,
264     SSL_MUTEXMODE_NONE   = 0,
265     SSL_MUTEXMODE_USED   = 1
266 } ssl_mutexmode_t;
267
268 /**
269  * Define the SSL enabled state
270  */
271 typedef enum {
272     SSL_ENABLED_UNSET    = UNSET,
273     SSL_ENABLED_FALSE    = 0,
274     SSL_ENABLED_TRUE     = 1,
275     SSL_ENABLED_OPTIONAL = 3
276 } ssl_enabled_t;
277
278 /**
279  * Define the SSL requirement structure
280  */
281 typedef struct {
282     char     *cpExpr;
283     ssl_expr *mpExpr;
284 } ssl_require_t;
285
286 /**
287  * Define the SSL random number generator seeding source
288  */
289 typedef enum {
290     SSL_RSCTX_STARTUP = 1,
291     SSL_RSCTX_CONNECT = 2
292 } ssl_rsctx_t;
293 typedef enum {
294     SSL_RSSRC_BUILTIN = 1,
295     SSL_RSSRC_FILE    = 2,
296     SSL_RSSRC_EXEC    = 3,
297     SSL_RSSRC_EGD     = 4
298 } ssl_rssrc_t;
299 typedef struct {
300     ssl_rsctx_t  nCtx;
301     ssl_rssrc_t  nSrc;
302     char        *cpPath;
303     int          nBytes;
304 } ssl_randseed_t;
305
306 /**
307  * Define the structure of an ASN.1 anything
308  */
309 typedef struct {
310     long int       nData;
311     unsigned char *cpData;
312     apr_time_t     source_mtime;
313 } ssl_asn1_t;
314
315 /**
316  * Define the mod_ssl per-module configuration structure
317  * (i.e. the global configuration for each httpd process)
318  */
319
320 typedef enum {
321     SSL_SHUTDOWN_TYPE_UNSET,
322     SSL_SHUTDOWN_TYPE_STANDARD,
323     SSL_SHUTDOWN_TYPE_UNCLEAN,
324     SSL_SHUTDOWN_TYPE_ACCURATE
325 } ssl_shutdown_type_e;
326
327 typedef struct {
328     SSL *ssl;
329     const char *client_dn;
330     X509 *client_cert;
331     ssl_shutdown_type_e shutdown_type;
332     const char *verify_info;
333     const char *verify_error;
334     int verify_depth;
335     int is_proxy;
336     int disabled;
337     int non_ssl_request;
338     server_rec *server;
339 } SSLConnRec;
340
341 /* BIG FAT WARNING: SSLModConfigRec has unusual memory lifetime: it is
342  * allocated out of the "process" pool and only a single such
343  * structure is created and used for the lifetime of the process.
344  * (The process pool is s->process->pool and is stored in the .pPool
345  * field.)  Most members of this structure are likewise allocated out
346  * of the process pool, but notably sesscache and sesscache_context
347  * are not.
348  *
349  * The structure is treated as mostly immutable after a single config
350  * parse has completed; the post_config hook (ssl_init_Module) flips
351  * the bFixed flag to true and subsequent invocations of the config
352  * callbacks hence do nothing.
353  *
354  * This odd lifetime strategy is used so that encrypted private keys
355  * can be decrypted once at startup and continue to be used across
356  * subsequent server reloads where the interactive password prompt is
357  * not possible.
358
359  * It is really an ABI nightmare waiting to happen since DSOs are
360  * reloaded across restarts, and nothing prevents the struct type
361  * changing across such reloads, yet the cached structure will be
362  * assumed to match regardless.
363  *
364  * This should really be fixed using a smaller structure which only
365  * stores that which is absolutely necessary (the private keys, maybe
366  * the random seed), and have that structure be strictly ABI-versioned
367  * for safety.
368  */
369 typedef struct {
370     pid_t           pid;
371     apr_pool_t     *pPool;
372     BOOL            bFixed;
373
374     /* OpenSSL SSL_SESS_CACHE_* flags: */
375     long            sesscache_mode;
376
377     /* The configured provider, and associated private data
378      * structure. */
379     const ap_socache_provider_t *sesscache;
380     ap_socache_instance_t *sesscache_context;
381
382     ssl_mutexmode_t nMutexMode;
383     apr_lockmech_e  nMutexMech;
384     const char     *szMutexFile;
385     apr_global_mutex_t   *pMutex;
386     apr_array_header_t   *aRandSeed;
387     apr_hash_t     *tVHostKeys;
388     void           *pTmpKeys[SSL_TMP_KEY_MAX];
389     apr_hash_t     *tPublicCert;
390     apr_hash_t     *tPrivateKey;
391 #if defined(HAVE_OPENSSL_ENGINE_H) && defined(HAVE_ENGINE_INIT)
392     const char     *szCryptoDevice;
393 #endif
394
395 #ifdef HAVE_OCSP_STAPLING
396     const ap_socache_provider_t *stapling_cache;
397     ap_socache_instance_t *stapling_cache_context;
398     ssl_mutexmode_t stapling_mutex_mode;
399     apr_lockmech_e  stapling_mutex_mech;
400     const char     *stapling_mutex_file;
401     apr_global_mutex_t   *stapling_mutex;
402 #endif
403
404     struct {
405         void *pV1, *pV2, *pV3, *pV4, *pV5, *pV6, *pV7, *pV8, *pV9, *pV10;
406     } rCtx;
407 } SSLModConfigRec;
408
409 /** public cert/private key */
410 typedef struct {
411     /** 
412      * server only has 1-2 certs/keys
413      * 1 RSA and/or 1 DSA
414      */
415     const char  *cert_files[SSL_AIDX_MAX];
416     const char  *key_files[SSL_AIDX_MAX];
417     X509        *certs[SSL_AIDX_MAX];
418     EVP_PKEY    *keys[SSL_AIDX_MAX];
419
420     /** Certificates which specify the set of CA names which should be
421      * sent in the CertificateRequest message: */
422     const char  *ca_name_path;
423     const char  *ca_name_file;
424 } modssl_pk_server_t;
425
426 typedef struct {
427     /** proxy can have any number of cert/key pairs */
428     const char  *cert_file;
429     const char  *cert_path;
430     STACK_OF(X509_INFO) *certs;
431 } modssl_pk_proxy_t;
432
433 /** stuff related to authentication that can also be per-dir */
434 typedef struct {
435     /** known/trusted CAs */
436     const char  *ca_cert_path;
437     const char  *ca_cert_file;
438
439     const char  *cipher_suite;
440
441     /** for client or downstream server authentication */
442     int          verify_depth;
443     ssl_verify_t verify_mode;
444 } modssl_auth_ctx_t;
445
446 typedef struct SSLSrvConfigRec SSLSrvConfigRec;
447
448 typedef struct {
449     SSLSrvConfigRec *sc; /** pointer back to server config */
450     SSL_CTX *ssl_ctx;
451
452     /** we are one or the other */
453     modssl_pk_server_t *pks;
454     modssl_pk_proxy_t  *pkp;
455
456     ssl_proto_t  protocol;
457
458     /** config for handling encrypted keys */
459     ssl_pphrase_t pphrase_dialog_type;
460     const char   *pphrase_dialog_path;
461
462     const char  *cert_chain;
463     const char  *pkcs7;
464
465     /** certificate revocation list */
466     const char  *crl_path;
467     const char  *crl_file;
468     X509_STORE  *crl;
469
470 #ifdef HAVE_OCSP_STAPLING
471     /** OCSP stapling options */
472     BOOL        stapling_enabled;
473     long        stapling_resptime_skew;
474     long        stapling_resp_maxage;
475     int         stapling_cache_timeout;
476     BOOL        stapling_return_errors;
477     BOOL        stapling_fake_trylater;
478     int         stapling_errcache_timeout;
479     apr_interval_time_t stapling_responder_timeout;
480     const char *stapling_force_url;
481 #endif
482
483     modssl_auth_ctx_t auth;
484
485     BOOL ocsp_enabled; /* true if OCSP verification enabled */
486     BOOL ocsp_force_default; /* true if the default responder URL is
487                               * used regardless of per-cert URL */
488     const char *ocsp_responder; /* default responder URL */
489
490 } modssl_ctx_t;
491
492 struct SSLSrvConfigRec {
493     SSLModConfigRec *mc;
494     ssl_enabled_t    enabled;
495     BOOL             proxy_enabled;
496     const char      *vhost_id;
497     int              vhost_id_len;
498     int              session_cache_timeout;
499     BOOL             cipher_server_pref;
500     modssl_ctx_t    *server;
501     modssl_ctx_t    *proxy;
502     ssl_log_level_e  ssl_log_level;
503     ssl_enabled_t    proxy_ssl_check_peer_expire;
504     ssl_enabled_t    proxy_ssl_check_peer_cn;
505 #ifndef OPENSSL_NO_TLSEXT
506     ssl_enabled_t    strict_sni_vhost_check;
507 #endif
508 };
509
510 /**
511  * Define the mod_ssl per-directory configuration structure
512  * (i.e. the local configuration for all &lt;Directory>
513  *  and .htaccess contexts)
514  */
515 typedef struct {
516     BOOL          bSSLRequired;
517     apr_array_header_t *aRequirement;
518     ssl_opt_t     nOptions;
519     ssl_opt_t     nOptionsAdd;
520     ssl_opt_t     nOptionsDel;
521     const char   *szCipherSuite;
522     ssl_verify_t  nVerifyClient;
523     int           nVerifyDepth;
524     const char   *szCACertificatePath;
525     const char   *szCACertificateFile;
526     const char   *szUserName;
527     apr_size_t    nRenegBufferSize;
528 } SSLDirConfigRec;
529
530 /**
531  *  function prototypes
532  */
533
534 /**  API glue structures  */
535 extern module AP_MODULE_DECLARE_DATA ssl_module;
536
537 /**  configuration handling   */
538 SSLModConfigRec *ssl_config_global_create(server_rec *);
539 void         ssl_config_global_fix(SSLModConfigRec *);
540 BOOL         ssl_config_global_isfixed(SSLModConfigRec *);
541 void        *ssl_config_server_create(apr_pool_t *, server_rec *);
542 void        *ssl_config_server_merge(apr_pool_t *, void *, void *);
543 void        *ssl_config_perdir_create(apr_pool_t *, char *);
544 void        *ssl_config_perdir_merge(apr_pool_t *, void *, void *);
545 const char  *ssl_cmd_SSLMutex(cmd_parms *, void *, const char *);
546 const char  *ssl_cmd_SSLPassPhraseDialog(cmd_parms *, void *, const char *);
547 const char  *ssl_cmd_SSLCryptoDevice(cmd_parms *, void *, const char *);
548 const char  *ssl_cmd_SSLRandomSeed(cmd_parms *, void *, const char *, const char *, const char *);
549 const char  *ssl_cmd_SSLEngine(cmd_parms *, void *, const char *);
550 const char  *ssl_cmd_SSLCipherSuite(cmd_parms *, void *, const char *);
551 const char  *ssl_cmd_SSLCertificateFile(cmd_parms *, void *, const char *);
552 const char  *ssl_cmd_SSLCertificateKeyFile(cmd_parms *, void *, const char *);
553 const char  *ssl_cmd_SSLCertificateChainFile(cmd_parms *, void *, const char *);
554 const char  *ssl_cmd_SSLPKCS7CertificateFile(cmd_parms *, void *, const char *);
555 const char  *ssl_cmd_SSLCACertificatePath(cmd_parms *, void *, const char *);
556 const char  *ssl_cmd_SSLCACertificateFile(cmd_parms *, void *, const char *);
557 const char  *ssl_cmd_SSLCADNRequestPath(cmd_parms *, void *, const char *);
558 const char  *ssl_cmd_SSLCADNRequestFile(cmd_parms *, void *, const char *);
559 const char  *ssl_cmd_SSLCARevocationPath(cmd_parms *, void *, const char *);
560 const char  *ssl_cmd_SSLCARevocationFile(cmd_parms *, void *, const char *);
561 const char  *ssl_cmd_SSLHonorCipherOrder(cmd_parms *cmd, void *dcfg, int flag);
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_SSLProtocol(cmd_parms *, void *, const char *);
567 const char  *ssl_cmd_SSLOptions(cmd_parms *, void *, const char *);
568 const char  *ssl_cmd_SSLRequireSSL(cmd_parms *, void *);
569 const char  *ssl_cmd_SSLRequire(cmd_parms *, void *, const char *);
570 const char  *ssl_cmd_SSLUserName(cmd_parms *, void *, const char *);
571 const char  *ssl_cmd_SSLLogLevelDebugDump(cmd_parms *, void *, const char *);
572 const char  *ssl_cmd_SSLRenegBufferSize(cmd_parms *cmd, void *dcfg, const char *arg);
573 const char  *ssl_cmd_SSLStrictSNIVHostCheck(cmd_parms *cmd, void *dcfg, int flag);
574
575 const char  *ssl_cmd_SSLProxyEngine(cmd_parms *cmd, void *dcfg, int flag);
576 const char  *ssl_cmd_SSLProxyProtocol(cmd_parms *, void *, const char *);
577 const char  *ssl_cmd_SSLProxyCipherSuite(cmd_parms *, void *, const char *);
578 const char  *ssl_cmd_SSLProxyVerify(cmd_parms *, void *, const char *);
579 const char  *ssl_cmd_SSLProxyVerifyDepth(cmd_parms *, void *, const char *);
580 const char  *ssl_cmd_SSLProxyCACertificatePath(cmd_parms *, void *, const char *);
581 const char  *ssl_cmd_SSLProxyCACertificateFile(cmd_parms *, void *, const char *);
582 const char  *ssl_cmd_SSLProxyCARevocationPath(cmd_parms *, void *, const char *);
583 const char  *ssl_cmd_SSLProxyCARevocationFile(cmd_parms *, void *, const char *);
584 const char  *ssl_cmd_SSLProxyMachineCertificatePath(cmd_parms *, void *, const char *);
585 const char  *ssl_cmd_SSLProxyMachineCertificateFile(cmd_parms *, void *, const char *);
586 const char  *ssl_cmd_SSLProxyCheckPeerExpire(cmd_parms *cmd, void *dcfg, int flag);
587 const char  *ssl_cmd_SSLProxyCheckPeerCN(cmd_parms *cmd, void *dcfg, int flag);
588
589 const char *ssl_cmd_SSLOCSPOverrideResponder(cmd_parms *cmd, void *dcfg, int flag);
590 const char *ssl_cmd_SSLOCSPDefaultResponder(cmd_parms *cmd, void *dcfg, const char *arg);
591 const char *ssl_cmd_SSLOCSPEnable(cmd_parms *cmd, void *dcfg, int flag);
592
593 /**  module initialization  */
594 int          ssl_init_Module(apr_pool_t *, apr_pool_t *, apr_pool_t *, server_rec *);
595 void         ssl_init_Engine(server_rec *, apr_pool_t *);
596 void         ssl_init_ConfigureServer(server_rec *, apr_pool_t *, apr_pool_t *, SSLSrvConfigRec *);
597 void         ssl_init_CheckServers(server_rec *, apr_pool_t *);
598 STACK_OF(X509_NAME) 
599             *ssl_init_FindCAList(server_rec *, apr_pool_t *, const char *, const char *);
600 void         ssl_init_Child(apr_pool_t *, server_rec *);
601 apr_status_t ssl_init_ModuleKill(void *data);
602
603 /**  Apache API hooks  */
604 int          ssl_hook_Auth(request_rec *);
605 int          ssl_hook_UserCheck(request_rec *);
606 int          ssl_hook_Access(request_rec *);
607 int          ssl_hook_Fixup(request_rec *);
608 int          ssl_hook_ReadReq(request_rec *);
609 int          ssl_hook_Upgrade(request_rec *);
610 void         ssl_hook_ConfigTest(apr_pool_t *pconf, server_rec *s);
611
612 /**  OpenSSL callbacks */
613 RSA         *ssl_callback_TmpRSA(SSL *, int, int);
614 DH          *ssl_callback_TmpDH(SSL *, int, int);
615 int          ssl_callback_SSLVerify(int, X509_STORE_CTX *);
616 int          ssl_callback_SSLVerify_CRL(int, X509_STORE_CTX *, conn_rec *);
617 int          ssl_callback_proxy_cert(SSL *ssl, MODSSL_CLIENT_CERT_CB_ARG_TYPE **x509, EVP_PKEY **pkey);
618 int          ssl_callback_NewSessionCacheEntry(SSL *, SSL_SESSION *);
619 SSL_SESSION *ssl_callback_GetSessionCacheEntry(SSL *, unsigned char *, int, int *);
620 void         ssl_callback_DelSessionCacheEntry(SSL_CTX *, SSL_SESSION *);
621 void         ssl_callback_LogTracingState(MODSSL_INFO_CB_ARG_TYPE, int, int);
622 #ifndef OPENSSL_NO_TLSEXT
623 int          ssl_callback_ServerNameIndication(SSL *, int *, modssl_ctx_t *);
624 #endif
625
626 /**  Session Cache Support  */
627 void         ssl_scache_init(server_rec *, apr_pool_t *);
628 void         ssl_scache_status_register(apr_pool_t *p);
629 void         ssl_scache_kill(server_rec *);
630 BOOL         ssl_scache_store(server_rec *, UCHAR *, int,
631                               time_t, SSL_SESSION *, apr_pool_t *);
632 SSL_SESSION *ssl_scache_retrieve(server_rec *, UCHAR *, int, apr_pool_t *);
633 void         ssl_scache_remove(server_rec *, UCHAR *, int,
634                                apr_pool_t *);
635
636 /** Proxy Support */
637 int ssl_proxy_enable(conn_rec *c);
638 int ssl_engine_disable(conn_rec *c);
639
640 /** OCSP Stapling Support */
641 #ifdef HAVE_OCSP_STAPLING
642 const char *ssl_cmd_SSLStaplingMutex(cmd_parms *, void *, const char *);
643 const char *ssl_cmd_SSLStaplingCache(cmd_parms *, void *, const char *);
644 const char *ssl_cmd_SSLUseStapling(cmd_parms *, void *, int);
645 const char *ssl_cmd_SSLStaplingResponseTimeSkew(cmd_parms *, void *, const char *);
646 const char *ssl_cmd_SSLStaplingResponseMaxAge(cmd_parms *, void *, const char *);
647 const char *ssl_cmd_SSLStaplingStandardCacheTimeout(cmd_parms *, void *, const char *);
648 const char *ssl_cmd_SSLStaplingErrorCacheTimeout(cmd_parms *, void *, const char *);
649 const char *ssl_cmd_SSLStaplingReturnResponderErrors(cmd_parms *, void *, int);
650 const char *ssl_cmd_SSLStaplingFakeTryLater(cmd_parms *, void *, int);
651 const char *ssl_cmd_SSLStaplingResponderTimeout(cmd_parms *, void *, const char *);
652 const char  *ssl_cmd_SSLStaplingForceURL(cmd_parms *, void *, const char *);
653 void         modssl_init_stapling(server_rec *, apr_pool_t *, apr_pool_t *, modssl_ctx_t *);
654 void         ssl_stapling_ex_init(void);
655 int          ssl_stapling_init_cert(server_rec *s, modssl_ctx_t *mctx, X509 *x);
656 #endif
657
658 /**  I/O  */
659 void         ssl_io_filter_init(conn_rec *, request_rec *r, SSL *);
660 void         ssl_io_filter_register(apr_pool_t *);
661 long         ssl_io_data_cb(BIO *, int, MODSSL_BIO_CB_ARG_TYPE *, int, long, long);
662
663 /* ssl_io_buffer_fill fills the setaside buffering of the HTTP request
664  * to allow an SSL renegotiation to take place. */
665 int          ssl_io_buffer_fill(request_rec *r, apr_size_t maxlen);
666
667 /**  PRNG  */
668 int          ssl_rand_seed(server_rec *, apr_pool_t *, ssl_rsctx_t, char *);
669
670 /**  Utility Functions  */
671 char        *ssl_util_vhostid(apr_pool_t *, server_rec *);
672 apr_file_t  *ssl_util_ppopen(server_rec *, apr_pool_t *, const char *,
673                              const char * const *);
674 void         ssl_util_ppclose(server_rec *, apr_pool_t *, apr_file_t *);
675 char        *ssl_util_readfilter(server_rec *, apr_pool_t *, const char *,
676                                  const char * const *);
677 BOOL         ssl_util_path_check(ssl_pathcheck_t, const char *, apr_pool_t *);
678 ssl_algo_t   ssl_util_algotypeof(X509 *, EVP_PKEY *); 
679 char        *ssl_util_algotypestr(ssl_algo_t);
680 void         ssl_util_thread_setup(apr_pool_t *);
681 int          ssl_init_ssl_connection(conn_rec *c, request_rec *r);
682
683 /**  Pass Phrase Support  */
684 void         ssl_pphrase_Handle(server_rec *, apr_pool_t *);
685
686 /**  Diffie-Hellman Parameter Support  */
687 DH           *ssl_dh_GetTmpParam(int);
688 DH           *ssl_dh_GetParamFromFile(char *);
689
690 unsigned char *ssl_asn1_table_set(apr_hash_t *table,
691                                   const char *key,
692                                   long int length);
693
694 ssl_asn1_t *ssl_asn1_table_get(apr_hash_t *table,
695                                const char *key);
696
697 void ssl_asn1_table_unset(apr_hash_t *table,
698                           const char *key);
699
700 const char *ssl_asn1_keystr(int keytype);
701
702 const char *ssl_asn1_table_keyfmt(apr_pool_t *p,
703                                   const char *id,
704                                   int keytype);
705
706 STACK_OF(X509) *ssl_read_pkcs7(server_rec *s, const char *pkcs7);
707
708 /**  Mutex Support  */
709 int          ssl_mutex_init(server_rec *, apr_pool_t *);
710 int          ssl_mutex_reinit(server_rec *, apr_pool_t *);
711 int          ssl_mutex_on(server_rec *);
712 int          ssl_mutex_off(server_rec *);
713
714 int          ssl_stapling_mutex_init(server_rec *, apr_pool_t *);
715 int          ssl_stapling_mutex_reinit(server_rec *, apr_pool_t *);
716
717 /**  Logfile Support  */
718 void         ssl_die(void);
719 void         ssl_log_ssl_error(const char *, int, int, server_rec *);
720
721 /* ssl_log_cxerror is a wrapper for ap_log_cerror which takes a
722  * certificate as an additional argument and appends details of that
723  * cert to the log message.  All other arguments interpreted exactly
724  * as ap_log_cerror. */
725 void ssl_log_cxerror(const char *file, int line, int level, 
726                      apr_status_t rv, conn_rec *c, X509 *cert,
727                      const char *format, ...)
728     __attribute__((format(printf,7,8)));
729
730
731 /**  Variables  */
732
733 /* Register variables for the lifetime of the process pool 'p'. */
734 void         ssl_var_register(apr_pool_t *p);
735 char        *ssl_var_lookup(apr_pool_t *, server_rec *, conn_rec *, request_rec *, char *);
736 apr_array_header_t *ssl_ext_list(apr_pool_t *p, conn_rec *c, int peer, const char *extension);
737
738 void         ssl_var_log_config_register(apr_pool_t *p);
739
740 /* Extract SSL_*_DN_* variables into table 't' from SSL object 'ssl',
741  * allocating from 'p': */
742 void modssl_var_extract_dns(apr_table_t *t, SSL *ssl, apr_pool_t *p);
743
744 #ifdef HAVE_OCSP
745 /* Perform OCSP validation of the current cert in the given context.
746  * Returns non-zero on success or zero on failure.  On failure, the
747  * context error code is set. */
748 int modssl_verify_ocsp(X509_STORE_CTX *ctx, SSLSrvConfigRec *sc, 
749                        server_rec *s, conn_rec *c, apr_pool_t *pool);
750
751 /* OCSP helper interface; dispatches the given OCSP request to the
752  * responder at the given URI.  Returns the decoded OCSP response
753  * object, or NULL on error (in which case, errors will have been
754  * logged).  Pool 'p' is used for temporary allocations. */
755 OCSP_RESPONSE *modssl_dispatch_ocsp_request(const apr_uri_t *uri,
756                                             apr_interval_time_t timeout,
757                                             OCSP_REQUEST *request,
758                                             conn_rec *c, apr_pool_t *p);
759 #endif
760
761 #endif /* SSL_PRIVATE_H */
762 /** @} */
763