Skip to content

misterdownloadmanager: The ultimate open-source, clean-room download manager written from scratch in pure Rust for Windows, Mac, and Linux

Linux: torrents start on a system without CA certificates, and HTTPS trackers say why they can't (part of #264) (#278)

Ahmed Nefzaoui1ffc0660ec07
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c540f831..e4d76a2d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -610,6 +610,11 @@ choose. And Linux, checked on a real desktop with every change.
### Fixed
+- **Linux: torrents work on a system without CA certificates too** (part of
+ [#264](https://github.com/anefzaoui/misterdownloadmanager/issues/264)): the torrent engine built
+ its own connection for the trackers, which can't be made without them, so no torrent or magnet
+ link started there. It now uses MDM's: peers, the DHT and `http://` trackers work, and an
+ `https://` tracker fails saying there are no certificates to check it with.
- **Linux: uninstalling the .deb or .rpm leaves no browser files behind**
([#266](https://github.com/anefzaoui/misterdownloadmanager/issues/266)): MDM wrote the files
that tell each browser where its helper is in every user's home folder, and `apt remove` or
diff --git a/Cargo.lock b/Cargo.lock
index 2890a2f2..135b0910 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3975,7 +3975,7 @@ dependencies = [
[[package]]
name = "librqbit"
version = "9.1.0"
-source = "git+https://github.com/anefzaoui/rqbit.git?rev=d0015a87bebf7ea581764ad45710a4abb6886dc6#d0015a87bebf7ea581764ad45710a4abb6886dc6"
+source = "git+https://github.com/anefzaoui/rqbit.git?rev=ef50d87f4a9d5be9e3951b74f722433f9b46bd76#ef50d87f4a9d5be9e3951b74f722433f9b46bd76"
dependencies = [
"anyhow",
"arc-swap",
@@ -4038,7 +4038,7 @@ dependencies = [
[[package]]
name = "librqbit-bencode"
version = "9.1.0"
-source = "git+https://github.com/anefzaoui/rqbit.git?rev=d0015a87bebf7ea581764ad45710a4abb6886dc6#d0015a87bebf7ea581764ad45710a4abb6886dc6"
+source = "git+https://github.com/anefzaoui/rqbit.git?rev=ef50d87f4a9d5be9e3951b74f722433f9b46bd76#ef50d87f4a9d5be9e3951b74f722433f9b46bd76"
dependencies = [
"anyhow",
"arrayvec",
@@ -4054,7 +4054,7 @@ dependencies = [
[[package]]
name = "librqbit-buffers"
version = "9.1.0"
-source = "git+https://github.com/anefzaoui/rqbit.git?rev=d0015a87bebf7ea581764ad45710a4abb6886dc6#d0015a87bebf7ea581764ad45710a4abb6886dc6"
+source = "git+https://github.com/anefzaoui/rqbit.git?rev=ef50d87f4a9d5be9e3951b74f722433f9b46bd76#ef50d87f4a9d5be9e3951b74f722433f9b46bd76"
dependencies = [
"bytes",
"librqbit-clone-to-owned",
@@ -4065,7 +4065,7 @@ dependencies = [
[[package]]
name = "librqbit-clone-to-owned"
version = "9.1.0"
-source = "git+https://github.com/anefzaoui/rqbit.git?rev=d0015a87bebf7ea581764ad45710a4abb6886dc6#d0015a87bebf7ea581764ad45710a4abb6886dc6"
+source = "git+https://github.com/anefzaoui/rqbit.git?rev=ef50d87f4a9d5be9e3951b74f722433f9b46bd76#ef50d87f4a9d5be9e3951b74f722433f9b46bd76"
dependencies = [
"bytes",
]
@@ -4073,7 +4073,7 @@ dependencies = [
[[package]]
name = "librqbit-core"
version = "9.1.0"
-source = "git+https://github.com/anefzaoui/rqbit.git?rev=d0015a87bebf7ea581764ad45710a4abb6886dc6#d0015a87bebf7ea581764ad45710a4abb6886dc6"
+source = "git+https://github.com/anefzaoui/rqbit.git?rev=ef50d87f4a9d5be9e3951b74f722433f9b46bd76#ef50d87f4a9d5be9e3951b74f722433f9b46bd76"
dependencies = [
"anyhow",
"bytes",
@@ -4102,7 +4102,7 @@ dependencies = [
[[package]]
name = "librqbit-dht"
version = "9.1.0"
-source = "git+https://github.com/anefzaoui/rqbit.git?rev=d0015a87bebf7ea581764ad45710a4abb6886dc6#d0015a87bebf7ea581764ad45710a4abb6886dc6"
+source = "git+https://github.com/anefzaoui/rqbit.git?rev=ef50d87f4a9d5be9e3951b74f722433f9b46bd76#ef50d87f4a9d5be9e3951b74f722433f9b46bd76"
dependencies = [
"anyhow",
"backon",
@@ -4149,7 +4149,7 @@ dependencies = [
[[package]]
name = "librqbit-lsd"
version = "9.1.0"
-source = "git+https://github.com/anefzaoui/rqbit.git?rev=d0015a87bebf7ea581764ad45710a4abb6886dc6#d0015a87bebf7ea581764ad45710a4abb6886dc6"
+source = "git+https://github.com/anefzaoui/rqbit.git?rev=ef50d87f4a9d5be9e3951b74f722433f9b46bd76#ef50d87f4a9d5be9e3951b74f722433f9b46bd76"
dependencies = [
"anyhow",
"atoi",
@@ -4168,7 +4168,7 @@ dependencies = [
[[package]]
name = "librqbit-peer-protocol"
version = "9.1.0"
-source = "git+https://github.com/anefzaoui/rqbit.git?rev=d0015a87bebf7ea581764ad45710a4abb6886dc6#d0015a87bebf7ea581764ad45710a4abb6886dc6"
+source = "git+https://github.com/anefzaoui/rqbit.git?rev=ef50d87f4a9d5be9e3951b74f722433f9b46bd76#ef50d87f4a9d5be9e3951b74f722433f9b46bd76"
dependencies = [
"anyhow",
"bitvec",
@@ -4188,7 +4188,7 @@ dependencies = [
[[package]]
name = "librqbit-sha1-wrapper"
version = "9.1.0"
-source = "git+https://github.com/anefzaoui/rqbit.git?rev=d0015a87bebf7ea581764ad45710a4abb6886dc6#d0015a87bebf7ea581764ad45710a4abb6886dc6"
+source = "git+https://github.com/anefzaoui/rqbit.git?rev=ef50d87f4a9d5be9e3951b74f722433f9b46bd76#ef50d87f4a9d5be9e3951b74f722433f9b46bd76"
dependencies = [
"assert_cfg",
"aws-lc-rs",
@@ -4197,7 +4197,7 @@ dependencies = [
[[package]]
name = "librqbit-tracker-comms"
version = "9.1.0"
-source = "git+https://github.com/anefzaoui/rqbit.git?rev=d0015a87bebf7ea581764ad45710a4abb6886dc6#d0015a87bebf7ea581764ad45710a4abb6886dc6"
+source = "git+https://github.com/anefzaoui/rqbit.git?rev=ef50d87f4a9d5be9e3951b74f722433f9b46bd76#ef50d87f4a9d5be9e3951b74f722433f9b46bd76"
dependencies = [
"anyhow",
"async-stream",
@@ -4225,7 +4225,7 @@ dependencies = [
[[package]]
name = "librqbit-upnp"
version = "9.1.0"
-source = "git+https://github.com/anefzaoui/rqbit.git?rev=d0015a87bebf7ea581764ad45710a4abb6886dc6#d0015a87bebf7ea581764ad45710a4abb6886dc6"
+source = "git+https://github.com/anefzaoui/rqbit.git?rev=ef50d87f4a9d5be9e3951b74f722433f9b46bd76#ef50d87f4a9d5be9e3951b74f722433f9b46bd76"
dependencies = [
"anyhow",
"bstr",
@@ -4728,6 +4728,7 @@ version = "0.3.0"
dependencies = [
"flate2",
"librqbit",
+ "mdm-engine",
"serde_json",
"tempfile",
"thiserror 2.0.21",
diff --git a/Cargo.toml b/Cargo.toml
index b88a9d47..11bfe093 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -190,19 +190,20 @@ debug = "line-tables-only"
[patch.crates-io]
# librqbit 9.1.0 with per-torrent rate limits that change while a torrent runs (#39), and a
# magnet lookup's progress counted (#92), and every socket bound to one address (`bind_ip`,
-# #143), until upstream has them (ikatson/rqbit); every crate of that repository from the same
-# commit.
-librqbit = { git = "https://github.com/anefzaoui/rqbit.git", rev = "d0015a87bebf7ea581764ad45710a4abb6886dc6" }
-librqbit-bencode = { git = "https://github.com/anefzaoui/rqbit.git", rev = "d0015a87bebf7ea581764ad45710a4abb6886dc6" }
-librqbit-buffers = { git = "https://github.com/anefzaoui/rqbit.git", rev = "d0015a87bebf7ea581764ad45710a4abb6886dc6" }
-librqbit-clone-to-owned = { git = "https://github.com/anefzaoui/rqbit.git", rev = "d0015a87bebf7ea581764ad45710a4abb6886dc6" }
-librqbit-core = { git = "https://github.com/anefzaoui/rqbit.git", rev = "d0015a87bebf7ea581764ad45710a4abb6886dc6" }
-librqbit-dht = { git = "https://github.com/anefzaoui/rqbit.git", rev = "d0015a87bebf7ea581764ad45710a4abb6886dc6" }
-librqbit-lsd = { git = "https://github.com/anefzaoui/rqbit.git", rev = "d0015a87bebf7ea581764ad45710a4abb6886dc6" }
-librqbit-peer-protocol = { git = "https://github.com/anefzaoui/rqbit.git", rev = "d0015a87bebf7ea581764ad45710a4abb6886dc6" }
-librqbit-sha1-wrapper = { git = "https://github.com/anefzaoui/rqbit.git", rev = "d0015a87bebf7ea581764ad45710a4abb6886dc6" }
-librqbit-tracker-comms = { git = "https://github.com/anefzaoui/rqbit.git", rev = "d0015a87bebf7ea581764ad45710a4abb6886dc6" }
-librqbit-upnp = { git = "https://github.com/anefzaoui/rqbit.git", rev = "d0015a87bebf7ea581764ad45710a4abb6886dc6" }
+# #143), and every HTTP client of a session built through MDM's TLS setup (`configure_http_client`:
+# a system without CA certificates), until upstream has them (ikatson/rqbit); every crate of that
+# repository from the same commit.
+librqbit = { git = "https://github.com/anefzaoui/rqbit.git", rev = "ef50d87f4a9d5be9e3951b74f722433f9b46bd76" }
+librqbit-bencode = { git = "https://github.com/anefzaoui/rqbit.git", rev = "ef50d87f4a9d5be9e3951b74f722433f9b46bd76" }
+librqbit-buffers = { git = "https://github.com/anefzaoui/rqbit.git", rev = "ef50d87f4a9d5be9e3951b74f722433f9b46bd76" }
+librqbit-clone-to-owned = { git = "https://github.com/anefzaoui/rqbit.git", rev = "ef50d87f4a9d5be9e3951b74f722433f9b46bd76" }
+librqbit-core = { git = "https://github.com/anefzaoui/rqbit.git", rev = "ef50d87f4a9d5be9e3951b74f722433f9b46bd76" }
+librqbit-dht = { git = "https://github.com/anefzaoui/rqbit.git", rev = "ef50d87f4a9d5be9e3951b74f722433f9b46bd76" }
+librqbit-lsd = { git = "https://github.com/anefzaoui/rqbit.git", rev = "ef50d87f4a9d5be9e3951b74f722433f9b46bd76" }
+librqbit-peer-protocol = { git = "https://github.com/anefzaoui/rqbit.git", rev = "ef50d87f4a9d5be9e3951b74f722433f9b46bd76" }
+librqbit-sha1-wrapper = { git = "https://github.com/anefzaoui/rqbit.git", rev = "ef50d87f4a9d5be9e3951b74f722433f9b46bd76" }
+librqbit-tracker-comms = { git = "https://github.com/anefzaoui/rqbit.git", rev = "ef50d87f4a9d5be9e3951b74f722433f9b46bd76" }
+librqbit-upnp = { git = "https://github.com/anefzaoui/rqbit.git", rev = "ef50d87f4a9d5be9e3951b74f722433f9b46bd76" }
ecolor = { git = "https://github.com/anefzaoui/egui.git", rev = "517027e916d11183b65b0cd9e5066154dbc7324b" }
emath = { git = "https://github.com/anefzaoui/egui.git", rev = "517027e916d11183b65b0cd9e5066154dbc7324b" }
epaint = { git = "https://github.com/anefzaoui/egui.git", rev = "517027e916d11183b65b0cd9e5066154dbc7324b" }
diff --git a/ROADMAP.md b/ROADMAP.md
index d94529d8..8b6ac0a4 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -31,6 +31,9 @@ Everything below ships together, in the next release.
on Wayland instead ([#265](https://github.com/anefzaoui/misterdownloadmanager/issues/265))
- ✅ Linux: plain HTTP downloads work on a system without CA certificates, and HTTPS ones say to
install them ([#264](https://github.com/anefzaoui/misterdownloadmanager/issues/264))
+- ✅ Linux: torrents and magnet links work on a system without CA certificates too (peers, the
+ DHT and `http://` trackers; `https://` trackers say why they can't), part of
+ [#264](https://github.com/anefzaoui/misterdownloadmanager/issues/264)
- ✅ Update now finds the Linux and macOS release files whether or not their names end in
"-experimental"
- ✅ Linux packages checked in clean Ubuntu 24.04, Debian 12 and Fedora 45 systems: install, the
diff --git a/crates/engine/src/tls.rs b/crates/engine/src/tls.rs
index 5a63d0c7..73854ebf 100644
--- a/crates/engine/src/tls.rs
+++ b/crates/engine/src/tls.rs
@@ -1,7 +1,9 @@
//! The certificates secure connections (HTTPS, FTPS, DNS over TLS or HTTPS) check servers with:
//! the system's. A system without any (a minimal Linux without the `ca-certificates` package,
//! #264) still gives every client: plain HTTP and FTP work, and each secure connection fails
-//! with [`NO_ROOTS`], which the engine reports as `Error::NoCertificates`.
+//! with [`NO_ROOTS`], which the engine reports as `Error::NoCertificates`. The torrent session's
+//! HTTP clients take the same setup (mdm-torrent), so a session still starts there: DHT, peers
+//! and plain HTTP trackers work, HTTPS trackers fail with [`NO_ROOTS`].
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
@@ -39,8 +41,10 @@ pub fn system_has_roots() -> bool {
/// `builder` with the TLS it can have here: reqwest's own (the system's verifier) when the
/// system has certificates, else one whose every secure connection fails with [`NO_ROOTS`]
-/// (reqwest's would refuse to build the client at all, plain HTTP included).
-pub(crate) fn configure(builder: reqwest::ClientBuilder) -> reqwest::ClientBuilder {
+/// (reqwest's would refuse to build the client at all, plain HTTP included). MDM's own clients
+/// get it through `net::bind_client`; the torrent session's (trackers, UPnP) through librqbit's
+/// `SessionOptions::configure_http_client` (mdm-torrent).
+pub fn configure(builder: reqwest::ClientBuilder) -> reqwest::ClientBuilder {
configure_with(builder, system_has_roots())
}
diff --git a/crates/torrent/Cargo.toml b/crates/torrent/Cargo.toml
index 82170fe6..8f18795d 100644
--- a/crates/torrent/Cargo.toml
+++ b/crates/torrent/Cargo.toml
@@ -11,6 +11,9 @@ publish.workspace = true
[dependencies]
# 9.1.0 and later: upstream's robustness fixes for what peers send.
librqbit = { version = "9.1.0", default-features = false, features = ["rust-tls"] }
+# The TLS setup of the session's HTTP clients (trackers, UPnP), MDM's own: a system without CA
+# certificates still starts a session (mdm_engine::tls).
+mdm-engine.workspace = true
flate2.workspace = true
# Reading librqbit's saved session (session.json) before it starts (lib.rs).
serde_json.workspace = true
diff --git a/crates/torrent/src/lib.rs b/crates/torrent/src/lib.rs
index 974b9e59..1386d942 100644
--- a/crates/torrent/src/lib.rs
+++ b/crates/torrent/src/lib.rs
@@ -546,6 +546,10 @@ impl Torrents {
env!("CARGO_PKG_VERSION_MAJOR"),
env!("CARGO_PKG_VERSION_MINOR")
)),
+ // Its HTTP clients (trackers, UPnP) with MDM's TLS setup: on a system without CA
+ // certificates librqbit's own can't be built and the session wouldn't start; with
+ // it, plain HTTP trackers work and HTTPS ones fail saying why (mdm_engine::tls).
+ configure_http_client: Some(Arc::new(mdm_engine::tls::configure)),
..Default::default()
};
prepare_saved(&cfg.state_dir.join("session"), proxied);
diff --git a/docs/torrents.md b/docs/torrents.md
index 7452389d..060c9473 100644
--- a/docs/torrents.md
+++ b/docs/torrents.md
@@ -115,6 +115,8 @@ The same window has the network switches (incoming connections, the port, UPnP,
MDM starts its torrent engine the first time you add a torrent. If you never use torrents, it never listens for peers.
+On a Linux system without CA certificates (a minimal install without the `ca-certificates` package), torrents still work: peers, the DHT and `http://` trackers. An `https://` tracker can't be checked there, so MDM skips it; install that package to use those too.
+
With a debrid account, torrents and magnet links can go to the service instead of to peers, and MDM downloads the files from it over HTTP: see [Torrents through the service](debrid.md#torrents-through-the-service).
## Next steps