fix as much as we can

Currently awaiting other crates we depend on to update. sqlx,
axum-server, etc, all use 0.21
This commit is contained in:
Ellie Huxtable 2024-06-13 12:58:02 +01:00
parent 2a508562cd
commit 07f53a74b6
5 changed files with 9 additions and 8 deletions

1
Cargo.lock generated
View File

@ -403,6 +403,7 @@ dependencies = [
"reqwest", "reqwest",
"rustls 0.23.9", "rustls 0.23.9",
"rustls-pemfile 2.1.2", "rustls-pemfile 2.1.2",
"rustls-pki-types",
"semver", "semver",
"serde", "serde",
"serde_json", "serde_json",

View File

@ -37,3 +37,4 @@ argon2 = "0.5"
semver = { workspace = true } semver = { workspace = true }
metrics-exporter-prometheus = "0.12.1" metrics-exporter-prometheus = "0.12.1"
metrics = "0.21.1" metrics = "0.21.1"
rustls-pki-types = "1.7.0"

View File

@ -14,7 +14,6 @@ mod metrics;
mod router; mod router;
mod utils; mod utils;
use rustls::ServerConfig;
pub use settings::example_config; pub use settings::example_config;
pub use settings::Settings; pub use settings::Settings;
@ -86,8 +85,7 @@ async fn launch_with_tls<Db: Database>(
let certificates = settings.tls.certificates()?; let certificates = settings.tls.certificates()?;
let pkey = settings.tls.private_key()?; let pkey = settings.tls.private_key()?;
let server_config = ServerConfig::builder() let server_config = rustls::server::ServerConfig::builder()
.with_safe_defaults()
.with_no_client_auth() .with_no_client_auth()
.with_single_cert(certificates, pkey)?; .with_single_cert(certificates, pkey)?;

View File

@ -112,12 +112,12 @@ pub struct Tls {
} }
impl Tls { impl Tls {
pub fn certificates(&self) -> Result<Vec<rustls::Certificate>> { pub fn certificates(&self) -> Result<Vec<rustls_pki_types::CertificateDer>> {
let cert_file = std::fs::File::open(&self.cert_path) let cert_file = std::fs::File::open(&self.cert_path)
.with_context(|| format!("tls.cert_path {:?} is missing", self.cert_path))?; .with_context(|| format!("tls.cert_path {:?} is missing", self.cert_path))?;
let mut reader = std::io::BufReader::new(cert_file); let mut reader = std::io::BufReader::new(cert_file);
let certs: Vec<_> = rustls_pemfile::certs(&mut reader) let certs: Vec<_> = rustls_pemfile::certs(&mut reader)
.map(|c| c.map(|c| rustls::Certificate(c.to_vec())))
.collect::<Result<Vec<_>, _>>() .collect::<Result<Vec<_>, _>>()
.with_context(|| format!("tls.cert_path {:?} is invalid", self.cert_path))?; .with_context(|| format!("tls.cert_path {:?} is invalid", self.cert_path))?;
@ -131,12 +131,12 @@ impl Tls {
Ok(certs) Ok(certs)
} }
pub fn private_key(&self) -> Result<rustls::PrivateKey> { pub fn private_key(&self) -> Result<rustls_pki_types::PrivateKeyDer> {
let pkey_file = std::fs::File::open(&self.pkey_path) let pkey_file = std::fs::File::open(&self.pkey_path)
.with_context(|| format!("tls.pkey_path {:?} is missing", self.pkey_path))?; .with_context(|| format!("tls.pkey_path {:?} is missing", self.pkey_path))?;
let mut reader = std::io::BufReader::new(pkey_file); let mut reader = std::io::BufReader::new(pkey_file);
let keys = rustls_pemfile::pkcs8_private_keys(&mut reader) let keys = rustls_pemfile::pkcs8_private_keys(&mut reader)
.map(|c| c.map(|c| rustls::PrivateKey(c.secret_pkcs8_der().to_vec()))) .map(|c| c.map(|c| rustls_pki_types::PrivateKeyDer::Pkcs8(c)))
.collect::<Result<Vec<_>, _>>() .collect::<Result<Vec<_>, _>>()
.with_context(|| format!("tls.pkey_path {:?} is not PKCS8-encoded", self.pkey_path))?; .with_context(|| format!("tls.pkey_path {:?} is not PKCS8-encoded", self.pkey_path))?;
@ -147,6 +147,6 @@ impl Tls {
); );
} }
Ok(keys[0].clone()) Ok(keys[0])
} }
} }

View File

@ -21,6 +21,7 @@ function Login(props: LoginProps) {
const key = form.key.value; const key = form.key.value;
console.log("Logging in..."); console.log("Logging in...");
try { try {
await login(username, password, key); await login(username, password, key);
refreshUser(); refreshUser();