diff --git a/Cargo.lock b/Cargo.lock index 4db1dc988d1..c4a5ddab6b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -401,8 +401,9 @@ dependencies = [ "metrics-exporter-prometheus", "rand", "reqwest", - "rustls", + "rustls 0.23.9", "rustls-pemfile 2.1.2", + "rustls-pki-types", "semver", "serde", "serde_json", @@ -450,6 +451,33 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +[[package]] +name = "aws-lc-rs" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "474d7cec9d0a1126fad1b224b767fcbf351c23b0309bb21ec210bcfd379926a5" +dependencies = [ + "aws-lc-sys", + "mirai-annotations", + "paste", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7505fc3cb7acbf42699a43a79dd9caa4ed9e99861dfbb837c5c0fb5a0a8d2980" +dependencies = [ + "bindgen", + "cc", + "cmake", + "dunce", + "fs_extra", + "libc", + "paste", +] + [[package]] name = "axum" version = "0.6.20" @@ -565,7 +593,7 @@ dependencies = [ "hyper 1.3.1", "hyper-util", "pin-project-lite", - "rustls", + "rustls 0.21.12", "rustls-pemfile 2.1.2", "tokio", "tokio-rustls", @@ -612,6 +640,29 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" +[[package]] +name = "bindgen" +version = "0.69.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" +dependencies = [ + "bitflags 2.5.0", + "cexpr", + "clang-sys", + "itertools", + "lazy_static", + "lazycell", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.66", + "which", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -689,6 +740,20 @@ name = "cc" version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" +dependencies = [ + "jobserver", + "libc", + "once_cell", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] [[package]] name = "cfg-if" @@ -731,6 +796,17 @@ dependencies = [ "zeroize", ] +[[package]] +name = "clang-sys" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc", + "libloading", +] + [[package]] name = "clap" version = "4.5.4" @@ -815,6 +891,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "cmake" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +dependencies = [ + "cc", +] + [[package]] name = "colorchoice" version = "1.0.1" @@ -1171,6 +1256,12 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" +[[package]] +name = "dunce" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" + [[package]] name = "ed25519" version = "2.2.3" @@ -1359,6 +1450,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + [[package]] name = "futures" version = "0.3.30" @@ -1507,6 +1604,12 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "h2" version = "0.3.26" @@ -1760,7 +1863,7 @@ dependencies = [ "futures-util", "http 0.2.12", "hyper 0.14.29", - "rustls", + "rustls 0.21.12", "tokio", "tokio-rustls", ] @@ -1936,6 +2039,15 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +[[package]] +name = "jobserver" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" version = "0.3.69" @@ -1954,12 +2066,28 @@ dependencies = [ "spin 0.5.2", ] +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "libc" version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +[[package]] +name = "libloading" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" +dependencies = [ + "cfg-if", + "windows-targets 0.52.5", +] + [[package]] name = "libm" version = "0.2.8" @@ -2214,6 +2342,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "mirai-annotations" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9be0862c1b3f26a88803c4a49de6889c10e608b3ee9344e6ef5b45fb37ad3d1" + [[package]] name = "multimap" version = "0.10.0" @@ -2882,7 +3016,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls", + "rustls 0.21.12", "rustls-native-certs", "rustls-pemfile 1.0.4", "serde", @@ -3018,10 +3152,25 @@ checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", "ring", - "rustls-webpki", + "rustls-webpki 0.101.7", "sct", ] +[[package]] +name = "rustls" +version = "0.23.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a218f0f6d05669de4eabfb24f31ce802035c952429d037507b4a4a39f0e60c5b" +dependencies = [ + "aws-lc-rs", + "log", + "once_cell", + "rustls-pki-types", + "rustls-webpki 0.102.4", + "subtle", + "zeroize", +] + [[package]] name = "rustls-native-certs" version = "0.6.3" @@ -3069,6 +3218,18 @@ dependencies = [ "untrusted", ] +[[package]] +name = "rustls-webpki" +version = "0.102.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" +dependencies = [ + "aws-lc-rs", + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.17" @@ -3320,6 +3481,12 @@ dependencies = [ "dirs", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signal-hook" version = "0.3.17" @@ -3477,7 +3644,7 @@ dependencies = [ "once_cell", "paste", "percent-encoding", - "rustls", + "rustls 0.21.12", "rustls-pemfile 1.0.4", "serde", "serde_json", @@ -3935,7 +4102,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls", + "rustls 0.21.12", "tokio", ] @@ -4477,6 +4644,18 @@ version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + [[package]] name = "whoami" version = "1.5.1" diff --git a/crates/atuin-server/Cargo.toml b/crates/atuin-server/Cargo.toml index b076a46697c..19e5d122cc5 100644 --- a/crates/atuin-server/Cargo.toml +++ b/crates/atuin-server/Cargo.toml @@ -31,9 +31,10 @@ fs-err = { workspace = true } tower = { workspace = true } tower-http = { version = "0.5.1", features = ["trace"] } reqwest = { workspace = true } -rustls = "0.21" +rustls = "0.23" rustls-pemfile = "2.1" argon2 = "0.5" semver = { workspace = true } metrics-exporter-prometheus = "0.12.1" metrics = "0.21.1" +rustls-pki-types = "1.7.0" diff --git a/crates/atuin-server/src/lib.rs b/crates/atuin-server/src/lib.rs index a0c104dc045..9ebdeebd9ab 100644 --- a/crates/atuin-server/src/lib.rs +++ b/crates/atuin-server/src/lib.rs @@ -14,7 +14,6 @@ mod metrics; mod router; mod utils; -use rustls::ServerConfig; pub use settings::example_config; pub use settings::Settings; @@ -86,8 +85,7 @@ async fn launch_with_tls( let certificates = settings.tls.certificates()?; let pkey = settings.tls.private_key()?; - let server_config = ServerConfig::builder() - .with_safe_defaults() + let server_config = rustls::server::ServerConfig::builder() .with_no_client_auth() .with_single_cert(certificates, pkey)?; diff --git a/crates/atuin-server/src/settings.rs b/crates/atuin-server/src/settings.rs index 286b56882c8..c35f5865bd4 100644 --- a/crates/atuin-server/src/settings.rs +++ b/crates/atuin-server/src/settings.rs @@ -112,12 +112,12 @@ pub struct Tls { } impl Tls { - pub fn certificates(&self) -> Result> { + pub fn certificates(&self) -> Result> { let cert_file = std::fs::File::open(&self.cert_path) .with_context(|| format!("tls.cert_path {:?} is missing", self.cert_path))?; let mut reader = std::io::BufReader::new(cert_file); + let certs: Vec<_> = rustls_pemfile::certs(&mut reader) - .map(|c| c.map(|c| rustls::Certificate(c.to_vec()))) .collect::, _>>() .with_context(|| format!("tls.cert_path {:?} is invalid", self.cert_path))?; @@ -131,12 +131,12 @@ impl Tls { Ok(certs) } - pub fn private_key(&self) -> Result { + pub fn private_key(&self) -> Result { let pkey_file = std::fs::File::open(&self.pkey_path) .with_context(|| format!("tls.pkey_path {:?} is missing", self.pkey_path))?; let mut reader = std::io::BufReader::new(pkey_file); 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::, _>>() .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]) } } diff --git a/ui/src/components/LoginOrRegister.tsx b/ui/src/components/LoginOrRegister.tsx index f05a9a2443a..af908fdbb5d 100644 --- a/ui/src/components/LoginOrRegister.tsx +++ b/ui/src/components/LoginOrRegister.tsx @@ -21,6 +21,7 @@ function Login(props: LoginProps) { const key = form.key.value; console.log("Logging in..."); + try { await login(username, password, key); refreshUser();