Skip to content

Commit ddde8b3

Browse files
committed
server: support reading CRL PEM for client auth.
This commit updates the `tests/server.c` example program to support reading one or more CRLs from a single PEM encoded CRL file, provided via `AUTH_CRL`. This option is only processed when the server is performing mandatory client authentication (e.g. `AUTH_CERT` was provided).
1 parent 1af450e commit ddde8b3

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

tests/server.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ main(int argc, const char **argv)
289289
if(auth_cert) {
290290
char certbuf[10000];
291291
size_t certbuf_len;
292-
int result =
292+
unsigned result =
293293
read_file(argv[0], auth_cert, certbuf, sizeof(certbuf), &certbuf_len);
294294
if(result != DEMO_OK) {
295295
goto cleanup;
@@ -298,9 +298,26 @@ main(int argc, const char **argv)
298298
client_cert_root_store = rustls_root_cert_store_new();
299299
rustls_root_cert_store_add_pem(
300300
client_cert_root_store, (uint8_t *)certbuf, certbuf_len, true);
301-
302301
client_cert_verifier_builder =
303302
rustls_client_cert_verifier_builder_new(client_cert_root_store);
303+
304+
char *auth_crl = getenv("AUTH_CRL");
305+
char crlbuf[10000];
306+
size_t crlbuf_len;
307+
if(auth_crl) {
308+
result =
309+
read_file(argv[0], auth_crl, crlbuf, sizeof(crlbuf), &crlbuf_len);
310+
if(result != DEMO_OK) {
311+
goto cleanup;
312+
}
313+
314+
result = rustls_client_cert_verifier_builder_add_crl(
315+
client_cert_verifier_builder, (uint8_t *)crlbuf, certbuf_len);
316+
if(result != RUSTLS_RESULT_OK) {
317+
goto cleanup;
318+
}
319+
}
320+
304321
client_cert_verifier =
305322
rustls_client_cert_verifier_new(client_cert_verifier_builder);
306323
rustls_server_config_builder_set_client_verifier(config_builder,

0 commit comments

Comments
 (0)