42extern module AP_MODULE_DECLARE_DATA tls_module;
72 for (
la =
gc->tls_addresses;
la;
la =
la->next) {
74 if (
la->host_port ==
sa->host_port
76 && !
memcmp(
la->host_addr->ipaddr_ptr,
77 la->host_addr->ipaddr_ptr, (
size_t)
la->host_addr->ipaddr_len)) {
109 if (cert_specs && cert_specs->
nelts > 0) {
110 for (
i = 0;
i < cert_specs->
nelts; ++
i) {
115 "Failed to load certificate %d[cert=%s(%d), key=%s(%d)] for %s",
130 conn_rec *
c,
const char *cert_pem,
const char *pkey_pem)
137 memset(&spec, 0,
sizeof(spec));
161 for (
i = 0;
i < cert_files->
nelts; ++
i) {
195 "checking preferred cipher %s: %d",
196 s->server_hostname,
id);
199 "checking preferred cipher %s: %d is known",
200 s->server_hostname,
id);
208 "checking preferred cipher %s: %d is unsupported",
209 s->server_hostname,
id);
226 if (
ciphers ==
gc->proto->supported_cipher_ids) {
232 "Server '%s' has TLS%sCiphersPrefer configured that are not "
233 "supported by rustls. These will not have an effect: %s",
234 s->server_hostname, proxy,
242 "Failed to configure ciphers %s: [%d] %s",
267 "tls ciphers configured[%s]: %s",
299 "init server: complete_cert_specs added %d certs",
cert_adds->nelts);
304 "init server: no certs configured, looking for fallback");
310 "Init: %s will respond with '503 Service Unavailable' for now. There "
311 "are no SSL certificates configured and no other module contributed any.",
316 "Init: %s has no certificates configured. Use 'TLSCertificate' to "
317 "configure a certificate and key file.",
365 "client hello selected key: %s", key_id? key_id :
"unknown");
374 "Failed to select certified key: [%d] %s", (
int)
rr,
err_descr);
395 "TLSClientAuthentication is enabled for %s, but no client CA file is set. "
396 "Use 'TLSClientCA <file>' to specify the trust anchors.",
410 "init server: %s with %d certificates loaded",
423 "",
pc->proxy_pref_ciphers,
pc->proxy_supp_ciphers, &
ciphers);
432 "tls proxy ciphers configured[%s]: %s",
433 pc->defined_in->server_hostname,
448 (void)
p; (void)ptemp;
454 "proxy: will use roots in %s from %s",
455 pc->defined_in->server_hostname,
pc->proxy_ca);
459 "proxy: there is no TLSProxyCA configured in %s which means "
460 "the certificates of remote servers contacted from here will not be trusted.",
461 pc->defined_in->server_hostname);
464 if (
pc->proxy_protocol_min > 0) {
468 "init server: set proxy protocol min version %04x",
pc->proxy_protocol_min);
474 "Init: the minimum proxy protocol version configured for %s (%04x) "
475 "is not supported and version %04x was selected instead.",
476 pc->defined_in->server_hostname,
pc->proxy_protocol_min,
482 "Unable to configure the proxy protocol version for %s: "
483 "neither the configured minimum version (%04x), nor any higher one is "
484 "available.",
pc->defined_in->server_hostname,
pc->proxy_protocol_min);
491 pc->machine_cert_specs,
gc->cert_reg);
510 if (
hello->server_name.len > 0) {
519 for (
i = 0;
i <
hello->signature_schemes.len; ++
i) {
520 n =
hello->signature_schemes.data[
i];
522 "client supports signature scheme: %x", (
int)
n);
529 for (
i = 0;
i <
len; ++
i) {
534 "ALPN: client proposes %d: `%s`", (
int)
i,
protocol);
557 if (!
gc->rustls_hello_config) {
566 "Failed to init generic hello config: [%d] %s", (
int)
rr,
err_descr);
586 for (
s = base_server;
s;
s =
s->
next) {
607 for (
s = base_server;
s;
s =
s->
next) {
637 (void)
p; (void)ptemp;
643 for (
s = base_server;
s;
s =
s->
next) {
655 for (
i = 0;
i <
gc->proxy_configs->nelts; ++
i) {
678 if (!
gc->mod_proxy_post_config_done)
goto cleanup;
783 "setup_outgoing: to %s [ALPN: %s] from configuration in %s"
789 if (
pc->proxy_protocol_min > 0) {
794 if (ciphersuites && ciphersuites->
nelts > 0
798 (
size_t)ciphersuites->
nelts,
821 if (
pc->machine_certified_keys->nelts > 0) {
823 "setup_outgoing: adding %d client certificate", (
int)
pc->machine_certified_keys->nelts);
826 (
size_t)
pc->machine_certified_keys->nelts);
850 "ALPN proxy protocol identifier too long: %s",
p);
866 bytes.data = (
const unsigned char*)proto;
867 bytes.len = strlen(proto);
876 "setup_outgoing: to %s, added %d ALPN protocols from %s",
895 "Failed to init pre_session for outgoing %s to %s: [%d] %s",
913#if AP_MODULE_MAGIC_AT_LEAST(20120211, 109)
920 "tls_core_conn_init: %s for tls: %s",
921 enabled?
"enabled" :
"disabled",
c->base_server->server_hostname);
925 "tls_core_conn_init, not our connection: %s",
926 c->base_server->server_hostname);
966 "Failed to init TLS connection for server %s: [%d] %s",
1011 "ALPN: no protocol selected in server");
1054 "Failed to init session for server %s: [%d] %s",
1063 const rustls_server_config **
pconfig,
1070 const rustls_server_config *config =
NULL;
1085 "Init: the minimum protocol version configured for %s (%04x) "
1086 "is not supported and version %04x was selected instead.",
1093 "Unable to configure the protocol version for %s: "
1094 "neither the configured minimum version (%04x), nor any higher one is "
1165 "Failed to init session for server %s: [%d] %s",
1172 "tls_core_conn_server_init done: %s",
1177 "Failed to init session for server %s",
1204 "vhost_init: virtual host found for SNI '%s'", cc->
sni_hostname);
1209 "vhost_init: virtual host NOT found, but base server[%s] matches SNI '%s'",
1216 "vhost_init: no virtual host found, relaxed SNI checking enabled, SNI '%s'",
1221 "vhost_init: no virtual host, nor base server[%s] matches SNI '%s'",
1229 "vhost_init: no SNI hostname provided by client");
1268 "post handshake, but rustls claims to still be handshaking: %s",
1280 "post handshake, but rustls does not report negotiated cipher suite: %s",
1302 "A client certificate is required, but no acceptable certificate was presented.");
1325 if (!cc->
server || !other)
return 0;
1326 if (cc->
server == other)
return 1;
1337 if (
sk !=
ok)
return 0;
1364 "tls_core_request_check[%s, %d]: %s",
r->
hostname,
1375 "Connection host %s, selected via SNI, and request host %s"
1376 " have incompatible TLS configurations.",
1403 "tls_core_setup_outgoing called");
1404#if AP_MODULE_MAGIC_AT_LEAST(20120211, 109)
1410 "tls_core_setup_outgoing: already disabled");
1416 "tls_core_setup_outgoing: already enabled");
1428 "tls_core_setup_outgoing: TLSProxyEngine not configured");
1437 "tls_core_setup_outgoing returns %s", rv ==
OK?
"OK" :
"DECLINED");
const char apr_size_t len
Small object cache provider interface.
APR general purpose library routines.
#define APLOG_USE_MODULE(foo)
#define ap_get_module_config(v, m)
struct ap_conf_vector_t ap_conf_vector_t
#define ap_set_module_config(v, m, val)
server_rec * ap_server_conf
int ap_ssl_answer_challenge(conn_rec *c, const char *server_name, const char **pcert_pem, const char **pkey_pem)
apr_status_t ap_switch_protocol(conn_rec *c, request_rec *r, server_rec *s, const char *protocol)
const char * ap_get_protocol(conn_rec *c)
apr_status_t ap_ssl_add_cert_files(server_rec *s, apr_pool_t *p, apr_array_header_t *cert_files, apr_array_header_t *key_files)
const char * ap_select_protocol(conn_rec *c, request_rec *r, server_rec *s, const apr_array_header_t *choices)
apr_status_t ap_ssl_add_fallback_cert_files(server_rec *s, apr_pool_t *p, apr_array_header_t *cert_files, apr_array_header_t *key_files)
#define HTTP_SERVICE_UNAVAILABLE
#define HTTP_MISDIRECTED_REQUEST
const char int apr_pool_t * pool
void const char apr_status_t(* cleanup)(void *))
int strcasecmp(const char *a, const char *b)
apr_vformatter_buff_t * c
const char apr_uint32_t * id
#define apr_pcalloc(p, size)
const void apr_size_t bytes
#define APR_ARRAY_PUSH(ary, type)
#define APR_ARRAY_IDX(ary, i, type)
static long gc(server_rec *s)
Structure to store things which are per connection.
A structure that represents the current request.
A structure to be used for Per-vhost config.
A structure to store information for each virtual server.
rustls_connection * rustls_connection
const char * sni_hostname
const char * application_protocol
const char * tls_protocol_name
tls_client_auth_t client_auth
apr_uint16_t tls_protocol_id
const rustls_server_config * rustls_server_config
const rustls_client_config * rustls_client_config
const char * last_error_descr
apr_uint16_t tls_cipher_id
apr_array_header_t * peer_certs
apr_array_header_t * local_keys
const apr_array_header_t * alpn
const char * tls_cipher_name
const rustls_certified_key * key
tls_conf_proxy_t * proxy_config
struct tls_cert_reg_t * cert_reg
struct tls_cert_verifiers_t * verifiers
struct tls_proto_conf_t * proto
const rustls_server_config * rustls_hello_config
apr_array_header_t * certified_keys
tls_client_auth_t client_auth
apr_array_header_t * tls_supp_ciphers
apr_array_header_t * tls_pref_ciphers
apr_array_header_t * cert_specs
const apr_array_header_t * ciphersuites
tls_conf_global_t * global
static const char hello[]
void tls_cache_free(server_rec *s)
apr_status_t tls_cache_init_server(rustls_server_config_builder *builder, server_rec *s)
apr_status_t tls_cache_post_config(apr_pool_t *p, apr_pool_t *ptemp, server_rec *s)
apr_status_t tls_cert_client_verifiers_get_optional(tls_cert_verifiers_t *verifiers, const char *store_file, const rustls_client_cert_verifier **pverifier)
apr_status_t tls_cert_root_stores_get(tls_cert_root_stores_t *stores, const char *store_file, const rustls_root_cert_store **pstore)
void tls_cert_verifiers_clear(tls_cert_verifiers_t *verifiers)
apr_status_t tls_cert_reg_get_certified_key(tls_cert_reg_t *reg, server_rec *s, const tls_cert_spec_t *spec, const rustls_certified_key **pckey)
void tls_cert_root_stores_clear(tls_cert_root_stores_t *stores)
apr_status_t tls_cert_load_cert_key(apr_pool_t *p, const tls_cert_spec_t *spec, const char **pcert_pem, const rustls_certified_key **pckey)
const char * tls_cert_reg_get_id(tls_cert_reg_t *reg, const rustls_certified_key *certified_key)
tls_cert_verifiers_t * tls_cert_verifiers_make(apr_pool_t *p, tls_cert_root_stores_t *stores)
tls_cert_reg_t * tls_cert_reg_make(apr_pool_t *p)
apr_status_t tls_cert_client_verifiers_get(tls_cert_verifiers_t *verifiers, const char *store_file, const rustls_client_cert_verifier **pverifier)
tls_cert_root_stores_t * tls_cert_root_stores_make(apr_pool_t *p)
apr_status_t tls_conf_dir_apply_defaults(tls_conf_dir_t *dc, apr_pool_t *p)
tls_conf_proxy_t * tls_conf_proxy_make(apr_pool_t *p, tls_conf_dir_t *dc, tls_conf_global_t *gc, server_rec *s)
tls_conf_server_t * tls_conf_server_get(server_rec *s)
apr_status_t tls_conf_server_apply_defaults(tls_conf_server_t *sc, apr_pool_t *p)
tls_conf_dir_t * tls_conf_dir_server_get(server_rec *s)
@ TLS_CONF_ST_OUTGOING_DONE
@ TLS_CONF_ST_INCOMING_DONE
@ TLS_CLIENT_AUTH_REQUIRED
static apr_status_t load_certified_keys(apr_array_header_t *keys, server_rec *s, apr_array_header_t *cert_specs, tls_cert_reg_t *cert_reg)
static apr_status_t build_server_connection(rustls_connection **pconnection, const rustls_server_config **pconfig, conn_rec *c)
apr_status_t tls_core_conn_post_handshake(conn_rec *c)
static apr_status_t tls_core_free(void *data)
static apr_status_t use_local_key(conn_rec *c, const char *cert_pem, const char *pkey_pem)
apr_status_t tls_core_conn_init(conn_rec *c)
apr_status_t tls_core_init(apr_pool_t *p, apr_pool_t *ptemp, server_rec *base_server)
static const rustls_certified_key * extract_client_hello_values(void *userdata, const rustls_client_hello *hello)
int tls_core_setup_outgoing(conn_rec *c)
static int we_listen_on(tls_conf_global_t *gc, server_rec *s, tls_conf_server_t *sc)
static apr_status_t calc_ciphers(apr_pool_t *pool, server_rec *s, tls_conf_global_t *gc, const char *proxy, apr_array_header_t *pref_ciphers, apr_array_header_t *supp_ciphers, const apr_array_header_t **pciphers)
static int tls_conn_compatible_for(tls_conf_conn_t *cc, server_rec *other)
static apr_status_t init_outgoing_connection(conn_rec *c)
void tls_core_conn_bind(conn_rec *c, ap_conf_vector_t *dir_conf)
static void add_file_specs(apr_array_header_t *certificates, apr_pool_t *p, apr_array_header_t *cert_files, apr_array_header_t *key_files)
static tls_conf_conn_t * cc_get_or_make(conn_rec *c)
static apr_status_t setup_hello_config(apr_pool_t *p, server_rec *base_server, tls_conf_global_t *gc)
apr_status_t tls_core_error(conn_rec *c, rustls_result rr, const char **perrstr)
void tls_core_conn_disable(conn_rec *c)
static apr_status_t select_application_protocol(conn_rec *c, server_rec *s, rustls_server_config_builder *builder)
static apr_status_t server_conf_setup(apr_pool_t *p, apr_pool_t *ptemp, tls_conf_server_t *sc, tls_conf_global_t *gc)
static apr_status_t init_outgoing(apr_pool_t *p, apr_pool_t *ptemp, server_rec *base_server)
int tls_conn_check_ssl(conn_rec *c)
int tls_core_request_check(request_rec *r)
static apr_status_t proxy_conf_setup(apr_pool_t *p, apr_pool_t *ptemp, tls_conf_proxy_t *pc, tls_conf_global_t *gc)
static int find_vhost(void *sni_hostname, conn_rec *c, server_rec *s)
static apr_status_t get_server_ciphersuites(const apr_array_header_t **pciphersuites, apr_pool_t *pool, tls_conf_server_t *sc)
int tls_core_pre_conn_init(conn_rec *c)
void tls_conf_conn_set(conn_rec *c, tls_conf_conn_t *cc)
static apr_status_t tls_core_conn_free(void *data)
static apr_status_t get_proxy_ciphers(const apr_array_header_t **pciphersuites, apr_pool_t *pool, tls_conf_proxy_t *pc)
static apr_array_header_t * complete_cert_specs(apr_pool_t *p, tls_conf_server_t *sc)
static const rustls_certified_key * select_certified_key(void *userdata, const rustls_client_hello *hello)
tls_conf_conn_t * tls_conf_conn_get(conn_rec *c)
static apr_status_t init_incoming(apr_pool_t *p, apr_pool_t *ptemp, server_rec *base_server)
apr_status_t tls_core_conn_seen_client_hello(conn_rec *c)
#define TLS_CONN_ST_IS_ENABLED(cc)
@ TLS_CONN_ST_CLIENT_HELLO
apr_status_t tls_ocsp_prime_certs(tls_conf_global_t *gc, apr_pool_t *p, server_rec *s)
apr_status_t tls_ocsp_update_key(conn_rec *c, const rustls_certified_key *certified_key, const rustls_certified_key **pkey_out)
const char * tls_proto_get_cipher_names(tls_proto_conf_t *conf, const apr_array_header_t *ciphers, apr_pool_t *pool)
int tls_proto_is_cipher_supported(tls_proto_conf_t *conf, apr_uint16_t cipher)
const char * tls_proto_get_version_name(tls_proto_conf_t *conf, apr_uint16_t id, apr_pool_t *pool)
apr_array_header_t * tls_proto_create_versions_plus(tls_proto_conf_t *conf, apr_uint16_t min_version, apr_pool_t *pool)
apr_array_header_t * tls_proto_get_rustls_suites(tls_proto_conf_t *conf, const apr_array_header_t *ids, apr_pool_t *pool)
apr_status_t tls_proto_post_config(apr_pool_t *pool, apr_pool_t *ptemp, server_rec *s)
const char * tls_proto_get_cipher_name(tls_proto_conf_t *conf, apr_uint16_t id, apr_pool_t *pool)
int tls_util_name_matches_server(const char *name, server_rec *s)
apr_status_t tls_util_rustls_error(apr_pool_t *p, rustls_result rr, const char **perr_descr)
const apr_array_header_t * tls_util_array_uint16_remove(apr_pool_t *pool, const apr_array_header_t *from, const apr_array_header_t *others)
int tls_util_array_uint16_contains(const apr_array_header_t *a, apr_uint16_t n)
apr_status_t tls_var_handshake_done(conn_rec *c)
int ap_vhost_iterate_given_conn(conn_rec *conn, ap_vhost_iterate_conn_cb func_cb, void *baton)