Skip to content

Commit c8a9d21

Browse files
committedApr 22, 2024·
* mod_tls: update version of rustls-ffi to v0.13.0.
[Daniel McCarney (@cpu}] git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1917270 13f79535-47bb-0310-9956-ffa450edef68
1 parent 301d5f6 commit c8a9d21

File tree

10 files changed

+91
-51
lines changed

10 files changed

+91
-51
lines changed
 

‎.github/workflows/linux.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ jobs:
241241
APR_VERSION=1.7.4
242242
APU_VERSION=1.6.3
243243
APU_CONFIG="--with-crypto"
244-
RUSTLS_VERSION="v0.10.0"
244+
RUSTLS_VERSION="v0.13.0"
245245
NO_TEST_FRAMEWORK=1
246246
TEST_INSTALL=1
247247
TEST_MOD_TLS=1

‎.gitignore

+14-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,19 @@ Release
7676
/build/config.sub
7777
/build/config.guess
7878
/build/config_vars.sh
79+
/build/confdefs.h
80+
/build/config.log
81+
/build/config.nice
82+
/build/srclib/
83+
/build/srclib/pth
84+
/build/srclib/apr
85+
/build/srclib/apr-util
86+
/build/srclib/apr-iconv
87+
/build/srclib/distcache
88+
/build/srclib/lua
89+
/build/srclib/pcre
90+
/build/srclib/openssl
91+
/build/srclib/zlib
7992

8093
# /build/pkg/
8194
/build/pkg/pkginfo
@@ -371,4 +384,4 @@ test/*/*/__pycache__
371384

372385
# make check
373386
check
374-
build/config_vars.out
387+
build/config_vars.out

‎changes-entries/mod_tls_v0.9.0.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* mod_tls: update version of rustls-ffi to v0.13.0.
2+
[Daniel McCarney (@cpu}]

‎modules/tls/tls_cert.c

+55-36
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,12 @@ const char *tls_cert_reg_get_id(tls_cert_reg_t *reg, const rustls_certified_key
331331
}
332332

