Apache2
tls_core.h
Go to the documentation of this file.
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 #ifndef tls_core_h
17 #define tls_core_h
18 
19 /* The module's state handling of a connection in normal chronological order,
20  */
21 typedef enum {
22  TLS_CONN_ST_INIT, /* being initialized */
23  TLS_CONN_ST_DISABLED, /* TLS is disabled here */
24  TLS_CONN_ST_CLIENT_HELLO, /* TLS is enabled, prep handshake */
25  TLS_CONN_ST_HANDSHAKE, /* TLS is enabled, handshake ongonig */
26  TLS_CONN_ST_TRAFFIC, /* TLS is enabled, handshake done */
27  TLS_CONN_ST_NOTIFIED, /* TLS is enabled, notification to end sent */
28  TLS_CONN_ST_DONE, /* TLS is enabled, TLS has shut down */
30 
31 #define TLS_CONN_ST_IS_ENABLED(cc) (cc && cc->state >= TLS_CONN_ST_CLIENT_HELLO)
32 
33 struct tls_filter_ctx_t;
34 
35 /* The modules configuration for a connection. Created at connection
36  * start and mutable during the lifetime of the connection.
37  * (A conn_rec is only ever processed by one thread at a time.)
38  */
39 typedef struct {
40  server_rec *server; /* the server_rec selected for this connection,
41  * initially c->base_server, to be negotiated via SNI. */
42  tls_conf_dir_t *dc; /* directory config applying here */
44  int outgoing; /* != 0 iff outgoing connection (redundant once c->outgoing is everywhere) */
45  int service_unavailable; /* we 503 all requests on this connection */
46  tls_client_auth_t client_auth; /* how client authentication with certificates is used */
47  int client_hello_seen; /* the client hello has been inspected */
48 
49  rustls_connection *rustls_connection; /* the session used on this connection or NULL */
50  const rustls_server_config *rustls_server_config; /* the config made for this connection (incoming) or NULL */
51  const rustls_client_config *rustls_client_config; /* the config made for this connection (outgoing) or NULL */
52  struct tls_filter_ctx_t *filter_ctx; /* the context used by this connection's tls filters */
53 
54  apr_array_header_t *local_keys; /* rustls_certified_key* array of connection specific keys */
55  const rustls_certified_key *key; /* the key selected for the session */
56  int key_cloned; /* != 0 iff the key is a unique clone, to be freed */
57  apr_array_header_t *peer_certs; /* handshaked peer ceritificates or NULL */
58  const char *sni_hostname; /* the SNI value from the client hello, or NULL */
59  const apr_array_header_t *alpn; /* the protocols proposed via ALPN by the client */
60  const char *application_protocol; /* the ALPN selected protocol or NULL */
61 
62  int session_id_cache_hit; /* if a submitted session id was found in our cache */
63 
64  apr_uint16_t tls_protocol_id; /* the TLS version negotiated */
65  const char *tls_protocol_name; /* the name of the TLS version negotiated */
66  apr_uint16_t tls_cipher_id; /* the TLS cipher suite negotiated */
67  const char *tls_cipher_name; /* the name of TLS cipher suite negotiated */
68 
69  const char *user_name; /* != NULL if we derived a TLSUserName from the client_cert */
70  apr_table_t *subprocess_env; /* common TLS variables for this connection */
71 
72  rustls_result last_error;
73  const char *last_error_descr;
74 
76 
77 /* Get the connection specific module configuration. */
79 
80 /* Set the module configuration for a connection. */
82 
83 /* Return OK iff this connection is a TSL connection (or a secondary on a TLS connection). */
85 
97 
103 
112 
119 
126 
132 
147 
155 
169 
175 apr_status_t tls_core_error(conn_rec *c, rustls_result rr, const char **perrstr);
176 
183 
184 #endif /* tls_core_h */
struct ap_conf_vector_t ap_conf_vector_t
Definition: http_config.h:512
request_rec * r
Definition: mod_dav.h:518
int apr_status_t
Definition: apr_errno.h:44
unsigned short apr_uint16_t
Definition: apr.h:345
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
struct apr_table_t apr_table_t
Definition: apr_tables.h:56
Definition: apr_tables.h:62
Structure to store things which are per connection.
Definition: httpd.h:1193
A structure that represents the current request.
Definition: httpd.h:856
A structure to store information for each virtual server.
Definition: httpd.h:1382
Definition: tls_core.h:39
struct tls_filter_ctx_t * filter_ctx
Definition: tls_core.h:52
rustls_connection * rustls_connection
Definition: tls_core.h:49
const char * sni_hostname
Definition: tls_core.h:58
const char * application_protocol
Definition: tls_core.h:60
const char * tls_protocol_name
Definition: tls_core.h:65
tls_client_auth_t client_auth
Definition: tls_core.h:46
int session_id_cache_hit
Definition: tls_core.h:62
server_rec * server
Definition: tls_core.h:40
apr_uint16_t tls_protocol_id
Definition: tls_core.h:64
const rustls_server_config * rustls_server_config
Definition: tls_core.h:50
const rustls_client_config * rustls_client_config
Definition: tls_core.h:51
int client_hello_seen
Definition: tls_core.h:47
tls_conf_dir_t * dc
Definition: tls_core.h:42
const char * last_error_descr
Definition: tls_core.h:73
apr_uint16_t tls_cipher_id
Definition: tls_core.h:66
const char * user_name
Definition: tls_core.h:69
apr_array_header_t * peer_certs
Definition: tls_core.h:57
int service_unavailable
Definition: tls_core.h:45
tls_conn_state_t state
Definition: tls_core.h:43
apr_array_header_t * local_keys
Definition: tls_core.h:54
const apr_array_header_t * alpn
Definition: tls_core.h:59
const char * tls_cipher_name
Definition: tls_core.h:67
const rustls_certified_key * key
Definition: tls_core.h:55
apr_table_t * subprocess_env
Definition: tls_core.h:70
int key_cloned
Definition: tls_core.h:56
int outgoing
Definition: tls_core.h:44
rustls_result last_error
Definition: tls_core.h:72
Definition: tls_conf.h:129
Definition: tls_filter.h:23
tls_conf_conn_t * cc
Definition: tls_filter.h:25
conn_rec * c
Definition: tls_filter.h:24
apr_pool_t * p
tls_client_auth_t
Definition: tls_conf.h:49
apr_status_t tls_core_conn_post_handshake(conn_rec *c)
apr_status_t tls_core_conn_init(conn_rec *c)
tls_conf_conn_t * tls_conf_conn_get(conn_rec *c)
apr_status_t tls_core_init(apr_pool_t *p, apr_pool_t *ptemp, server_rec *base_server)
int tls_core_setup_outgoing(conn_rec *c)
void tls_core_conn_bind(conn_rec *c, ap_conf_vector_t *dir_conf)
apr_status_t tls_core_error(conn_rec *c, rustls_result rr, const char **perrstr)
void tls_core_conn_disable(conn_rec *c)
int tls_conn_check_ssl(conn_rec *c)
int tls_core_request_check(request_rec *r)
int tls_core_pre_conn_init(conn_rec *c)
void tls_conf_conn_set(conn_rec *c, tls_conf_conn_t *cc)
apr_status_t tls_core_init_outgoing(apr_pool_t *p, apr_pool_t *ptemp, server_rec *base_server)
apr_status_t tls_core_conn_seen_client_hello(conn_rec *c)
tls_conn_state_t
Definition: tls_core.h:21
@ TLS_CONN_ST_INIT
Definition: tls_core.h:22
@ TLS_CONN_ST_TRAFFIC
Definition: tls_core.h:26
@ TLS_CONN_ST_DISABLED
Definition: tls_core.h:23
@ TLS_CONN_ST_NOTIFIED
Definition: tls_core.h:27
@ TLS_CONN_ST_CLIENT_HELLO
Definition: tls_core.h:24
@ TLS_CONN_ST_DONE
Definition: tls_core.h:28
@ TLS_CONN_ST_HANDSHAKE
Definition: tls_core.h:25