2 ** _ __ ___ ___ __| | ___ ___| | mod_ssl
3 ** | '_ ` _ \ / _ \ / _` | / __/ __| | Apache Interface to OpenSSL
4 ** | | | | | | (_) | (_| | \__ \__ \ | www.modssl.org
5 ** |_| |_| |_|\___/ \__,_|___|___/___/_| ftp.modssl.org
11 /* ====================================================================
12 * The Apache Software License, Version 1.1
14 * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
21 * 1. Redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer.
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
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.
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.
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.
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
57 * ====================================================================
59 /* ``The Apache Group: a collection
60 of talented individuals who are
61 trying to perfect the art of
62 never finishing something.''
67 #define MOD_SSL_VERSION "3.0a0"
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".
74 #ifdef SSL_EXPERIMENTAL
75 #ifndef SSL_EXPERIMENTAL_PERDIRCA_IGNORE
76 #define SSL_EXPERIMENTAL_PERDIRCA
78 #ifndef SSL_EXPERIMENTAL_PROXY_IGNORE
79 #define SSL_EXPERIMENTAL_PROXY
82 #ifndef SSL_EXPERIMENTAL_ENGINE_IGNORE
83 #define SSL_EXPERIMENTAL_ENGINE
86 #endif /* SSL_EXPERIMENTAL */
89 * Power up our brain...
94 #include "http_config.h"
95 #include "http_core.h"
97 #include "http_main.h"
98 #include "http_connection.h"
99 #include "http_request.h"
100 #include "http_protocol.h"
101 #include "util_script.h"
102 #include "util_filter.h"
105 #include "apr_strings.h"
106 #include "apr_tables.h"
108 #include "apr_fnmatch.h"
109 #include "apr_strings.h"
111 #include "apr_optional.h"
113 /* OpenSSL headers */
122 #ifdef SSL_EXPERIMENTAL_ENGINE
126 /* mod_ssl headers */
127 #include "ssl_expr.h"
128 #include "ssl_util_ssl.h"
129 #include "ssl_util_table.h"
131 /* The #ifdef macros are only defined AFTER including the above
132 * therefore we cannot include these system files at the top :-(
134 #if APR_HAVE_SYS_TIME_H
135 #include <sys/time.h>
137 #if APR_HAVE_UNISTD_H
138 #include <unistd.h> /* needed for STDIN_FILENO et.al., at least on FreeBSD */
142 * Provide reasonable default for some defines
148 #define TRUE (!FALSE)
151 #define PFALSE ((void *)FALSE)
154 #define PTRUE ((void *)TRUE)
164 #define RAND_MAX INT_MAX
168 * Provide reasonable defines for some types
171 #define BOOL unsigned int
174 #define UCHAR unsigned char
178 * Provide useful shorthands
180 #define strEQ(s1,s2) (strcmp(s1,s2) == 0)
181 #define strNE(s1,s2) (strcmp(s1,s2) != 0)
182 #define strEQn(s1,s2,n) (strncmp(s1,s2,n) == 0)
183 #define strNEn(s1,s2,n) (strncmp(s1,s2,n) != 0)
185 #define strcEQ(s1,s2) (strcasecmp(s1,s2) == 0)
186 #define strcNE(s1,s2) (strcasecmp(s1,s2) != 0)
187 #define strcEQn(s1,s2,n) (strncasecmp(s1,s2,n) == 0)
188 #define strcNEn(s1,s2,n) (strncasecmp(s1,s2,n) != 0)
190 #define strIsEmpty(s) (s == NULL || s[0] == NUL)
192 #define cfgMerge(el,unset) new->el = (add->el == (unset)) ? base->el : add->el
193 #define cfgMergeArray(el) new->el = apr_array_append(p, add->el, base->el)
194 #define cfgMergeTable(el) new->el = apr_table_overlay(p, add->el, base->el)
195 #define cfgMergeCtx(el) new->el = apr_table_overlay(p, add->el, base->el)
196 #define cfgMergeString(el) cfgMerge(el, NULL)
197 #define cfgMergeBool(el) cfgMerge(el, UNSET)
198 #define cfgMergeInt(el) cfgMerge(el, UNSET)
200 #define myConnConfig(c) \
201 (SSLConnRec *)ap_get_module_config(c->conn_config, &ssl_module)
202 #define myConnConfigSet(c, val) \
203 ap_set_module_config(c->conn_config, &ssl_module, val)
204 #define mySrvConfig(srv) (SSLSrvConfigRec *)ap_get_module_config(srv->module_config, &ssl_module)
205 #define myDirConfig(req) (SSLDirConfigRec *)ap_get_module_config(req->per_dir_config, &ssl_module)
206 #define myModConfig(srv) (mySrvConfig((srv)))->mc
208 #define myCtxVarSet(mc,num,val) mc->rCtx.pV##num = val
209 #define myCtxVarGet(mc,num,type) (type)(mc->rCtx.pV##num)
214 #define SSL_LOG_NONE (1<<0)
215 #define SSL_LOG_ERROR (1<<1)
216 #define SSL_LOG_WARN (1<<2)
217 #define SSL_LOG_INFO (1<<3)
218 #define SSL_LOG_TRACE (1<<4)
219 #define SSL_LOG_DEBUG (1<<5)
220 #define SSL_LOG_MASK (SSL_LOG_ERROR|SSL_LOG_WARN|SSL_LOG_INFO|SSL_LOG_TRACE|SSL_LOG_DEBUG)
222 #define SSL_ADD_NONE (1<<8)
223 #define SSL_ADD_ERRNO (1<<9)
224 #define SSL_ADD_SSLERR (1<<10)
225 #define SSL_NO_TIMESTAMP (1<<11)
226 #define SSL_NO_LEVELID (1<<12)
227 #define SSL_NO_NEWLINE (1<<13)
230 * Defaults for the configuration
232 #ifndef SSL_SESSION_CACHE_TIMEOUT
233 #define SSL_SESSION_CACHE_TIMEOUT 300
237 * Support for MM library
239 #define SSL_MM_FILE_MODE ( APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD )
242 * Support for DBM library
244 #define SSL_DBM_FILE_MODE ( APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD )
246 #if !defined(SSL_DBM_FILE_SUFFIX_DIR) && !defined(SSL_DBM_FILE_SUFFIX_PAG)
247 #if defined(DBM_SUFFIX)
248 #define SSL_DBM_FILE_SUFFIX_DIR DBM_SUFFIX
249 #define SSL_DBM_FILE_SUFFIX_PAG DBM_SUFFIX
250 #elif defined(__FreeBSD__) || (defined(DB_LOCK) && defined(DB_SHMEM))
251 #define SSL_DBM_FILE_SUFFIX_DIR ".db"
252 #define SSL_DBM_FILE_SUFFIX_PAG ".db"
254 #define SSL_DBM_FILE_SUFFIX_DIR ".dir"
255 #define SSL_DBM_FILE_SUFFIX_PAG ".pag"
260 * Check for OpenSSL version
262 #if SSL_LIBRARY_VERSION < 0x00903100
263 #error "mod_ssl requires OpenSSL 0.9.3 or higher"
267 * The own data structures
271 apr_pool_t *pSubPool;
272 apr_array_header_t *aData;
277 apr_pool_t *pSubPool;
278 apr_array_header_t *aKey;
279 apr_array_header_t *aData;
283 * Define the certificate algorithm types
286 typedef int ssl_algo_t;
288 #define SSL_ALGO_UNKNOWN (0)
289 #define SSL_ALGO_RSA (1<<0)
290 #define SSL_ALGO_DSA (1<<1)
291 #define SSL_ALGO_ALL (SSL_ALGO_RSA|SSL_ALGO_DSA)
293 #define SSL_AIDX_RSA (0)
294 #define SSL_AIDX_DSA (1)
295 #define SSL_AIDX_MAX (2)
299 * Define IDs for the temporary RSA keys and DH params
302 #define SSL_TKP_GEN (0)
303 #define SSL_TKP_ALLOC (1)
304 #define SSL_TKP_FREE (2)
306 #define SSL_TKPIDX_RSA512 (0)
307 #define SSL_TKPIDX_RSA1024 (1)
308 #define SSL_TKPIDX_DH512 (2)
309 #define SSL_TKPIDX_DH1024 (3)
310 #define SSL_TKPIDX_MAX (4)
313 * Define the SSL options
315 #define SSL_OPT_NONE (0)
316 #define SSL_OPT_RELSET (1<<0)
317 #define SSL_OPT_STDENVVARS (1<<1)
318 #define SSL_OPT_COMPATENVVARS (1<<2)
319 #define SSL_OPT_EXPORTCERTDATA (1<<3)
320 #define SSL_OPT_FAKEBASICAUTH (1<<4)
321 #define SSL_OPT_STRICTREQUIRE (1<<5)
322 #define SSL_OPT_OPTRENEGOTIATE (1<<6)
323 #define SSL_OPT_ALL (SSL_OPT_STDENVVARS|SSL_OPT_COMPATENVVAR|SSL_OPT_EXPORTCERTDATA|SSL_OPT_FAKEBASICAUTH|SSL_OPT_STRICTREQUIRE|SSL_OPT_OPTRENEGOTIATE)
324 typedef int ssl_opt_t;
327 * Define the SSL Protocol options
329 #define SSL_PROTOCOL_NONE (0)
330 #define SSL_PROTOCOL_SSLV2 (1<<0)
331 #define SSL_PROTOCOL_SSLV3 (1<<1)
332 #define SSL_PROTOCOL_TLSV1 (1<<2)
333 #define SSL_PROTOCOL_ALL (SSL_PROTOCOL_SSLV2|SSL_PROTOCOL_SSLV3|SSL_PROTOCOL_TLSV1)
334 typedef int ssl_proto_t;
337 * Define the SSL verify levels
340 SSL_CVERIFY_UNSET = UNSET,
341 SSL_CVERIFY_NONE = 0,
342 SSL_CVERIFY_OPTIONAL = 1,
343 SSL_CVERIFY_REQUIRE = 2,
344 SSL_CVERIFY_OPTIONAL_NO_CA = 3
347 #define SSL_VERIFY_PEER_STRICT \
348 (SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT)
350 #ifndef X509_V_ERR_CERT_UNTRUSTED
351 #define X509_V_ERR_CERT_UNTRUSTED 27
355 #ifdef OPENSSL_VERSION_NUMBER
357 #define EVP_PKEY_key_type(k) (EVP_PKEY_type(k->type))
359 #define X509_NAME_get_entries(xs) (xs->entries)
360 #define X509_REVOKED_get_serialNumber(xs) (xs->serialNumber)
362 #define X509_get_signature_algorithm(xs) (xs->cert_info->signature->algorithm)
363 #define X509_get_key_algorithm(xs) (xs->cert_info->key->algor->algorithm)
365 #define X509_NAME_ENTRY_get_data_ptr(xs) (xs->value->data)
366 #define X509_NAME_ENTRY_get_data_len(xs) (xs->value->length)
368 #define SSL_CTX_get_extra_certs(ctx) (ctx->extra_certs)
369 #define SSL_CTX_set_extra_certs(ctx,value) {ctx->extra_certs = value;}
371 #define SSL_CIPHER_get_name(s) (s->name)
372 #define SSL_CIPHER_get_valid(s) (s->valid)
374 #define SSL_SESSION_get_session_id(s) (s->session_id)
375 #define SSL_SESSION_get_session_id_length(s) (s->session_id_length)
378 * Support for retrieving/overriding states
380 #ifndef SSL_get_state
381 #define SSL_get_state(ssl) SSL_state(ssl)
384 #define SSL_set_state(ssl,val) (ssl)->state = val
388 #define ssl_verify_error_is_optional(errnum) \
389 ((errnum == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT) \
390 || (errnum == X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN) \
391 || (errnum == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY) \
392 || (errnum == X509_V_ERR_CERT_UNTRUSTED) \
393 || (errnum == X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE))
396 * Define the SSL pass phrase dialog types
399 SSL_PPTYPE_UNSET = UNSET,
400 SSL_PPTYPE_BUILTIN = 0,
401 SSL_PPTYPE_FILTER = 1,
406 * Define the Path Checking modes
408 #define SSL_PCM_EXISTS 1
409 #define SSL_PCM_ISREG 2
410 #define SSL_PCM_ISDIR 4
411 #define SSL_PCM_ISNONZERO 8
412 typedef unsigned int ssl_pathcheck_t;
415 * Define the SSL session cache modes and structures
418 SSL_SCMODE_UNSET = UNSET,
421 SSL_SCMODE_SHMHT = 2,
426 * Define the SSL mutex modes
429 SSL_MUTEXMODE_UNSET = UNSET,
430 SSL_MUTEXMODE_NONE = 0,
431 SSL_MUTEXMODE_USED = 1
435 * Define the SSL requirement structure
443 * Define the SSL random number generator seeding source
446 SSL_RSCTX_STARTUP = 1,
447 SSL_RSCTX_CONNECT = 2
450 SSL_RSSRC_BUILTIN = 1,
453 #if SSL_LIBRARY_VERSION >= 0x00905100
465 * Define the structure of an ASN.1 anything
469 unsigned char *cpData;
470 apr_time_t source_mtime;
474 * Define the mod_ssl per-module configuration structure
475 * (i.e. the global configuration for each httpd process)
482 ap_filter_t *pInputFilter;
483 ap_filter_t *pOutputFilter;
487 SSL_SHUTDOWN_TYPE_UNSET,
488 SSL_SHUTDOWN_TYPE_STANDARD,
489 SSL_SHUTDOWN_TYPE_UNCLEAN,
490 SSL_SHUTDOWN_TYPE_ACCURATE
491 } ssl_shutdown_type_e;
495 const char *client_dn;
497 ssl_shutdown_type_e shutdown_type;
498 const char *verify_info;
499 const char *verify_error;
501 int log_level; /* for avoiding expensive logging */
504 #define SSLConnLogApplies(sslconn, level) (sslconn->log_level >= level)
510 int nSessionCacheMode;
511 char *szSessionCacheDataFile;
512 int nSessionCacheDataSize;
514 AP_MM *pSessionCacheDataMM;
516 apr_table_t *tSessionCacheDataTable;
517 ssl_mutexmode_t nMutexMode;
520 apr_array_header_t *aRandSeed;
521 apr_hash_t *tVHostKeys;
522 apr_hash_t *tTmpKeys;
523 void *pTmpKeys[SSL_TKPIDX_MAX];
524 apr_hash_t *tPublicCert;
525 apr_hash_t *tPrivateKey;
526 #ifdef SSL_EXPERIMENTAL_ENGINE
527 char *szCryptoDevice;
530 void *pV1, *pV2, *pV3, *pV4, *pV5, *pV6, *pV7, *pV8, *pV9, *pV10;
535 * Define the mod_ssl per-server configuration structure
536 * (i.e. the configuration for the main server
537 * and all <VirtualHost> contexts)
541 const char *szVHostID;
544 const char *szPublicCertFile[SSL_AIDX_MAX];
545 const char *szPrivateKeyFile[SSL_AIDX_MAX];
546 const char *szCertificateChain;
547 const char *szCACertificatePath;
548 const char *szCACertificateFile;
549 const char *szLogFile;
550 const char *szCipherSuite;
551 apr_file_t *fileLogFile;
554 ssl_verify_t nVerifyClient;
555 X509 *pPublicCert[SSL_AIDX_MAX];
556 EVP_PKEY *pPrivateKey[SSL_AIDX_MAX];
558 int nSessionCacheTimeout;
559 int nPassPhraseDialogType;
560 const char *szPassPhraseDialogPath;
561 ssl_proto_t nProtocol;
562 const char *szCARevocationPath;
563 const char *szCARevocationFile;
564 X509_STORE *pRevocationStore;
565 #ifdef SSL_EXPERIMENTAL_PROXY
566 /* Configuration details for proxy operation */
567 ssl_proto_t nProxyProtocol;
569 int nProxyVerifyDepth;
570 const char *szProxyCACertificatePath;
571 const char *szProxyCACertificateFile;
572 const char *szProxyClientCertificateFile;
573 const char *szProxyClientCertificatePath;
574 const char *szProxyCipherSuite;
575 SSL_CTX *pSSLProxyCtx;
576 STACK_OF(X509_INFO) *skProxyClientCerts;
581 * Define the mod_ssl per-directory configuration structure
582 * (i.e. the local configuration for all <Directory>
583 * and .htaccess contexts)
587 apr_array_header_t *aRequirement;
589 ssl_opt_t nOptionsAdd;
590 ssl_opt_t nOptionsDel;
592 ssl_verify_t nVerifyClient;
594 #ifdef SSL_EXPERIMENTAL_PERDIRCA
595 char *szCACertificatePath;
596 char *szCACertificateFile;
601 * function prototypes
604 /* API glue structures */
605 extern module AP_MODULE_DECLARE_DATA ssl_module;
607 /* configuration handling */
608 SSLModConfigRec *ssl_config_global_create(server_rec *);
609 void ssl_config_global_fix(SSLModConfigRec *);
610 BOOL ssl_config_global_isfixed(SSLModConfigRec *);
611 void *ssl_config_server_create(apr_pool_t *, server_rec *);
612 void *ssl_config_server_merge(apr_pool_t *, void *, void *);
613 void *ssl_config_perdir_create(apr_pool_t *, char *);
614 void *ssl_config_perdir_merge(apr_pool_t *, void *, void *);
615 const char *ssl_cmd_SSLMutex(cmd_parms *, void *, const char *);
616 const char *ssl_cmd_SSLPassPhraseDialog(cmd_parms *, void *, const char *);
617 const char *ssl_cmd_SSLCryptoDevice(cmd_parms *, void *, const char *);
618 const char *ssl_cmd_SSLRandomSeed(cmd_parms *, void *, const char *, const char *, const char *);
619 const char *ssl_cmd_SSLEngine(cmd_parms *, void *, int);
620 const char *ssl_cmd_SSLCipherSuite(cmd_parms *, void *, const char *);
621 const char *ssl_cmd_SSLCertificateFile(cmd_parms *, void *, const char *);
622 const char *ssl_cmd_SSLCertificateKeyFile(cmd_parms *, void *, const char *);
623 const char *ssl_cmd_SSLCertificateChainFile(cmd_parms *, void *, const char *);
624 const char *ssl_cmd_SSLCACertificatePath(cmd_parms *, void *, const char *);
625 const char *ssl_cmd_SSLCACertificateFile(cmd_parms *, void *, const char *);
626 const char *ssl_cmd_SSLCARevocationPath(cmd_parms *, void *, const char *);
627 const char *ssl_cmd_SSLCARevocationFile(cmd_parms *, void *, const char *);
628 const char *ssl_cmd_SSLVerifyClient(cmd_parms *, void *, const char *);
629 const char *ssl_cmd_SSLVerifyDepth(cmd_parms *, void *, const char *);
630 const char *ssl_cmd_SSLSessionCache(cmd_parms *, void *, const char *);
631 const char *ssl_cmd_SSLSessionCacheTimeout(cmd_parms *, void *, const char *);
632 const char *ssl_cmd_SSLLog(cmd_parms *, void *, const char *);
633 const char *ssl_cmd_SSLLogLevel(cmd_parms *, void *, const char *);
634 const char *ssl_cmd_SSLProtocol(cmd_parms *, void *, const char *);
635 const char *ssl_cmd_SSLOptions(cmd_parms *, void *, const char *);
636 const char *ssl_cmd_SSLRequireSSL(cmd_parms *, void *);
637 const char *ssl_cmd_SSLRequire(cmd_parms *, void *, const char *);
638 #ifdef SSL_EXPERIMENTAL_PROXY
639 const char *ssl_cmd_SSLProxyProtocol(cmd_parms *, char *, const char *);
640 const char *ssl_cmd_SSLProxyCipherSuite(cmd_parms *, char *, char *);
641 const char *ssl_cmd_SSLProxyVerify(cmd_parms *, char *, int);
642 const char *ssl_cmd_SSLProxyVerifyDepth(cmd_parms *, char *, char *);
643 const char *ssl_cmd_SSLProxyCACertificatePath(cmd_parms *, char *, char *);
644 const char *ssl_cmd_SSLProxyCACertificateFile(cmd_parms *, char *, char *);
645 const char *ssl_cmd_SSLProxyMachineCertificatePath(cmd_parms *, char *, char *);
646 const char *ssl_cmd_SSLProxyMachineCertificateFile(cmd_parms *, char *, char *);
649 /* module initialization */
650 int ssl_init_Module(apr_pool_t *, apr_pool_t *, apr_pool_t *, server_rec *);
651 void ssl_init_Engine(server_rec *, apr_pool_t *);
652 void ssl_init_TmpKeysHandle(int, server_rec *, apr_pool_t *);
653 void ssl_init_ConfigureServer(server_rec *, apr_pool_t *, SSLSrvConfigRec *);
654 void ssl_init_CheckServers(server_rec *, apr_pool_t *);
656 *ssl_init_FindCAList(server_rec *, apr_pool_t *, const char *, const char *);
657 void ssl_init_Child(apr_pool_t *, server_rec *);
658 apr_status_t ssl_init_ModuleKill(void *data);
660 /* Apache API hooks */
661 void ssl_hook_NewConnection(conn_rec *);
662 void ssl_hook_TimeoutConnection(int);
663 int ssl_hook_process_connection(SSLFilterRec *pRec);
664 apr_status_t ssl_hook_CloseConnection(SSLFilterRec *);
665 int ssl_hook_Translate(request_rec *);
666 int ssl_hook_Auth(request_rec *);
667 int ssl_hook_UserCheck(request_rec *);
668 int ssl_hook_Access(request_rec *);
669 int ssl_hook_Fixup(request_rec *);
670 int ssl_hook_ReadReq(request_rec *);
671 int ssl_hook_Handler(request_rec *);
673 /* OpenSSL callbacks */
674 RSA *ssl_callback_TmpRSA(SSL *, int, int);
675 DH *ssl_callback_TmpDH(SSL *, int, int);
676 int ssl_callback_SSLVerify(int, X509_STORE_CTX *);
677 int ssl_callback_SSLVerify_CRL(int, X509_STORE_CTX *, server_rec *);
678 int ssl_callback_NewSessionCacheEntry(SSL *, SSL_SESSION *);
679 SSL_SESSION *ssl_callback_GetSessionCacheEntry(SSL *, unsigned char *, int, int *);
680 void ssl_callback_DelSessionCacheEntry(SSL_CTX *, SSL_SESSION *);
681 #if SSL_LIBRARY_VERSION >= 0x00907000
682 void ssl_callback_LogTracingState(const SSL *, int, int);
684 void ssl_callback_LogTracingState(SSL *, int, int);
687 /* Session Cache Support */
688 void ssl_scache_init(server_rec *, apr_pool_t *);
690 void ssl_scache_status_register(apr_pool_t *p);
692 void ssl_scache_kill(server_rec *);
693 BOOL ssl_scache_store(server_rec *, UCHAR *, int, time_t, SSL_SESSION *);
694 SSL_SESSION *ssl_scache_retrieve(server_rec *, UCHAR *, int);
695 void ssl_scache_remove(server_rec *, UCHAR *, int);
696 void ssl_scache_expire(server_rec *);
697 void ssl_scache_status(server_rec *, apr_pool_t *, void (*)(char *, void *), void *);
698 char *ssl_scache_id2sz(UCHAR *, int);
699 void ssl_scache_dbm_init(server_rec *, apr_pool_t *);
700 void ssl_scache_dbm_kill(server_rec *);
701 BOOL ssl_scache_dbm_store(server_rec *, UCHAR *, int, time_t, SSL_SESSION *);
702 SSL_SESSION *ssl_scache_dbm_retrieve(server_rec *, UCHAR *, int);
703 void ssl_scache_dbm_remove(server_rec *, UCHAR *, int);
704 void ssl_scache_dbm_expire(server_rec *);
705 void ssl_scache_dbm_status(server_rec *, apr_pool_t *, void (*)(char *, void *), void *);
707 void ssl_scache_shmht_init(server_rec *, pool *);
708 void ssl_scache_shmht_kill(server_rec *);
709 BOOL ssl_scache_shmht_store(server_rec *, UCHAR *, int, time_t, SSL_SESSION *);
710 SSL_SESSION *ssl_scache_shmht_retrieve(server_rec *, UCHAR *, int);
711 void ssl_scache_shmht_remove(server_rec *, UCHAR *, int);
712 void ssl_scache_shmht_expire(server_rec *);
713 void ssl_scache_shmht_status(server_rec *, pool *, void (*)(char *, void *), void *);
714 void ssl_scache_shmcb_init(server_rec *, pool *);
715 void ssl_scache_shmcb_kill(server_rec *);
716 BOOL ssl_scache_shmcb_store(server_rec *, UCHAR *, int, time_t, SSL_SESSION *);
717 SSL_SESSION *ssl_scache_shmcb_retrieve(server_rec *, UCHAR *, int);
718 void ssl_scache_shmcb_remove(server_rec *, UCHAR *, int);
719 void ssl_scache_shmcb_expire(server_rec *);
720 void ssl_scache_shmcb_status(server_rec *, pool *, void (*)(char *, void *), void *);
723 /* Pass Phrase Support */
724 void ssl_pphrase_Handle(server_rec *, apr_pool_t *);
726 /* Diffie-Hellman Parameter Support */
727 DH *ssl_dh_GetTmpParam(int);
728 DH *ssl_dh_GetParamFromFile(char *);
730 /* Data Structures */
731 ssl_ds_array *ssl_ds_array_make(apr_pool_t *, int);
732 BOOL ssl_ds_array_isempty(ssl_ds_array *);
733 void *ssl_ds_array_push(ssl_ds_array *);
734 void *ssl_ds_array_get(ssl_ds_array *, int);
735 void ssl_ds_array_wipeout(ssl_ds_array *);
736 void ssl_ds_array_kill(ssl_ds_array *);
737 ssl_ds_table *ssl_ds_table_make(apr_pool_t *, int);
738 BOOL ssl_ds_table_isempty(ssl_ds_table *);
739 void *ssl_ds_table_push(ssl_ds_table *, char *);
740 void *ssl_ds_table_get(ssl_ds_table *, char *);
741 void ssl_ds_table_wipeout(ssl_ds_table *);
742 void ssl_ds_table_kill(ssl_ds_table *);
744 unsigned char *ssl_asn1_table_set(apr_hash_t *table,
748 ssl_asn1_t *ssl_asn1_table_get(apr_hash_t *table,
751 void ssl_asn1_table_unset(apr_hash_t *table,
755 int ssl_mutex_init(server_rec *, apr_pool_t *);
756 int ssl_mutex_reinit(server_rec *, apr_pool_t *);
757 int ssl_mutex_on(server_rec *);
758 int ssl_mutex_off(server_rec *);
760 /* Logfile Support */
761 void ssl_log_open(server_rec *, server_rec *, apr_pool_t *);
762 void ssl_log(server_rec *, int, const char *, ...);
766 void ssl_var_register(void);
767 char *ssl_var_lookup(apr_pool_t *, server_rec *, conn_rec *, request_rec *, char *);
768 void ssl_var_log_config_register(apr_pool_t *p);
770 APR_DECLARE_OPTIONAL_FN(char *, ssl_var_lookup,
771 (apr_pool_t *, server_rec *,
772 conn_rec *, request_rec *,
775 /* Proxy Extensions */
777 void ssl_ext_proxy_register(apr_pool_t *p);
781 void ssl_io_filter_init(conn_rec *, SSL *);
782 void ssl_io_filter_register(apr_pool_t *);
783 long ssl_io_data_cb(BIO *, int, const char *, int, long, long);
786 int ssl_rand_seed(server_rec *, apr_pool_t *, ssl_rsctx_t, char *);
788 /* Utility Functions */
789 char *ssl_util_vhostid(apr_pool_t *, server_rec *);
790 void ssl_util_strupper(char *);
791 void ssl_util_uuencode(char *, const char *, BOOL);
792 void ssl_util_uuencode_binary(unsigned char *, const unsigned char *, int, BOOL);
793 apr_file_t *ssl_util_ppopen(server_rec *, apr_pool_t *, const char *,
794 const char * const *);
795 void ssl_util_ppclose(server_rec *, apr_pool_t *, apr_file_t *);
796 char *ssl_util_readfilter(server_rec *, apr_pool_t *, const char *,
797 const char * const *);
798 BOOL ssl_util_path_check(ssl_pathcheck_t, const char *, apr_pool_t *);
799 ssl_algo_t ssl_util_algotypeof(X509 *, EVP_PKEY *);
800 char *ssl_util_algotypestr(ssl_algo_t);
801 char *ssl_util_ptxtsub(apr_pool_t *, const char *, const char *, char *);
802 void ssl_util_thread_setup(server_rec *, apr_pool_t *);
804 #endif /* __MOD_SSL_H__ */