333333
apr_status_t tls_cert_load_root_store(
334-
apr_pool_t *p, const char *store_file, rustls_root_cert_store **pstore)
334+
apr_pool_t *p, const char *store_file, const rustls_root_cert_store **pstore)
335335
{
336336
const char *fpath;
337337
tls_data_t pem;
338-
rustls_root_cert_store *store = NULL;
338+
rustls_root_cert_store_builder *store_builder = NULL;
339+
const rustls_root_cert_store *store = NULL;
339340
rustls_result rr = RUSTLS_RESULT_OK;
340341
apr_pool_t *ptemp = NULL;
341342
apr_status_t rv;
@@ -353,11 +354,17 @@ apr_status_t tls_cert_load_root_store(
353354
rv = tls_util_file_load(ptemp, fpath, 0, 1024*1024, &pem);
354355
if (APR_SUCCESS != rv) goto cleanup;
355356

356-
store = rustls_root_cert_store_new();
357-
rr = rustls_root_cert_store_add_pem(store, pem.data, pem.len, 1);
357+
store_builder = rustls_root_cert_store_builder_new();
358+
rr = rustls_root_cert_store_builder_add_pem(store_builder, pem.data, pem.len, 1);
359+
if (RUSTLS_RESULT_OK != rr) goto cleanup;
360+
361+
rr = rustls_root_cert_store_builder_build(store_builder, &store);
358362
if (RUSTLS_RESULT_OK != rr) goto cleanup;
359363

360364
cleanup:
365+
if (store_builder != NULL) {
366+
rustls_root_cert_store_builder_free(store_builder);
367+
}
361368
if (RUSTLS_RESULT_OK != rr) {
362369
const char *err_descr;
363370
rv = tls_util_rustls_error(p, rr, &err_descr);
@@ -378,7 +385,7 @@ apr_status_t tls_cert_load_root_store(
378385

379386
typedef struct {
380387
const char *id;
381-
rustls_root_cert_store *store;
388+
const rustls_root_cert_store *store;
382389
} tls_cert_root_stores_entry_t;
383390

384391
static int stores_entry_cleanup(void *ctx, const void *key, apr_ssize_t klen, const void *val)
@@ -421,14 +428,14 @@ void tls_cert_root_stores_clear(tls_cert_root_stores_t *stores)
421428
apr_status_t tls_cert_root_stores_get(
422429
tls_cert_root_stores_t *stores,
423430
const char *store_file,
424-
rustls_root_cert_store **pstore)
431+
const rustls_root_cert_store **pstore)
425432
{
426433
apr_status_t rv = APR_SUCCESS;
427434
tls_cert_root_stores_entry_t *entry;
428435

429436
entry = apr_hash_get(stores->file2store, store_file, APR_HASH_KEY_STRING);
430437
if (!entry) {
431-
rustls_root_cert_store *store;
438+
const rustls_root_cert_store *store;
432439
rv = tls_cert_load_root_store(stores->pool, store_file, &store);
433440
if (APR_SUCCESS != rv) goto cleanup;
434441
entry = apr_pcalloc(stores->pool, sizeof(*entry));
@@ -449,8 +456,8 @@ apr_status_t tls_cert_root_stores_get(
449456

450457
typedef struct {
451458
const char *id;
452-
const rustls_client_cert_verifier *client_verifier;
453-
const rustls_client_cert_verifier_optional *client_verifier_opt;
459+
rustls_client_cert_verifier *client_verifier;
460+
rustls_client_cert_verifier *client_verifier_opt;
454461
} tls_cert_verifiers_entry_t;
455462

456463
static int verifiers_entry_cleanup(void *ctx, const void *key, apr_ssize_t klen, const void *val)
@@ -462,7 +469,7 @@ static int verifiers_entry_cleanup(void *ctx, const void *key, apr_ssize_t klen,
462469
entry->client_verifier = NULL;
463470
}
464471
if (entry->client_verifier_opt) {
465-
rustls_client_cert_verifier_optional_free(entry->client_verifier_opt);
472+
rustls_client_cert_verifier_free(entry->client_verifier_opt);
466473
entry->client_verifier_opt = NULL;
467474
}
468475
return 1;
@@ -511,23 +518,44 @@ static tls_cert_verifiers_entry_t * verifiers_get_or_make_entry(
511518
return entry;
512519
}
513520

514-
apr_status_t tls_cert_client_verifiers_get(
515-
tls_cert_verifiers_t *verifiers,
516-
const char *store_file,
517-
const rustls_client_cert_verifier **pverifier)
521+
static apr_status_t tls_cert_client_verifiers_get_internal(
522+
tls_cert_verifiers_t *verifiers,
523+
const char *store_file,
524+
const rustls_client_cert_verifier **pverifier,
525+
bool allow_unauthenticated)
518526
{
519527
apr_status_t rv = APR_SUCCESS;
520528
tls_cert_verifiers_entry_t *entry;
529+
rustls_result rr = RUSTLS_RESULT_OK;
530+
struct rustls_web_pki_client_cert_verifier_builder *verifier_builder = NULL;
521531

522532
entry = verifiers_get_or_make_entry(verifiers, store_file);
523533
if (!entry->client_verifier) {
524-
rustls_root_cert_store *store;
534+
const rustls_root_cert_store *store;
525535
rv = tls_cert_root_stores_get(verifiers->stores, store_file, &store);
526536
if (APR_SUCCESS != rv) goto cleanup;
527-
entry->client_verifier = rustls_client_cert_verifier_new(store);
537+
verifier_builder = rustls_web_pki_client_cert_verifier_builder_new(store);
538+
539+
if (allow_unauthenticated) {
540+
rr = rustls_web_pki_client_cert_verifier_builder_allow_unauthenticated(verifier_builder);
541+
if (rr != RUSTLS_RESULT_OK) {
542+
goto cleanup;
543+
}
544+
}
545+
546+
rr = rustls_web_pki_client_cert_verifier_builder_build(verifier_builder, &entry->client_verifier);
547+
if (rr != RUSTLS_RESULT_OK) {
548+
goto cleanup;
549+
}
528550
}
529551

530552
cleanup:
553+
if (verifier_builder != NULL) {
554+
rustls_web_pki_client_cert_verifier_builder_free(verifier_builder);
555+
}
556+
if (rr != RUSTLS_RESULT_OK) {
557+
rv = tls_util_rustls_error(verifiers->pool, rr, NULL);
558+
}
531559
if (APR_SUCCESS == rv) {
532560
*pverifier = entry->client_verifier;
533561
}
@@ -537,28 +565,19 @@ apr_status_t tls_cert_client_verifiers_get(
537565
return rv;
538566
}
539567

540-
apr_status_t tls_cert_client_verifiers_get_optional(
568+
569+
apr_status_t tls_cert_client_verifiers_get(
541570
tls_cert_verifiers_t *verifiers,
542571
const char *store_file,
543-
const rustls_client_cert_verifier_optional **pverifier)
572+
const rustls_client_cert_verifier **pverifier)
544573
{
545-
apr_status_t rv = APR_SUCCESS;
546-
tls_cert_verifiers_entry_t *entry;
547-
548-
entry = verifiers_get_or_make_entry(verifiers, store_file);
549-
if (!entry->client_verifier_opt) {
550-
rustls_root_cert_store *store;
551-
rv = tls_cert_root_stores_get(verifiers->stores, store_file, &store);
552-
if (APR_SUCCESS != rv) goto cleanup;
553-
entry->client_verifier_opt = rustls_client_cert_verifier_optional_new(store);
554-
}
574+
return tls_cert_client_verifiers_get_internal(verifiers, store_file, pverifier, false);
575+
}
555576

556-
cleanup:
557-
if (APR_SUCCESS == rv) {
558-
*pverifier = entry->client_verifier_opt;
559-
}
560-
else {
561-
*pverifier = NULL;
562-
}
563-
return rv;
577+
apr_status_t tls_cert_client_verifiers_get_optional(
578+
tls_cert_verifiers_t *verifiers,
579+
const char *store_file,
580+
const rustls_client_cert_verifier **pverifier)
581+
{
582+
return tls_cert_client_verifiers_get_internal(verifiers, store_file, pverifier, true);
564583
}

‎modules/tls/tls_cert.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ const char *tls_cert_reg_get_id(tls_cert_reg_t *reg, const rustls_certified_key
128128
* @param pstore the loaded root store on success
129129
*/
130130
apr_status_t tls_cert_load_root_store(
131-
apr_pool_t *p, const char *store_file, rustls_root_cert_store **pstore);
131+
apr_pool_t *p, const char *store_file, const rustls_root_cert_store **pstore);
132132

133133
typedef struct tls_cert_root_stores_t tls_cert_root_stores_t;
134134
struct tls_cert_root_stores_t {
@@ -157,7 +157,7 @@ void tls_cert_root_stores_clear(tls_cert_root_stores_t *stores);
157157
apr_status_t tls_cert_root_stores_get(
158158
tls_cert_root_stores_t *stores,
159159
const char *store_file,
160-
rustls_root_cert_store **pstore);
160+
const rustls_root_cert_store **pstore);
161161

162162
typedef struct tls_cert_verifiers_t tls_cert_verifiers_t;
163163
struct tls_cert_verifiers_t {
@@ -206,6 +206,6 @@ apr_status_t tls_cert_client_verifiers_get(
206206
apr_status_t tls_cert_client_verifiers_get_optional(
207207
tls_cert_verifiers_t *verifiers,
208208
const char *store_file,
209-
const rustls_client_cert_verifier_optional **pverifier);
209+
const rustls_client_cert_verifier **pverifier);
210210

211-
#endif /* tls_cert_h */
211+
#endif /* tls_cert_h */

‎modules/tls/tls_core.c

+10-4
Original file line numberDiff line numberDiff line change
@@ -764,8 +764,10 @@ static apr_status_t init_outgoing_connection(conn_rec *c)
764764
tls_conf_proxy_t *pc;
765765
const apr_array_header_t *ciphersuites = NULL;
766766
apr_array_header_t *tls_versions = NULL;
767+
rustls_web_pki_server_cert_verifier_builder *verifier_builder = NULL;
768+
struct rustls_server_cert_verifier *verifier = NULL;
767769
rustls_client_config_builder *builder = NULL;
768-
rustls_root_cert_store *ca_store = NULL;
770+
const rustls_root_cert_store *ca_store = NULL;
769771
const char *hostname = NULL, *alpn_note = NULL;
770772
rustls_result rr = RUSTLS_RESULT_OK;
771773
apr_status_t rv = APR_SUCCESS;
@@ -809,7 +811,10 @@ static apr_status_t init_outgoing_connection(conn_rec *c)
809811
if (pc->proxy_ca && strcasecmp(pc->proxy_ca, "default")) {
810812
rv = tls_cert_root_stores_get(pc->global->stores, pc->proxy_ca, &ca_store);
811813
if (APR_SUCCESS != rv) goto cleanup;
812-
rustls_client_config_builder_use_roots(builder, ca_store);
814+
verifier_builder = rustls_web_pki_server_cert_verifier_builder_new(ca_store);
815+
rr = rustls_web_pki_server_cert_verifier_builder_build(verifier_builder, &verifier);
816+
if (RUSTLS_RESULT_OK != rr) goto cleanup;
817+
rustls_client_config_builder_set_server_verifier(builder, verifier);
813818
}
814819

815820
#if TLS_MACHINE_CERTS
@@ -881,6 +886,7 @@ static apr_status_t init_outgoing_connection(conn_rec *c)
881886
rustls_connection_set_userdata(cc->rustls_connection, c);
882887

883888
cleanup:
889+
if (verifier_builder != NULL) rustls_web_pki_server_cert_verifier_builder_free(verifier_builder);
884890
if (builder != NULL) rustls_client_config_builder_free(builder);
885891
if (RUSTLS_RESULT_OK != rr) {
886892
const char *err_descr = NULL;
@@ -1125,10 +1131,10 @@ static apr_status_t build_server_connection(rustls_connection **pconnection,
11251131
rustls_server_config_builder_set_client_verifier(builder, verifier);
11261132
}
11271133
else {
1128-
const rustls_client_cert_verifier_optional *verifier;
1134+
const rustls_client_cert_verifier *verifier;
11291135
rv = tls_cert_client_verifiers_get_optional(sc->global->verifiers, sc->client_ca, &verifier);
11301136
if (APR_SUCCESS != rv) goto cleanup;
1131-
rustls_server_config_builder_set_client_verifier_optional(builder, verifier);
1137+
rustls_server_config_builder_set_client_verifier(builder, verifier);
11321138
}
11331139
}
11341140

‎modules/tls/tls_version.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
* @macro
2727
* Version number of the md module as c string
2828
*/
29-
#define MOD_TLS_VERSION "0.8.3"
29+
#define MOD_TLS_VERSION "0.9.0"
3030

3131
/**
3232
* @macro
3333
* Numerical representation of the version number of the md module
3434
* release. This is a 24 bit number with 8 bits for major number, 8 bits
3535
* for minor and 8 bits for patch. Version 1.2.3 becomes 0x010203.
3636
*/
37-
#define MOD_TLS_VERSION_NUM 0x000802
37+
#define MOD_TLS_VERSION_NUM 0x000900
3838

3939
#endif /* mod_md_md_version_h */

‎test/modules/tls/test_08_vars.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def test_tls_08_vars_const(self, env, name: str, value: str):
5959

6060
@pytest.mark.parametrize("name, pattern", [
6161
("SSL_VERSION_INTERFACE", r'mod_tls/\d+\.\d+\.\d+'),
62-
("SSL_VERSION_LIBRARY", r'rustls-ffi/\d+\.\d+\.\d+/rustls/\d+\.\d+\.\d+'),
62+
("SSL_VERSION_LIBRARY", r'rustls-ffi/\d+\.\d+\.\d+/rustls/\d+\.\d+(\.\d+)?'),
6363
])
6464
def test_tls_08_vars_match(self, env, name: str, pattern: str):
6565
r = env.tls_get(env.domain_b, f"/vars.py?name={name}")

‎test/modules/tls/test_14_proxy_ssl.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def test_tls_14_proxy_ssl_vars_const(self, env, name: str, value: str):
100100

101101
@pytest.mark.parametrize("name, pattern", [
102102
("SSL_VERSION_INTERFACE", r'mod_tls/\d+\.\d+\.\d+'),
103-
("SSL_VERSION_LIBRARY", r'rustls-ffi/\d+\.\d+\.\d+/rustls/\d+\.\d+\.\d+'),
103+
("SSL_VERSION_LIBRARY", r'rustls-ffi/\d+\.\d+\.\d+/rustls/\d+\.\d+(\.\d+)?'),
104104
])
105105
def test_tls_14_proxy_tsl_vars_match(self, env, name: str, pattern: str):
106106
if not HttpdTestEnv.has_shared_module("tls"):

‎test/travis_run_linux.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ fi
266266
if test -v TEST_MOD_TLS -a $RV -eq 0; then
267267
# Run mod_tls tests. The underlying librustls was build
268268
# and installed before we configured the server (see top of file).
269-
# This will be replaved once librustls is available as a package.
269+
# This will be replaced once librustls is available as a package.
270270
py.test-3 test/modules/tls
271271
RV=$?
272272
fi

0 commit comments

Comments
 (0)
Please sign in to comment.