mod_ssl.c revision f84d3d83a741c21154d42e0ebdec9b9b37efeedc
/* Copyright 2001-2004 The Apache Software Foundation
*
* Licensed 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 <assert.h>
/*
* the table of configuration directives we provide
*/
#define AP_END_CMD { NULL }
const char ssl_valid_ssl_mutex_string[] =
"Valid SSLMutex mechanisms are: `none', `default'"
#endif
#endif
#if APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM)
", `sysvsem'"
#endif
", `posixsem'"
#endif
", `pthread'"
#endif
#endif
", `sem'"
#endif
" ";
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')")
"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 "
"SSL CA Certificate path "
"SSL CA Certificate file "
"SSL CA Certificate Revocation List (CRL) path "
"SSL CA Certificate Revocation List (CRL) file "
"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")
"Set user name to SSL variable value")
/*
* 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: file containing client certificates "
"SSL Proxy: directory containing client certificates "
/*
* 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)")
/* 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.
*/
#ifdef HAVE_OPENSSL
#if OPENSSL_VERSION_NUMBER >= 0x00907001
/* Corresponds to OPENSSL_load_builtin_modules():
* XXX: borrowed from apps.h, but why not CONF_modules_free()
* which also invokes CONF_modules_finish()?
*/
#endif
#endif
/* Corresponds to SSL_library_init: */
EVP_cleanup();
#endif
#ifdef HAVE_OPENSSL
#if OPENSSL_VERSION_NUMBER >= 0x00907001
#endif
#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. */
/*
* 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.
*/
#ifdef HAVE_OPENSSL
#endif
#endif
#ifdef HAVE_OPENSSL
#if OPENSSL_VERSION_NUMBER >= 0x00907001
#endif
#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 */
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)
{
return 0;
}
return 1;
}
int ssl_init_ssl_connection(conn_rec *c)
{
char *vhost_md5;
/*
* Seed the Pseudo Random Number Generator (PRNG)
*/
if (!sslconn) {
}
/*
* 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
*/
ssl_io_filter_init(c, ssl);
return APR_SUCCESS;
}
static const char *ssl_hook_http_method(const request_rec *r)
{
return NULL;
}
return "https";
}
{
return 0;
}
return 443;
}
{
/*
* 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);
}
static void ssl_hook_Insert_Filter(request_rec *r)
{
}
}
/*
* the module registration phase
*/
static void ssl_register_hooks(apr_pool_t *p)
{
/* ap_hook_handler (ssl_hook_Upgrade, NULL,NULL, APR_HOOK_MIDDLE); */
}
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 */
};