Apache HTTPD
Functions | Variables
tls_core.c File Reference
module tls_module
#include <assert.h>
#include <apr_lib.h>
#include <apr_strings.h>
#include <apr_network_io.h>
#include <httpd.h>
#include <http_core.h>
#include <http_log.h>
#include <http_protocol.h>
#include <http_ssl.h>
#include <http_vhost.h>
#include <http_main.h>
#include <ap_socache.h>
#include <rustls.h>
#include "tls_proto.h"
#include "tls_cert.h"
#include "tls_conf.h"
#include "tls_core.h"
#include "tls_ocsp.h"
#include "tls_util.h"
#include "tls_cache.h"
#include "tls_var.h"

Go to the source code of this file.

Functions

tls_conf_conn_ttls_conf_conn_get (conn_rec *c)
 
void tls_conf_conn_set (conn_rec *c, tls_conf_conn_t *cc)
 
int tls_conn_check_ssl (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 tls_core_free (void *data)
 
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 use_local_key (conn_rec *c, const char *cert_pem, const char *pkey_pem)
 
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 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 apr_status_t get_server_ciphersuites (const apr_array_header_t **pciphersuites, apr_pool_t *pool, tls_conf_server_t *sc)
 
static apr_array_header_tcomplete_cert_specs (apr_pool_t *p, tls_conf_server_t *sc)
 
static const rustls_certified_keyselect_certified_key (void *userdata, const rustls_client_hello *hello)
 
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 get_proxy_ciphers (const apr_array_header_t **pciphersuites, apr_pool_t *pool, tls_conf_proxy_t *pc)
 
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 const rustls_certified_keyextract_client_hello_values (void *userdata, const rustls_client_hello *hello)
 
static apr_status_t setup_hello_config (apr_pool_t *p, server_rec *base_server, tls_conf_global_t *gc)
 
static apr_status_t init_incoming (apr_pool_t *p, apr_pool_t *ptemp, server_rec *base_server)
 
static apr_status_t init_outgoing (apr_pool_t *p, apr_pool_t *ptemp, server_rec *base_server)
 
apr_status_t tls_core_init (apr_pool_t *p, apr_pool_t *ptemp, server_rec *base_server)
 
static apr_status_t tls_core_conn_free (void *data)
 
static tls_conf_conn_tcc_get_or_make (conn_rec *c)
 
void tls_core_conn_disable (conn_rec *c)
 
void tls_core_conn_bind (conn_rec *c, ap_conf_vector_t *dir_conf)
 
static apr_status_t init_outgoing_connection (conn_rec *c)
 
int tls_core_pre_conn_init (conn_rec *c)
 
apr_status_t tls_core_conn_init (conn_rec *c)
 
static int find_vhost (void *sni_hostname, conn_rec *c, server_rec *s)
 
static apr_status_t select_application_protocol (conn_rec *c, server_rec *s, rustls_server_config_builder *builder)
 
static apr_status_t build_server_connection (rustls_connection **pconnection, const rustls_server_config **pconfig, conn_rec *c)
 
apr_status_t tls_core_conn_seen_client_hello (conn_rec *c)
 
apr_status_t tls_core_conn_post_handshake (conn_rec *c)
 
static int tls_conn_compatible_for (tls_conf_conn_t *cc, server_rec *other)
 
int tls_core_request_check (request_rec *r)
 
apr_status_t tls_core_error (conn_rec *c, rustls_result rr, const char **perrstr)
 
int tls_core_setup_outgoing (conn_rec *c)
 

Variables

static int *const aplog_module_index = &( tls_module.module_index)
 

Function Documentation

◆ add_file_specs()

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

Definition at line 152 of file tls_core.c.

◆ build_server_connection()

static apr_status_t build_server_connection ( rustls_connection **  pconnection,
const rustls_server_config **  pconfig,
conn_rec c 
)
static

Definition at line 1062 of file tls_core.c.

◆ calc_ciphers()

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

Definition at line 169 of file tls_core.c.

◆ cc_get_or_make()

static tls_conf_conn_t * cc_get_or_make ( conn_rec c)
static

Definition at line 731 of file tls_core.c.

◆ complete_cert_specs()

static apr_array_header_t * complete_cert_specs ( apr_pool_t p,
tls_conf_server_t sc 
)
static

Definition at line 278 of file tls_core.c.

◆ extract_client_hello_values()

static const rustls_certified_key * extract_client_hello_values ( void *  userdata,
const rustls_client_hello hello 
)
static

Definition at line 499 of file tls_core.c.

◆ find_vhost()

static int find_vhost ( void *  sni_hostname,
conn_rec c,
server_rec s 
)
static

Definition at line 975 of file tls_core.c.

◆ get_proxy_ciphers()

static apr_status_t get_proxy_ciphers ( const apr_array_header_t **  pciphersuites,
apr_pool_t pool,
tls_conf_proxy_t pc 
)
static

Definition at line 416 of file tls_core.c.

◆ get_server_ciphersuites()

static apr_status_t get_server_ciphersuites ( const apr_array_header_t **  pciphersuites,
apr_pool_t pool,
tls_conf_server_t sc 
)
static

Definition at line 249 of file tls_core.c.

◆ init_incoming()

static apr_status_t init_incoming ( apr_pool_t p,
apr_pool_t ptemp,
server_rec base_server 
)
static

Definition at line 572 of file tls_core.c.

◆ init_outgoing()

static apr_status_t init_outgoing ( apr_pool_t p,
apr_pool_t ptemp,
server_rec base_server 
)
static

Definition at line 627 of file tls_core.c.

◆ init_outgoing_connection()

static apr_status_t init_outgoing_connection ( conn_rec c)
static

Definition at line 761 of file tls_core.c.

◆ load_certified_keys()

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

Definition at line 99 of file tls_core.c.

◆ proxy_conf_setup()

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

Definition at line 443 of file tls_core.c.

◆ select_application_protocol()

static apr_status_t select_application_protocol ( conn_rec c,
server_rec s,
rustls_server_config_builder builder 
)
static

Definition at line 985 of file tls_core.c.

◆ select_certified_key()

static const rustls_certified_key * select_certified_key ( void *  userdata,
const rustls_client_hello hello 
)
static

Definition at line 324 of file tls_core.c.

◆ server_conf_setup()

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

Definition at line 379 of file tls_core.c.

◆ setup_hello_config()

static apr_status_t setup_hello_config ( apr_pool_t p,
server_rec base_server,
tls_conf_global_t gc 
)
static

Definition at line 545 of file tls_core.c.

◆ tls_conf_conn_get()

tls_conf_conn_t * tls_conf_conn_get ( conn_rec c)

Definition at line 45 of file tls_core.c.

◆ tls_conf_conn_set()

void tls_conf_conn_set ( conn_rec c,
tls_conf_conn_t cc 
)

Definition at line 50 of file tls_core.c.

◆ tls_conn_check_ssl()

int tls_conn_check_ssl ( conn_rec c)

< Module has handled this stage.

< Module declines to handle

Definition at line 55 of file tls_core.c.

◆ tls_conn_compatible_for()

static int tls_conn_compatible_for ( tls_conf_conn_t cc,
server_rec other 
)
static

Return != 0, if a connection also serve requests for server <other>.

Definition at line 1314 of file tls_core.c.

◆ tls_core_conn_bind()

void tls_core_conn_bind ( conn_rec c,
ap_conf_vector_t dir_conf 
)

Supply a directory configuration for the connection to work with. This maybe NULL. This can be called several times during the lifetime of a connection and must not change the current TLS state.

Parameters
cthe connection
dir_confoptional directory configuration that applies

Definition at line 754 of file tls_core.c.

◆ tls_core_conn_disable()

void tls_core_conn_disable ( conn_rec c)

Disable TLS on a new connection. Will do nothing on already initialized connections.

Parameters
ca new connection

Definition at line 745 of file tls_core.c.

◆ tls_core_conn_free()

static apr_status_t tls_core_conn_free ( void *  data)
static

Definition at line 697 of file tls_core.c.

◆ tls_core_conn_init()

apr_status_t tls_core_conn_init ( conn_rec c)

Initialize the module for a TLS enabled connection.

Parameters
ca new connection

Definition at line 934 of file tls_core.c.

◆ tls_core_conn_post_handshake()

apr_status_t tls_core_conn_post_handshake ( conn_rec c)

The TLS handshake for the connection has been successfully performed. This means that TLS related properties, such as TLS version and cipher, are known and the props in tls_conf_conn_t of the connection can be set.

Definition at line 1257 of file tls_core.c.

◆ tls_core_conn_seen_client_hello()

apr_status_t tls_core_conn_seen_client_hello ( conn_rec c)

Called when the ClientHello has been received and values from it have been extracted into the tls_conf_conn_t of the connection.

Decides:

  • which server_rec this connection is for (SNI)
  • which application protocol to use (ALPN) This may be unsuccessful for several reasons. The SNI from the client may not be known or the selected server has not certificates available. etc. On success, a proper rustls_connection will have been created and set in the tls_conf_conn_t of the connection.

Definition at line 1186 of file tls_core.c.

◆ tls_core_error()

apr_status_t tls_core_error ( conn_rec c,
rustls_result  rr,
const char **  perrstr 
)

A Rustls error happened while processing the connection. Look up an error description, determine the apr_status_t to use for it and remember this as the last error at tls_conf_conn_t.

Definition at line 1384 of file tls_core.c.

◆ tls_core_free()

static apr_status_t tls_core_free ( void *  data)
static

Definition at line 86 of file tls_core.c.

◆ tls_core_init()

apr_status_t tls_core_init ( apr_pool_t p,
apr_pool_t ptemp,
server_rec base_server 
)

Initialize the module's global and server specific settings. This runs in Apache's "post-config" phase, meaning the configuration has been read and checked for syntactic and other easily verifiable errors and now it is time to load everything in and make it ready for traffic.

a memory pool staying with us the whole time until the server stops/reloads. <ptemp> a temporary pool as a scratch buffer that will be destroyed shortly after. <base_server> the server for the global configuration which links -> next to all contained virtual hosts configured.

Definition at line 665 of file tls_core.c.

◆ tls_core_pre_conn_init()

int tls_core_pre_conn_init ( conn_rec c)

Initialize the tls_conf_connt_t for the connection and decide if TLS is enabled or not.

Returns
OK if enabled, DECLINED otherwise

< Module has handled this stage.

< Module declines to handle

Definition at line 904 of file tls_core.c.

◆ tls_core_request_check()

int tls_core_request_check ( request_rec r)

After a request has been read, but before processing is started, we check if everything looks good to us:

  • was an SNI hostname provided by the client when we have vhosts to choose from? if not, we deny it.
  • if the SNI hostname and request host are not the same, are they - from TLS point of view - 'compatible' enough? For example, if one server requires client certificates and the other not (or with different settings), such a request will also be denied. returns DECLINED if everything is ok, otherwise an HTTP response code to generate an error page for.

< Module declines to handle

Definition at line 1348 of file tls_core.c.

◆ tls_core_setup_outgoing()

int tls_core_setup_outgoing ( conn_rec c)

Determine if we handle the TLS for an outgoing connection or not.

Parameters
cthe connection
Returns
OK if we handle the TLS, DECLINED otherwise.

< Module declines to handle

< Module has handled this stage.

< Module has handled this stage.

< Module has handled this stage.

Definition at line 1397 of file tls_core.c.

◆ use_local_key()

static apr_status_t use_local_key ( conn_rec c,
const char cert_pem,
const char pkey_pem 
)
static

Definition at line 129 of file tls_core.c.

◆ we_listen_on()

static int we_listen_on ( tls_conf_global_t gc,
server_rec s,
tls_conf_server_t sc 
)
static

Definition at line 64 of file tls_core.c.

Variable Documentation

◆ aplog_module_index

int* const aplog_module_index = &( tls_module.module_index)
static

Definition at line 43 of file tls_core.c.