Panic on invalid certificate path when creating tls server
fritzrehde opened this issue · 1 comments
fritzrehde commented
Version
└── warp v0.3.5
Platform
Linux thinkpad 6.3.1-arch1-1 #1 SMP PREEMPT_DYNAMIC Mon, 01 May 2023 17:42:39 +0000 x86_64 GNU/Linux
Description
I want to create a tls server with the code down below. config
is a struct that stores the configuration, and it contains strings for client auth, cert and key paths. However, if these strings are invalid paths (or maybe just don't contain the "expected" content, I'm not sure), then warp::serve
panics.
I tried this code:
warp::serve(routes)
.tls()
.client_auth_required_path(config.client_ca_path)
.cert_path(config.cert_path)
.key_path(config.key_path)
.run(socket)
.await;
I expected to see this happen:
Some proper way of error handling. Can I work with a result somehow instead of it panicking?
Instead, this happened:
thread 'main' panicked at 'error binding to 0.0.0.0:3030: certificate parse error', /home/.../.cargo/registry/src/github.com-.../warp-0.3.5/src/server.rs:534:27
dsendkowski commented
You can make use of try_bind_with_graceful_shutdown
function that has been added recently.