tokio-xmpp: Add support for kernel TLS

This drastically improve the debuggability of the network parts, by
moving the task of encrypting/decrypting TLS packets from userland to
the kernel.  This makes them appear in clear in strace as sendto() and
recvfrom().

I introduced a new tls-rust-ktls feature which depends on both rustls
and ktls, but isn’t enabled by default since it probably isn’t available
on every computer.  It requires the tls kernel module to be loaded,
which then can offload encryption/decryption to dedicated hardware if
available.

I have tested this change on Linux 6.11 on a rk3588.
This commit is contained in:
Emmanuel Gil Peyrot 2024-09-11 20:34:38 +02:00 • committed by pep
commit c24275c098
2 changed files with 41 additions and 5 deletions

View file

@ -35,6 +35,7 @@ idna = { version = "1.0", optional = true}
native-tls = { version = "0.2", optional = true }
tokio-native-tls = { version = "0.3", optional = true }
tokio-rustls = { version = "0.26", optional = true }
ktls = { version = "6", optional = true }
[dev-dependencies]
env_logger = { version = "0.11", default-features = false, features = ["auto-color", "humantime"] }
@ -46,6 +47,7 @@ tokio-xmpp = { path = ".", features = ["insecure-tcp"]}
default = ["starttls-rust", "rustls-native-certs"]
starttls = ["dns"]
tls-rust = ["tokio-rustls"]
tls-rust-ktls = ["tls-rust", "ktls"]
tls-rust-native-certs = ["tls-rust", "rustls-native-certs"]
tls-rust-webpki-roots = ["tls-rust", "webpki-roots"]
tls-native = ["tokio-native-tls", "native-tls"]