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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 * @brief Internal interfaces private to mod_ssl.
24 * @defgroup MOD_SSL_PRIVATE Private
31 #include "http_config.h"
32 #include "http_core.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"
43 #include "apr_strings.h"
44 #define APR_WANT_STRFUNC
46 #include "apr_tables.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"
54 #define MOD_SSL_VERSION AP_SERVER_BASEREVISION
57 #include "ssl_toolkit_compat.h"
59 #include "ssl_util_ssl.h"
61 /* The #ifdef macros are only defined AFTER including the above
62 * therefore we cannot include these system files at the top :-(
64 #if APR_HAVE_SYS_TIME_H
68 #include <unistd.h> /* needed for STDIN_FILENO et.al., at least on FreeBSD */
72 * Provide reasonable default for some defines
81 #define PFALSE ((void *)FALSE)
84 #define PTRUE ((void *)TRUE)
94 #define RAND_MAX INT_MAX
98 * Provide reasonable defines for some types
101 #define BOOL unsigned int
104 #define UCHAR unsigned char
108 * Provide useful shorthands
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)
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)
120 #define strIsEmpty(s) (s == NULL || s[0] == NUL)
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))
134 #define myCtxVarSet(mc,num,val) mc->rCtx.pV##num = val
135 #define myCtxVarGet(mc,num,type) (type)(mc->rCtx.pV##num)
138 * Defaults for the configuration
140 #ifndef SSL_SESSION_CACHE_TIMEOUT
141 #define SSL_SESSION_CACHE_TIMEOUT 300
144 /* Default setting for per-dir reneg buffer. */
145 #ifndef DEFAULT_RENEG_BUFFER_SIZE
146 #define DEFAULT_RENEG_BUFFER_SIZE (128 * 1024)
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.
155 SSL_LOG_UNSET = UNSET,
162 * Support for MM library
164 #define SSL_MM_FILE_MODE ( APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD )
167 * Define the certificate algorithm types
170 typedef int ssl_algo_t;
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)
177 #define SSL_AIDX_RSA (0)
178 #define SSL_AIDX_DSA (1)
179 #define SSL_AIDX_MAX (2)
183 * Define IDs for the temporary RSA keys and DH params
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)
193 * Define the SSL options
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;
206 * Define the SSL Protocol options
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;
216 * Define the SSL verify levels
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
226 #define SSL_VERIFY_PEER_STRICT \
227 (SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT)
229 #ifndef X509_V_ERR_CERT_UNTRUSTED
230 #define X509_V_ERR_CERT_UNTRUSTED 27
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))
241 * Define the SSL pass phrase dialog types
244 SSL_PPTYPE_UNSET = UNSET,
245 SSL_PPTYPE_BUILTIN = 0,
246 SSL_PPTYPE_FILTER = 1,
251 * Define the Path Checking modes
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;
260 * Define the SSL mutex modes
263 SSL_MUTEXMODE_UNSET = UNSET,
264 SSL_MUTEXMODE_NONE = 0,
265 SSL_MUTEXMODE_USED = 1
269 * Define the SSL enabled state
272 SSL_ENABLED_UNSET = UNSET,
273 SSL_ENABLED_FALSE = 0,
274 SSL_ENABLED_TRUE = 1,
275 SSL_ENABLED_OPTIONAL = 3
279 * Define the SSL requirement structure
287 * Define the SSL random number generator seeding source
290 SSL_RSCTX_STARTUP = 1,
291 SSL_RSCTX_CONNECT = 2
294 SSL_RSSRC_BUILTIN = 1,
307 * Define the structure of an ASN.1 anything
311 unsigned char *cpData;
312 apr_time_t source_mtime;
316 * Define the mod_ssl per-module configuration structure
317 * (i.e. the global configuration for each httpd process)
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;
329 const char *client_dn;
331 ssl_shutdown_type_e shutdown_type;
332 const char *verify_info;
333 const char *verify_error;
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
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.
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
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.
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
374 /* OpenSSL SSL_SESS_CACHE_* flags: */
377 /* The configured provider, and associated private data
379 const ap_socache_provider_t *sesscache;
380 ap_socache_instance_t *sesscache_context;
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;
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;
405 void *pV1, *pV2, *pV3, *pV4, *pV5, *pV6, *pV7, *pV8, *pV9, *pV10;
409 /** public cert/private key */
412 * server only has 1-2 certs/keys
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];
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;
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;
433 /** stuff related to authentication that can also be per-dir */
435 /** known/trusted CAs */
436 const char *ca_cert_path;
437 const char *ca_cert_file;
439 const char *cipher_suite;
441 /** for client or downstream server authentication */
443 ssl_verify_t verify_mode;
446 typedef struct SSLSrvConfigRec SSLSrvConfigRec;
449 SSLSrvConfigRec *sc; /** pointer back to server config */
452 /** we are one or the other */
453 modssl_pk_server_t *pks;
454 modssl_pk_proxy_t *pkp;
456 ssl_proto_t protocol;
458 /** config for handling encrypted keys */
459 ssl_pphrase_t pphrase_dialog_type;
460 const char *pphrase_dialog_path;
462 const char *cert_chain;
465 /** certificate revocation list */
466 const char *crl_path;
467 const char *crl_file;
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;
483 modssl_auth_ctx_t auth;
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 */
492 struct SSLSrvConfigRec {
494 ssl_enabled_t enabled;
496 const char *vhost_id;
498 int session_cache_timeout;
499 BOOL cipher_server_pref;
500 modssl_ctx_t *server;
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;
511 * Define the mod_ssl per-directory configuration structure
512 * (i.e. the local configuration for all <Directory>
513 * and .htaccess contexts)
517 apr_array_header_t *aRequirement;
519 ssl_opt_t nOptionsAdd;
520 ssl_opt_t nOptionsDel;
521 const char *szCipherSuite;
522 ssl_verify_t nVerifyClient;
524 const char *szCACertificatePath;
525 const char *szCACertificateFile;
526 const char *szUserName;
527 apr_size_t nRenegBufferSize;
531 * function prototypes
534 /** API glue structures */
535 extern module AP_MODULE_DECLARE_DATA ssl_module;
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);
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);
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);
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 *);
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);
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);
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 *);
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,
637 int ssl_proxy_enable(conn_rec *c);
638 int ssl_engine_disable(conn_rec *c);
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);
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);
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);
668 int ssl_rand_seed(server_rec *, apr_pool_t *, ssl_rsctx_t, char *);
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);
683 /** Pass Phrase Support */
684 void ssl_pphrase_Handle(server_rec *, apr_pool_t *);
686 /** Diffie-Hellman Parameter Support */
687 DH *ssl_dh_GetTmpParam(int);
688 DH *ssl_dh_GetParamFromFile(char *);
690 unsigned char *ssl_asn1_table_set(apr_hash_t *table,
694 ssl_asn1_t *ssl_asn1_table_get(apr_hash_t *table,
697 void ssl_asn1_table_unset(apr_hash_t *table,
700 const char *ssl_asn1_keystr(int keytype);
702 const char *ssl_asn1_table_keyfmt(apr_pool_t *p,
706 STACK_OF(X509) *ssl_read_pkcs7(server_rec *s, const char *pkcs7);
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 *);
714 int ssl_stapling_mutex_init(server_rec *, apr_pool_t *);
715 int ssl_stapling_mutex_reinit(server_rec *, apr_pool_t *);
717 /** Logfile Support */
719 void ssl_log_ssl_error(const char *, int, int, server_rec *);
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)));
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);
738 void ssl_var_log_config_register(apr_pool_t *p);
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);
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);
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);
761 #endif /* SSL_PRIVATE_H */