mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
update ws dependencies as well as http rustls dependency
This commit is contained in:
parent
071f088d8b
commit
3042539101
16 changed files with 499 additions and 295 deletions
|
|
@ -37,5 +37,5 @@ toml = "0.5"
|
|||
# Optional
|
||||
glommio = { version = "0.8", optional = true }
|
||||
hwloc = { version = "0.5", optional = true }
|
||||
rustls = { version = "0.21", optional = true }
|
||||
rustls-pemfile = { version = "1", optional = true }
|
||||
rustls = { version = "0.22", optional = true }
|
||||
rustls-pemfile = { version = "2", optional = true }
|
||||
|
|
|
|||
|
|
@ -17,10 +17,20 @@ pub fn create_rustls_config(
|
|||
})?;
|
||||
let mut f = BufReader::new(f);
|
||||
|
||||
rustls_pemfile::certs(&mut f)?
|
||||
.into_iter()
|
||||
.map(|bytes| rustls::Certificate(bytes))
|
||||
.collect()
|
||||
let mut certs = Vec::new();
|
||||
|
||||
for cert in rustls_pemfile::certs(&mut f) {
|
||||
match cert {
|
||||
Ok(cert) => {
|
||||
certs.push(cert);
|
||||
}
|
||||
Err(err) => {
|
||||
::log::error!("error parsing certificate: {:#?}", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
certs
|
||||
};
|
||||
|
||||
let private_key = {
|
||||
|
|
@ -32,16 +42,16 @@ pub fn create_rustls_config(
|
|||
})?;
|
||||
let mut f = BufReader::new(f);
|
||||
|
||||
rustls_pemfile::pkcs8_private_keys(&mut f)?
|
||||
.first()
|
||||
.map(|bytes| rustls::PrivateKey(bytes.clone()))
|
||||
.ok_or(anyhow::anyhow!("No private keys in file"))?
|
||||
let key = rustls_pemfile::pkcs8_private_keys(&mut f)
|
||||
.next()
|
||||
.ok_or(anyhow::anyhow!("No private keys in file"))??;
|
||||
|
||||
key
|
||||
};
|
||||
|
||||
let tls_config = rustls::ServerConfig::builder()
|
||||
.with_safe_defaults()
|
||||
.with_no_client_auth()
|
||||
.with_single_cert(certs, private_key)
|
||||
.with_single_cert(certs, rustls::pki_types::PrivateKeyDer::Pkcs8(private_key))
|
||||
.with_context(|| "create rustls config")?;
|
||||
|
||||
Ok(tls_config)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue