add loading fallback certificates

This commit is contained in:
Johann150 2021-02-28 15:12:20 +01:00
parent 5a4907292f
commit 06819eeabd
No known key found for this signature in database
GPG key ID: 9EE6577A2A06F8F1
4 changed files with 147 additions and 56 deletions

View file

@ -160,7 +160,7 @@ fn args() -> Result<Args> {
];
}
let certs = Arc::new(certificates::CertStore::load_from(check_path(
let certs = Arc::new(certificates::CertStore::load_from(&check_path(
matches.opt_get_default("certs", ".certificates".into())?,
)?)?);
@ -188,15 +188,15 @@ fn check_path(s: String) -> Result<PathBuf, String> {
}
/// TLS configuration.
static TLS: Lazy<TlsAcceptor> = Lazy::new(|| acceptor().unwrap());
static TLS: Lazy<TlsAcceptor> = Lazy::new(acceptor);
fn acceptor() -> Result<TlsAcceptor> {
fn acceptor() -> TlsAcceptor {
let mut config = ServerConfig::new(NoClientAuth::new());
if ARGS.only_tls13 {
config.versions = vec![rustls::ProtocolVersion::TLSv1_3];
}
config.cert_resolver = ARGS.certs.clone();
Ok(TlsAcceptor::from(Arc::new(config)))
TlsAcceptor::from(Arc::new(config))
}
struct RequestHandle {