mod_ssl.c revision 77504f17963a8dd941a921d9ddfa25ddb0f348d6
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* _ _
* _ __ ___ ___ __| | ___ ___| | mod_ssl
* | '_ ` _ \ / _ \ / _` | / __/ __| | Apache Interface to OpenSSL
* | | | | | | (_) | (_| | \__ \__ \ |
* |_| |_| |_|\___/ \__,_|___|___/___/_|
* |_____|
* Apache API interface structures
*/
#include "ssl_private.h"
#include "mod_ssl.h"
#include "util_md5.h"
#include "util_mutex.h"
#include "ap_provider.h"
#include <assert.h>
/*
* the table of configuration directives we provide
*/
#define AP_END_CMD { NULL }
static const command_rec ssl_config_cmds[] = {
/*
* Global (main-server) context configuration directives
*/
"SSL dialog mechanism for the pass phrase query "
"('builtin', '|/path/to/pipe_program', "
"or 'exec:/path/to/cgi_program')")
"SSL Session Cache storage "
#if defined(HAVE_OPENSSL_ENGINE_H) && defined(HAVE_ENGINE_INIT)
"SSL external Crypto Device usage "
"('builtin', '...')")
#endif
"SSL Pseudo Random Number Generator (PRNG) seeding source "
"('startup|connect builtin|file:/path|exec:/path [bytes]')")
/*
* Per-server context configuration directives
*/
"SSL switch for the protocol engine "
"('on', 'off')")
"Enable FIPS-140 mode "
"(`on', `off')")
"Colon-delimited list of permitted SSL Ciphers "
"('XXX:...:XXX' - see manual)")
"SSL Server Certificate file "
"SSL Server Private Key file "
"SSL Server CA Certificate Chain file "
"PKCS#7 file containing server certificate and chain"
"SSL CA Certificate path "
"SSL CA Certificate file "
"SSL CA Distinguished Name path "
"SSL CA Distinguished Name file "
"SSL CA Certificate Revocation List (CRL) path "
"SSL CA Certificate Revocation List (CRL) file "
"SSL CA Certificate Revocation List (CRL) checking mode")
"SSL Client verify type "
"('none', 'optional', 'require', 'optional_no_ca')")
"SSL Client verify depth "
"('N' - number of intermediate certificates)")
"SSL Session Cache object lifetime "
"('N' - number of seconds)")
"Enable or disable various SSL protocols"
"('[+-][SSLv2|SSLv3|TLSv1] ...' - see manual)")
"Use the server's cipher ordering preference")
"Enable support for insecure renegotiation")
"Set user name to SSL variable value")
"Strict SNI virtual host checking")
/*
* Proxy configuration for remote SSL connections
*/
"SSL switch for the proxy protocol engine "
"('on', 'off')")
"SSL Proxy: enable or disable SSL protocol flavors "
"('[+-][SSLv2|SSLv3|TLSv1] ...' - see manual)")
"SSL Proxy: colon-delimited list of permitted SSL ciphers "
"('XXX:...:XXX' - see manual)")
"SSL Proxy: whether to verify the remote certificate "
"('on' or 'off')")
"SSL Proxy: maximum certificate verification depth "
"('N' - number of intermediate certificates)")
"SSL Proxy: file containing server certificates "
"SSL Proxy: directory containing server certificates "
"SSL Proxy: CA Certificate Revocation List (CRL) path "
"SSL Proxy: CA Certificate Revocation List (CRL) file "
"SSL Proxy: CA Certificate Revocation List (CRL) checking mode")
"SSL Proxy: file containing client certificates "
"SSL Proxy: directory containing client certificates "
"SSL Proxy: file containing issuing certificates "
"of the client certificate "
"SSL Proxy: check the peers certificate expiration date")
"SSL Proxy: check the peers certificate CN")
/*
* Per-directory context configuration directives
*/
"Set one or more options to configure the SSL engine"
"('[+-]option[=value] ...' - see manual)")
"Require the SSL protocol for the per-directory context "
"(no arguments)")
"Require a boolean expression to evaluate to true for granting access"
"(arbitrary complex boolean expression - see manual)")
"Configure the amount of memory that will be used for buffering the "
"request body if a per-location SSL renegotiation is required due to "
"changed access control requirements")
"Enable use of OCSP to verify certificate revocation ('on', 'off')")
"URL of the default OCSP Responder")
"Force use of the default responder URL ('on', 'off')")
"Maximum time difference in OCSP responses")
"Maximum age of OCSP responses")
"OCSP responder query timeout")
#ifdef HAVE_OCSP_STAPLING
/*
* OCSP Stapling options
*/
"SSL Stapling Response Cache storage "
"SSL switch for the OCSP Stapling protocol " "(`on', `off')")
"SSL stapling option for maximum time difference in OCSP responses")
"SSL stapling option for OCSP responder timeout")
"SSL stapling option for maximum age of OCSP responses")
"SSL stapling option for normal OCSP Response Cache Lifetime")
"SSL stapling switch to return Status Errors Back to Client"
"(`on', `off')")
"SSL stapling switch to send tryLater response to client on error "
"(`on', `off')")
"SSL stapling option for OCSP Response Error Cache Lifetime")
"SSL stapling option to Force the OCSP Stapling URL")
#endif
/* Deprecated directives. */
"SSLLog directive is no longer supported - use ErrorLog."),
"SSLLogLevel directive is no longer supported - use LogLevel."),
};
/*
* the various processing hooks
*/
{
/*
* Try to kill the internals of the SSL library.
*/
/* Corresponds to OPENSSL_load_builtin_modules():
* XXX: borrowed from apps.h, but why not CONF_modules_free()
* which also invokes CONF_modules_finish()?
*/
/* Corresponds to SSL_library_init: */
EVP_cleanup();
#endif
ERR_remove_state(0);
/* Don't call ERR_free_strings here; ERR_load_*_strings only
* actually load the error strings once per process due to static
* variable abuse in OpenSSL. */
/* Also don't call CRYPTO_cleanup_all_ex_data here; any registered
* ex_data indices may have been cached in static variables in
* OpenSSL; removing them may cause havoc. Notably, with OpenSSL
* versions >= 0.9.8f, COMP_CTX cleanups would not be run, which
* could result in a per-connection memory leak (!). */
/*
* TODO: determine somewhere we can safely shove out diagnostics
* (when enabled) at this late stage in the game:
* CRYPTO_mem_leaks_fp(stderr);
*/
return APR_SUCCESS;
}
{
/* We must register the library in full, to ensure our configuration
* code can successfully test the SSL environment.
*/
#endif
/*
* Let us cleanup the ssl library when the module is unloaded
*/
/* Register us to handle mod_log_config %c/%x variables */
/* Register to handle mod_status status page generation */
/* Register mutex type names so they can be configured with Mutex */
#ifdef HAVE_OCSP_STAPLING
#endif
return OK;
}
{
if (sslconn) {
return sslconn;
}
myConnConfigSet(c, sslconn);
return sslconn;
}
int ssl_proxy_enable(conn_rec *c)
{
if (!sc->proxy_enabled) {
"SSL Proxy requested for %s but not enabled "
return 0;
}
return 1;
}
int ssl_engine_disable(conn_rec *c)
{
if (sslconn) {
}
else {
}
return 0;
}
return 1;
}
{
char *vhost_md5;
if (!sslconn) {
}
/*
* Seed the Pseudo Random Number Generator (PRNG)
*/
/*
* Create a new SSL connection with the configured server SSL context and
* attach this to the socket. Additionally we register this attachment
* so we can detach later.
*/
"Unable to create a new SSL connection from the SSL "
"context");
c->aborted = 1;
return DECLINED; /* XXX */
}
sc->vhost_id_len);
{
"Unable to set session id context to '%s'", vhost_md5);
c->aborted = 1;
return DECLINED; /* XXX */
}
SSL_set_app_data(ssl, c);
/*
* Configure callbacks for SSL connection
*/
#ifndef OPENSSL_NO_EC
#endif
ssl_io_filter_init(c, r, ssl);
return APR_SUCCESS;
}
static const char *ssl_hook_http_scheme(const request_rec *r)
{
return NULL;
}
return "https";
}
{
return 0;
}
return 443;
}
{
if (sslconn) {
}
else {
}
/*
* Immediately stop processing if SSL is disabled for this connection
*/
{
return DECLINED;
}
/*
* Create SSL context
*/
if (!sslconn) {
}
return DECLINED;
}
/*
* Remember the connection information for
* later access inside callback functions
*/
"Connection to child %ld established "
return ssl_init_ssl_connection(c, NULL);
}
/*
* the module registration phase
*/
static void ssl_register_hooks(apr_pool_t *p)
{
/* ssl_hook_ReadReq needs to use the BrowserMatch settings so must
* run after mod_setenvif's post_read_request hook. */
ssl_var_register(p);
}
ssl_config_perdir_create, /* create per-dir config structures */
ssl_config_perdir_merge, /* merge per-dir config structures */
ssl_config_server_create, /* create per-server config structures */
ssl_config_server_merge, /* merge per-server config structures */
ssl_config_cmds, /* table of configuration directives */
ssl_register_hooks /* register hooks */
};