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.
18 * _ __ ___ ___ __| | ___ ___| | mod_ssl
19 * | '_ ` _ \ / _ \ / _` | / __/ __| | Apache Interface to OpenSSL
20 * | | | | | | (_) | (_| | \__ \__ \ |
21 * |_| |_| |_|\___/ \__,_|___|___/___/_|
24 * Apache API interface structures
27 #include "ssl_private.h"
29 #include "mod_ssl_openssl.h"
31 #include "util_mutex.h"
32 #include "ap_provider.h"
33 #include "http_config.h"
35 #include "mod_proxy.h" /* for proxy_hook_section_post_config() */
41 int ssl_running_on_valgrind = 0;
43 static int modssl_running_statically = 0;
45 APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ssl, SSL, int, pre_handshake,
46 (conn_rec *c,SSL *ssl,int is_proxy),
47 (c,ssl,is_proxy), OK, DECLINED);
50 * the table of configuration directives we provide
53 #define SSL_CMD_ALL(name, args, desc) \
54 AP_INIT_##args("SSL"#name, ssl_cmd_SSL##name, \
55 NULL, RSRC_CONF|OR_AUTHCFG, desc),
57 #define SSL_CMD_SRV(name, args, desc) \
58 AP_INIT_##args("SSL"#name, ssl_cmd_SSL##name, \
59 NULL, RSRC_CONF, desc),
61 #define SSL_CMD_PXY(name, args, desc) \
62 AP_INIT_##args("SSL"#name, ssl_cmd_SSL##name, \
63 NULL, RSRC_CONF|PROXY_CONF, desc),
65 #define SSL_CMD_DIR(name, type, args, desc) \
66 AP_INIT_##args("SSL"#name, ssl_cmd_SSL##name, \
67 NULL, OR_##type, desc),
69 #define AP_END_CMD { NULL }
71 static const command_rec ssl_config_cmds[] = {
73 * Global (main-server) context configuration directives
75 SSL_CMD_SRV(PassPhraseDialog, TAKE1,
76 "SSL dialog mechanism for the pass phrase query "
77 "('builtin', '|/path/to/pipe_program', "
78 "or 'exec:/path/to/cgi_program')")
79 SSL_CMD_SRV(SessionCache, TAKE1,
80 "SSL Session Cache storage "
81 "('none', 'nonenotnull', 'dbm:/path/to/file')")
82 #if defined(HAVE_OPENSSL_ENGINE_H) && defined(HAVE_ENGINE_INIT)
83 SSL_CMD_SRV(CryptoDevice, TAKE1,
84 "SSL external Crypto Device usage "
87 SSL_CMD_SRV(RandomSeed, TAKE23,
88 "SSL Pseudo Random Number Generator (PRNG) seeding source "
89 "('startup|connect builtin|file:/path|exec:/path [bytes]')")
92 * Per-server context configuration directives
94 SSL_CMD_SRV(Engine, TAKE1,
95 "SSL switch for the protocol engine "
97 SSL_CMD_SRV(FIPS, FLAG,
98 "Enable FIPS-140 mode "
100 SSL_CMD_ALL(CipherSuite, TAKE1,
101 "Colon-delimited list of permitted SSL Ciphers "
102 "('XXX:...:XXX' - see manual)")
103 SSL_CMD_SRV(CertificateFile, TAKE1,
104 "SSL Server Certificate file "
105 "('/path/to/file' - PEM or DER encoded)")
106 SSL_CMD_SRV(CertificateKeyFile, TAKE1,
107 "SSL Server Private Key file "
108 "('/path/to/file' - PEM or DER encoded)")
109 SSL_CMD_SRV(CertificateChainFile, TAKE1,
110 "SSL Server CA Certificate Chain file "
111 "('/path/to/file' - PEM encoded)")
112 #ifdef HAVE_TLS_SESSION_TICKETS
113 SSL_CMD_SRV(SessionTicketKeyFile, TAKE1,
114 "TLS session ticket encryption/decryption key file (RFC 5077) "
115 "('/path/to/file' - file with 48 bytes of random data)")
117 SSL_CMD_ALL(CACertificatePath, TAKE1,
118 "SSL CA Certificate path "
119 "('/path/to/dir' - contains PEM encoded files)")
120 SSL_CMD_ALL(CACertificateFile, TAKE1,
121 "SSL CA Certificate file "
122 "('/path/to/file' - PEM encoded)")
123 SSL_CMD_SRV(CADNRequestPath, TAKE1,
124 "SSL CA Distinguished Name path "
125 "('/path/to/dir' - symlink hashes to PEM of acceptable CA names to request)")
126 SSL_CMD_SRV(CADNRequestFile, TAKE1,
127 "SSL CA Distinguished Name file "
128 "('/path/to/file' - PEM encoded to derive acceptable CA names to request)")
129 SSL_CMD_SRV(CARevocationPath, TAKE1,
130 "SSL CA Certificate Revocation List (CRL) path "
131 "('/path/to/dir' - contains PEM encoded files)")
132 SSL_CMD_SRV(CARevocationFile, TAKE1,
133 "SSL CA Certificate Revocation List (CRL) file "
134 "('/path/to/file' - PEM encoded)")
135 SSL_CMD_SRV(CARevocationCheck, RAW_ARGS,
136 "SSL CA Certificate Revocation List (CRL) checking mode")
137 SSL_CMD_ALL(VerifyClient, TAKE1,
138 "SSL Client verify type "
139 "('none', 'optional', 'require', 'optional_no_ca')")
140 SSL_CMD_ALL(VerifyDepth, TAKE1,
141 "SSL Client verify depth "
142 "('N' - number of intermediate certificates)")
143 SSL_CMD_SRV(SessionCacheTimeout, TAKE1,
144 "SSL Session Cache object lifetime "
145 "('N' - number of seconds)")
146 #ifdef OPENSSL_NO_SSL3
147 #define SSLv3_PROTO_PREFIX ""
149 #define SSLv3_PROTO_PREFIX "SSLv3|"
152 #define SSL_PROTOCOLS SSLv3_PROTO_PREFIX "TLSv1|TLSv1.1|TLSv1.2"
154 #define SSL_PROTOCOLS SSLv3_PROTO_PREFIX "TLSv1"
156 SSL_CMD_SRV(Protocol, RAW_ARGS,
157 "Enable or disable various SSL protocols "
158 "('[+-][" SSL_PROTOCOLS "] ...' - see manual)")
159 SSL_CMD_SRV(HonorCipherOrder, FLAG,
160 "Use the server's cipher ordering preference")
161 SSL_CMD_SRV(Compression, FLAG,
162 "Enable SSL level compression "
164 SSL_CMD_SRV(SessionTickets, FLAG,
165 "Enable or disable TLS session tickets"
167 SSL_CMD_SRV(InsecureRenegotiation, FLAG,
168 "Enable support for insecure renegotiation")
169 SSL_CMD_ALL(UserName, TAKE1,
170 "Set user name to SSL variable value")
171 SSL_CMD_SRV(StrictSNIVHostCheck, FLAG,
172 "Strict SNI virtual host checking")
175 SSL_CMD_SRV(SRPVerifierFile, TAKE1,
177 "('/path/to/file' - created by srptool)")
178 SSL_CMD_SRV(SRPUnknownUserSeed, TAKE1,
179 "SRP seed for unknown users (to avoid leaking a user's existence) "
180 "('some secret text')")
184 * Proxy configuration for remote SSL connections
186 SSL_CMD_PXY(ProxyEngine, FLAG,
187 "SSL switch for the proxy protocol engine "
189 SSL_CMD_PXY(ProxyProtocol, RAW_ARGS,
190 "SSL Proxy: enable or disable SSL protocol flavors "
191 "('[+-][" SSL_PROTOCOLS "] ...' - see manual)")
192 SSL_CMD_PXY(ProxyCipherSuite, TAKE1,
193 "SSL Proxy: colon-delimited list of permitted SSL ciphers "
194 "('XXX:...:XXX' - see manual)")
195 SSL_CMD_PXY(ProxyVerify, TAKE1,
196 "SSL Proxy: whether to verify the remote certificate "
198 SSL_CMD_PXY(ProxyVerifyDepth, TAKE1,
199 "SSL Proxy: maximum certificate verification depth "
200 "('N' - number of intermediate certificates)")
201 SSL_CMD_PXY(ProxyCACertificateFile, TAKE1,
202 "SSL Proxy: file containing server certificates "
203 "('/path/to/file' - PEM encoded certificates)")
204 SSL_CMD_PXY(ProxyCACertificatePath, TAKE1,
205 "SSL Proxy: directory containing server certificates "
206 "('/path/to/dir' - contains PEM encoded certificates)")
207 SSL_CMD_PXY(ProxyCARevocationPath, TAKE1,
208 "SSL Proxy: CA Certificate Revocation List (CRL) path "
209 "('/path/to/dir' - contains PEM encoded files)")
210 SSL_CMD_PXY(ProxyCARevocationFile, TAKE1,
211 "SSL Proxy: CA Certificate Revocation List (CRL) file "
212 "('/path/to/file' - PEM encoded)")
213 SSL_CMD_PXY(ProxyCARevocationCheck, RAW_ARGS,
214 "SSL Proxy: CA Certificate Revocation List (CRL) checking mode")
215 SSL_CMD_PXY(ProxyMachineCertificateFile, TAKE1,
216 "SSL Proxy: file containing client certificates "
217 "('/path/to/file' - PEM encoded certificates)")
218 SSL_CMD_PXY(ProxyMachineCertificatePath, TAKE1,
219 "SSL Proxy: directory containing client certificates "
220 "('/path/to/dir' - contains PEM encoded certificates)")
221 SSL_CMD_PXY(ProxyMachineCertificateChainFile, TAKE1,
222 "SSL Proxy: file containing issuing certificates "
223 "of the client certificate "
224 "(`/path/to/file' - PEM encoded certificates)")
225 SSL_CMD_PXY(ProxyCheckPeerExpire, FLAG,
226 "SSL Proxy: check the peer certificate's expiration date")
227 SSL_CMD_PXY(ProxyCheckPeerCN, FLAG,
228 "SSL Proxy: check the peer certificate's CN")
229 SSL_CMD_PXY(ProxyCheckPeerName, FLAG,
230 "SSL Proxy: check the peer certificate's name "
231 "(must be present in subjectAltName extension or CN")
234 * Per-directory context configuration directives
236 SSL_CMD_DIR(Options, OPTIONS, RAW_ARGS,
237 "Set one or more options to configure the SSL engine"
238 "('[+-]option[=value] ...' - see manual)")
239 SSL_CMD_DIR(RequireSSL, AUTHCFG, NO_ARGS,
240 "Require the SSL protocol for the per-directory context "
242 SSL_CMD_DIR(Require, AUTHCFG, RAW_ARGS,
243 "Require a boolean expression to evaluate to true for granting access"
244 "(arbitrary complex boolean expression - see manual)")
245 SSL_CMD_DIR(RenegBufferSize, AUTHCFG, TAKE1,
246 "Configure the amount of memory that will be used for buffering the "
247 "request body if a per-location SSL renegotiation is required due to "
248 "changed access control requirements")
250 SSL_CMD_SRV(OCSPEnable, FLAG,
251 "Enable use of OCSP to verify certificate revocation ('on', 'off')")
252 SSL_CMD_SRV(OCSPDefaultResponder, TAKE1,
253 "URL of the default OCSP Responder")
254 SSL_CMD_SRV(OCSPOverrideResponder, FLAG,
255 "Force use of the default responder URL ('on', 'off')")
256 SSL_CMD_SRV(OCSPResponseTimeSkew, TAKE1,
257 "Maximum time difference in OCSP responses")
258 SSL_CMD_SRV(OCSPResponseMaxAge, TAKE1,
259 "Maximum age of OCSP responses")
260 SSL_CMD_SRV(OCSPResponderTimeout, TAKE1,
261 "OCSP responder query timeout")
262 SSL_CMD_SRV(OCSPUseRequestNonce, FLAG,
263 "Whether OCSP queries use a nonce or not ('on', 'off')")
264 SSL_CMD_SRV(OCSPProxyURL, TAKE1,
265 "Proxy URL to use for OCSP requests")
267 #ifdef HAVE_OCSP_STAPLING
269 * OCSP Stapling options
271 SSL_CMD_SRV(StaplingCache, TAKE1,
272 "SSL Stapling Response Cache storage "
273 "(`dbm:/path/to/file')")
274 SSL_CMD_SRV(UseStapling, FLAG,
275 "SSL switch for the OCSP Stapling protocol " "(`on', `off')")
276 SSL_CMD_SRV(StaplingResponseTimeSkew, TAKE1,
277 "SSL stapling option for maximum time difference in OCSP responses")
278 SSL_CMD_SRV(StaplingResponderTimeout, TAKE1,
279 "SSL stapling option for OCSP responder timeout")
280 SSL_CMD_SRV(StaplingResponseMaxAge, TAKE1,
281 "SSL stapling option for maximum age of OCSP responses")
282 SSL_CMD_SRV(StaplingStandardCacheTimeout, TAKE1,
283 "SSL stapling option for normal OCSP Response Cache Lifetime")
284 SSL_CMD_SRV(StaplingReturnResponderErrors, FLAG,
285 "SSL stapling switch to return Status Errors Back to Client"
287 SSL_CMD_SRV(StaplingFakeTryLater, FLAG,
288 "SSL stapling switch to send tryLater response to client on error "
290 SSL_CMD_SRV(StaplingErrorCacheTimeout, TAKE1,
291 "SSL stapling option for OCSP Response Error Cache Lifetime")
292 SSL_CMD_SRV(StaplingForceURL, TAKE1,
293 "SSL stapling option to Force the OCSP Stapling URL")
296 #ifdef HAVE_SSL_CONF_CMD
297 SSL_CMD_SRV(OpenSSLConfCmd, TAKE2,
298 "OpenSSL configuration command")
301 /* Deprecated directives. */
302 AP_INIT_RAW_ARGS("SSLLog", ap_set_deprecated, NULL, OR_ALL,
303 "SSLLog directive is no longer supported - use ErrorLog."),
304 AP_INIT_RAW_ARGS("SSLLogLevel", ap_set_deprecated, NULL, OR_ALL,
305 "SSLLogLevel directive is no longer supported - use LogLevel."),
311 * the various processing hooks
313 static int modssl_is_prelinked(void)
317 while ((mod = ap_prelinked_modules[i++])) {
318 if (strcmp(mod->name, "mod_ssl.c") == 0) {
325 static apr_status_t ssl_cleanup_pre_config(void *data)
328 * Try to kill the internals of the SSL library.
333 /* Corresponds to OBJ_create()s */
335 /* Corresponds to OPENSSL_load_builtin_modules() */
337 /* Corresponds to SSL_library_init: */
339 #if HAVE_ENGINE_LOAD_BUILTIN_ENGINES
342 #if OPENSSL_VERSION_NUMBER >= 0x1000200fL
343 SSL_COMP_free_compression_methods();
346 /* Usually needed per thread, but this parent process is single-threaded */
347 #if OPENSSL_VERSION_NUMBER < 0x10100000L
348 #if OPENSSL_VERSION_NUMBER >= 0x1000000fL
349 ERR_remove_thread_state(NULL);
355 /* Don't call ERR_free_strings in earlier versions, ERR_load_*_strings only
356 * actually loaded the error strings once per process due to static
357 * variable abuse in OpenSSL. */
358 #if (OPENSSL_VERSION_NUMBER >= 0x00090805f)
362 /* Also don't call CRYPTO_cleanup_all_ex_data when linked statically here;
363 * any registered ex_data indices may have been cached in static variables
364 * in OpenSSL; removing them may cause havoc. Notably, with OpenSSL
365 * versions >= 0.9.8f, COMP_CTX cleanups would not be run, which
366 * could result in a per-connection memory leak (!). */
367 if (!modssl_running_statically) {
368 CRYPTO_cleanup_all_ex_data();
372 * TODO: determine somewhere we can safely shove out diagnostics
373 * (when enabled) at this late stage in the game:
374 * CRYPTO_mem_leaks_fp(stderr);
379 static int ssl_hook_pre_config(apr_pool_t *pconf,
384 ssl_running_on_valgrind = RUNNING_ON_VALGRIND;
386 modssl_running_statically = modssl_is_prelinked();
388 /* Some OpenSSL internals are allocated per-thread, make sure they
389 * are associated to the/our same thread-id until cleaned up.
391 ssl_util_thread_id_setup(pconf);
393 /* We must register the library in full, to ensure our configuration
394 * code can successfully test the SSL environment.
396 #if OPENSSL_VERSION_NUMBER < 0x10100000L
397 CRYPTO_malloc_init();
399 OPENSSL_malloc_init();
401 ERR_load_crypto_strings();
402 SSL_load_error_strings();
404 #if HAVE_ENGINE_LOAD_BUILTIN_ENGINES
405 ENGINE_load_builtin_engines();
407 OpenSSL_add_all_algorithms();
408 OPENSSL_load_builtin_modules();
410 if (OBJ_txt2nid("id-on-dnsSRV") == NID_undef) {
411 (void)OBJ_create("1.3.6.1.5.5.7.8.7", "id-on-dnsSRV",
412 "SRVName otherName form");
415 /* Start w/o errors (e.g. OBJ_txt2nid() above) */
419 * Let us cleanup the ssl library when the module is unloaded
421 apr_pool_cleanup_register(pconf, NULL, ssl_cleanup_pre_config,
422 apr_pool_cleanup_null);
424 /* Register us to handle mod_log_config %c/%x variables */
425 ssl_var_log_config_register(pconf);
427 /* Register to handle mod_status status page generation */
428 ssl_scache_status_register(pconf);
430 /* Register mutex type names so they can be configured with Mutex */
431 ap_mutex_register(pconf, SSL_CACHE_MUTEX_TYPE, NULL, APR_LOCK_DEFAULT, 0);
432 #ifdef HAVE_OCSP_STAPLING
433 ap_mutex_register(pconf, SSL_STAPLING_CACHE_MUTEX_TYPE, NULL,
434 APR_LOCK_DEFAULT, 0);
435 ap_mutex_register(pconf, SSL_STAPLING_REFRESH_MUTEX_TYPE, NULL,
436 APR_LOCK_DEFAULT, 0);
442 static SSLConnRec *ssl_init_connection_ctx(conn_rec *c,
443 ap_conf_vector_t *per_dir_config)
445 SSLConnRec *sslconn = myConnConfig(c);
452 sslconn = apr_pcalloc(c->pool, sizeof(*sslconn));
454 if (per_dir_config) {
455 sslconn->dc = ap_get_module_config(per_dir_config, &ssl_module);
458 sslconn->dc = ap_get_module_config(c->base_server->lookup_defaults,
462 sslconn->server = c->base_server;
463 sslconn->verify_depth = UNSET;
464 sc = mySrvConfig(c->base_server);
465 sslconn->cipher_suite = sc->server->auth.cipher_suite;
467 myConnConfigSet(c, sslconn);
472 static int ssl_engine_status(conn_rec *c, SSLConnRec *sslconn)
478 if (sslconn->disabled) {
481 if (sslconn->is_proxy) {
482 if (!sslconn->dc->proxy_enabled) {
487 if (mySrvConfig(sslconn->server)->enabled != SSL_ENABLED_TRUE) {
493 if (mySrvConfig(c->base_server)->enabled != SSL_ENABLED_TRUE) {
500 static int ssl_engine_set(conn_rec *c,
501 ap_conf_vector_t *per_dir_config,
502 int proxy, int enable)
508 sslconn = ssl_init_connection_ctx(c, per_dir_config);
509 sslconn->is_proxy = 1;
512 sslconn = myConnConfig(c);
515 status = ssl_engine_status(c, sslconn);
517 if (proxy && status == DECLINED) {
519 SSLSrvConfigRec *sc = mySrvConfig(sslconn->server);
520 ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, c, APLOGNO(01961)
521 "SSL Proxy requested for %s but not enabled "
522 "[Hint: SSLProxyEngine]", sc->vhost_id);
524 sslconn->disabled = 1;
527 sslconn->disabled = !enable;
530 return status != DECLINED;
533 static int ssl_proxy_enable(conn_rec *c)
535 return ssl_engine_set(c, NULL, 1, 1);
538 static int ssl_engine_disable(conn_rec *c)
540 return ssl_engine_set(c, NULL, 0, 0);
543 int ssl_init_ssl_connection(conn_rec *c, request_rec *r)
554 * Create or retrieve SSL context
556 sslconn = ssl_init_connection_ctx(c, r ? r->per_dir_config : NULL);
557 server = sslconn->server;
558 sc = mySrvConfig(server);
561 * Seed the Pseudo Random Number Generator (PRNG)
563 ssl_rand_seed(server, c->pool, SSL_RSCTX_CONNECT,
564 sslconn->is_proxy ? "Proxy: " : "Server: ");
566 mctx = myCtxConfig(sslconn, sc);
569 * Create a new SSL connection with the configured server SSL context and
570 * attach this to the socket. Additionally we register this attachment
571 * so we can detach later.
573 if (!(sslconn->ssl = ssl = SSL_new(mctx->ssl_ctx))) {
574 ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, c, APLOGNO(01962)
575 "Unable to create a new SSL connection from the SSL "
577 ssl_log_ssl_error(SSLLOG_MARK, APLOG_ERR, server);
581 return DECLINED; /* XXX */
584 rc = ssl_run_pre_handshake(c, ssl, sslconn->is_proxy ? 1 : 0);
585 if (rc != OK && rc != DECLINED) {
589 vhost_md5 = ap_md5_binary(c->pool, (unsigned char *)sc->vhost_id,
592 if (!SSL_set_session_id_context(ssl, (unsigned char *)vhost_md5,
593 APR_MD5_DIGESTSIZE*2))
595 ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, c, APLOGNO(01963)
596 "Unable to set session id context to '%s'", vhost_md5);
597 ssl_log_ssl_error(SSLLOG_MARK, APLOG_ERR, server);
601 return DECLINED; /* XXX */
604 SSL_set_app_data(ssl, c);
605 modssl_set_app_data2(ssl, NULL); /* will be request_rec */
607 SSL_set_verify_result(ssl, X509_V_OK);
609 ssl_io_filter_init(c, r, ssl);
614 static const char *ssl_hook_http_scheme(const request_rec *r)
616 SSLSrvConfigRec *sc = mySrvConfig(r->server);
618 if (sc->enabled == SSL_ENABLED_FALSE || sc->enabled == SSL_ENABLED_OPTIONAL) {
625 static apr_port_t ssl_hook_default_port(const request_rec *r)
627 SSLSrvConfigRec *sc = mySrvConfig(r->server);
629 if (sc->enabled == SSL_ENABLED_FALSE || sc->enabled == SSL_ENABLED_OPTIONAL) {
636 static int ssl_hook_pre_connection(conn_rec *c, void *csd)
639 SSLConnRec *sslconn = myConnConfig(c);
642 * Immediately stop processing if SSL is disabled for this connection
644 if (ssl_engine_status(c, sslconn) != OK) {
649 sc = mySrvConfig(sslconn->server);
652 sc = mySrvConfig(c->base_server);
656 * Remember the connection information for
657 * later access inside callback functions
660 ap_log_cerror(APLOG_MARK, APLOG_INFO, 0, c, APLOGNO(01964)
661 "Connection to child %ld established "
662 "(server %s)", c->id, sc->vhost_id);
664 return ssl_init_ssl_connection(c, NULL);
667 static int ssl_hook_process_connection(conn_rec* c)
669 SSLConnRec *sslconn = myConnConfig(c);
671 if (sslconn && !sslconn->disabled) {
672 /* On an active SSL connection, let the input filters initialize
673 * themselves which triggers the handshake, which again triggers
674 * all kinds of useful things such as SNI and ALPN.
676 apr_bucket_brigade* temp;
678 temp = apr_brigade_create(c->pool, c->bucket_alloc);
679 ap_get_brigade(c->input_filters, temp,
680 AP_MODE_INIT, APR_BLOCK_READ, 0);
681 apr_brigade_destroy(temp);
688 * the module registration phase
691 static void ssl_register_hooks(apr_pool_t *p)
693 /* ssl_hook_ReadReq needs to use the BrowserMatch settings so must
694 * run after mod_setenvif's post_read_request hook. */
695 static const char *pre_prr[] = { "mod_setenvif.c", NULL };
696 /* The ssl_init_Module post_config hook should run before mod_proxy's
697 * for the ssl proxy main configs to be merged with vhosts' before being
698 * themselves merged with mod_proxy's in proxy_hook_section_post_config.
700 static const char *b_pc[] = { "mod_proxy.c", NULL};
703 ssl_io_filter_register(p);
705 ap_hook_pre_connection(ssl_hook_pre_connection,NULL,NULL, APR_HOOK_MIDDLE);
706 ap_hook_process_connection(ssl_hook_process_connection,
707 NULL, NULL, APR_HOOK_MIDDLE);
708 ap_hook_test_config (ssl_hook_ConfigTest, NULL,NULL, APR_HOOK_MIDDLE);
709 ap_hook_post_config (ssl_init_Module, NULL,b_pc, APR_HOOK_MIDDLE);
710 ap_hook_http_scheme (ssl_hook_http_scheme, NULL,NULL, APR_HOOK_MIDDLE);
711 ap_hook_default_port (ssl_hook_default_port, NULL,NULL, APR_HOOK_MIDDLE);
712 ap_hook_pre_config (ssl_hook_pre_config, NULL,NULL, APR_HOOK_MIDDLE);
713 ap_hook_child_init (ssl_init_Child, NULL,NULL, APR_HOOK_MIDDLE);
714 ap_hook_post_read_request(ssl_hook_ReadReq, pre_prr,NULL, APR_HOOK_MIDDLE);
715 ap_hook_check_access (ssl_hook_Access, NULL,NULL, APR_HOOK_MIDDLE,
716 AP_AUTH_INTERNAL_PER_CONF);
717 ap_hook_check_authn (ssl_hook_UserCheck, NULL,NULL, APR_HOOK_FIRST,
718 AP_AUTH_INTERNAL_PER_CONF);
719 ap_hook_check_authz (ssl_hook_Auth, NULL,NULL, APR_HOOK_MIDDLE,
720 AP_AUTH_INTERNAL_PER_CONF);
721 ap_hook_fixups (ssl_hook_Fixup, NULL,NULL, APR_HOOK_MIDDLE);
723 APR_OPTIONAL_HOOK(proxy, section_post_config,
724 ssl_proxy_section_post_config, NULL, NULL,
729 APR_REGISTER_OPTIONAL_FN(ssl_proxy_enable);
730 APR_REGISTER_OPTIONAL_FN(ssl_engine_disable);
731 APR_REGISTER_OPTIONAL_FN(ssl_engine_set);
733 ap_register_auth_provider(p, AUTHZ_PROVIDER_GROUP, "ssl",
734 AUTHZ_PROVIDER_VERSION,
735 &ssl_authz_provider_require_ssl,
736 AP_AUTH_INTERNAL_PER_CONF);
738 ap_register_auth_provider(p, AUTHZ_PROVIDER_GROUP, "ssl-verify-client",
739 AUTHZ_PROVIDER_VERSION,
740 &ssl_authz_provider_verify_client,
741 AP_AUTH_INTERNAL_PER_CONF);
744 module AP_MODULE_DECLARE_DATA ssl_module = {
745 STANDARD20_MODULE_STUFF,
746 ssl_config_perdir_create, /* create per-dir config structures */
747 ssl_config_perdir_merge, /* merge per-dir config structures */
748 ssl_config_server_create, /* create per-server config structures */
749 ssl_config_server_merge, /* merge per-server config structures */
750 ssl_config_cmds, /* table of configuration directives */
751 ssl_register_hooks /* register hooks */