feat(client): TLS 1.3 control connection with SPKI pinning and LNEx v3

Replace the custom X25519/HKDF/ChaCha20 TCP layer with rustls (TLS 1.3 only,
ALPN vnox-lnex/3, no plaintext or fallback). Add a trust store (pin, trust on
first use, public CA), block changed fingerprints and identities, bind the
Ed25519 auth signature to the TLS exporter, add RU/EN trust dialog and
update the interop test and e2e voice tool.
This commit is contained in:
Loki 2026-10-24 22:05:19 +02:00
parent 5f594046a6
commit 29883a3187
31 changed files with 2085 additions and 567 deletions

View file

@ -382,6 +382,30 @@ pub fn sync_connect(window: &MainWindow, state: &UiState) {
ConnState::Connecting | ConnState::Reconnecting { .. }
));
window.set_auto_reconnect(state.auto_reconnect);
{
use crate::ui::state::TrustPromptKind;
let (kind, address, received, expected) = match &state.trust_prompt {
None => (0, "", "", ""),
Some(prompt) => (
match prompt.kind {
TrustPromptKind::FirstUse => 1,
TrustPromptKind::FingerprintChanged => 2,
TrustPromptKind::IdentityChanged => 3,
},
prompt.address.as_str(),
prompt.received.as_str(),
prompt.expected.as_str(),
),
};
window.set_trust_kind(kind);
window.set_trust_address(SharedString::from(address));
window.set_trust_received(SharedString::from(
vnox_client::net::trust::display_fingerprint(received),
));
window.set_trust_expected(SharedString::from(
vnox_client::net::trust::display_fingerprint(expected),
));
}
if let ConnState::Connected { ref node_name, .. } = state.conn {
window.set_node_name(SharedString::from(node_name.as_str()));
} else if matches!(state.conn, ConnState::Disconnected) {

View file

@ -16,6 +16,14 @@ export component ConnectScreen inherits Rectangle {
callback remove-bookmark(string);
callback add-bookmark(string);
callback open-settings();
// 0 none, 1 first use, 2 certificate fingerprint changed, 3 server identity changed
in property <int> trust-kind: 0;
in property <string> trust-address;
in property <string> trust-received;
in property <string> trust-expected;
callback trust-accept();
callback trust-forget();
callback trust-dismiss();
background: Theme.bg-base;
VerticalLayout {
padding: 32px; spacing: 22px;
@ -86,4 +94,50 @@ export component ConnectScreen inherits Rectangle {
Rectangle { vertical-stretch: 1; }
Text { text: @tr("Your server. Your community."); color: Theme.text-disabled; font-size: Math.max(11px, Theme.font-size * 0.75); horizontal-alignment: center; }
}
if root.trust-kind != 0 : Rectangle {
background: #000000a0;
TouchArea { }
HorizontalLayout {
Rectangle { horizontal-stretch: 1; }
VerticalLayout {
Rectangle { vertical-stretch: 1; }
Rectangle {
width: 560px;
height: trust-card.preferred-height;
background: Theme.bg-surface; border-radius: 14px;
border-width: 1px; border-color: root.trust-kind == 1 ? Theme.border : Theme.danger;
trust-card := VerticalLayout {
padding: 26px; spacing: 12px; alignment: start;
Text {
text: root.trust-kind == 1 ? @tr("Trust this server?") : root.trust-kind == 2 ? @tr("Server fingerprint changed") : @tr("Server identity changed");
color: root.trust-kind == 1 ? Theme.text-primary : Theme.danger;
font-size: Math.max(11px, Theme.font-size * 1.375); font-weight: 600; wrap: word-wrap;
}
Text {
text: root.trust-kind == 1
? @tr("This is the first connection to this server. Its certificate is not issued by a public authority, so Vnox cannot verify it automatically. Compare the fingerprint with the one published by the server owner and trust it only if they match.")
: root.trust-kind == 2
? @tr("The certificate of this server is different from the one you trusted before. This can mean an attack on your connection, or the owner reinstalled the server. The connection was blocked and nothing was sent. Ask the owner whether the change is expected.")
: @tr("The server proved a different identity key than the one you trusted before. The connection was blocked and nothing was sent. Ask the owner whether the change is expected.");
color: Theme.text-secondary; font-size: Math.max(11px, Theme.font-size * 0.8125); wrap: word-wrap;
}
Text { text: @tr("Server address"); color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); }
Text { text: root.trust-address; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.875); wrap: word-wrap; }
if root.trust-kind != 1 : Text { text: @tr("Previously trusted fingerprint"); color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); }
if root.trust-kind != 1 : Text { text: root.trust-expected; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.75); wrap: word-wrap; }
Text { text: root.trust-kind == 1 ? @tr("Fingerprint (SHA-256)") : @tr("Received fingerprint"); color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); }
Text { text: root.trust-received; color: root.trust-kind == 1 ? Theme.accent : Theme.danger; font-size: Math.max(11px, Theme.font-size * 0.75); wrap: word-wrap; }
HorizontalLayout {
spacing: 9px; alignment: end;
if root.trust-kind != 1 : ActionButton { text: @tr("Forget this server"); danger: true; clicked => { root.trust-forget(); } }
ActionButton { text: root.trust-kind == 1 ? @tr("Cancel") : @tr("Close"); clicked => { root.trust-dismiss(); } }
if root.trust-kind == 1 : ActionButton { text: @tr("Trust and connect"); active: true; clicked => { root.trust-accept(); } }
}
}
}
Rectangle { vertical-stretch: 1; }
}
Rectangle { horizontal-stretch: 1; }
}
}
}

View file

@ -71,6 +71,11 @@ export component MainWindow inherits Window {
in-out property <bool> connecting: false;
in-out property <bool> auto-reconnect: false;
in-out property <string> node-name: "";
// 0 none, 1 first use, 2 certificate fingerprint changed, 3 server identity changed
in-out property <int> trust-kind: 0;
in-out property <string> trust-address: "";
in-out property <string> trust-received: "";
in-out property <string> trust-expected: "";
in-out property <string> identity-pubkey: "";
in-out property <bool> vault-enabled: false;
@ -155,6 +160,9 @@ export component MainWindow inherits Window {
callback connect(string);
callback remove-bookmark(string);
callback add-bookmark(string);
callback trust-accept();
callback trust-forget();
callback trust-dismiss();
callback close-settings();
callback set-passphrase(string, string);
callback remove-passphrase();
@ -177,6 +185,13 @@ export component MainWindow inherits Window {
connecting: root.connecting;
auto-reconnect <=> root.auto-reconnect;
node-name: root.node-name;
trust-kind: root.trust-kind;
trust-address: root.trust-address;
trust-received: root.trust-received;
trust-expected: root.trust-expected;
trust-accept => { root.trust-accept(); }
trust-forget => { root.trust-forget(); }
trust-dismiss => { root.trust-dismiss(); }
open-settings => { root.open-settings(); }
address-edited(text) => { root.address-edited(text); }
auto-reconnect-changed(value) => { root.auto-reconnect-changed(value); }

View file

@ -12,6 +12,7 @@ impl Default for UiState {
bookmarks: default_bookmarks(),
selected_bookmark: 0,
status_msg: None,
trust_prompt: None,
channels: Vec::new(),
active_channel: None,
messages: Default::default(),

View file

@ -4,7 +4,7 @@ mod navigation;
mod types;
pub use models::{Channel, ChatMessage, DmConversation, FriendState, GuildState, NodeBookmark};
pub use types::{ConnState, UiState, VoiceUiState};
pub use types::{ConnState, TrustPrompt, TrustPromptKind, UiState, VoiceUiState};
use models::bookmark_label_from_address;

View file

@ -24,6 +24,25 @@ pub enum ConnState {
},
}
/// A pending server trust decision (first use or blocked fingerprint change).
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct TrustPrompt {
pub kind: TrustPromptKind,
/// Trust store key, `host:port`.
pub address: String,
/// Lower-case hex value that was received.
pub received: String,
/// Lower-case hex value that was trusted before (changed fingerprint or identity).
pub expected: String,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum TrustPromptKind {
FirstUse,
FingerprintChanged,
IdentityChanged,
}
pub struct UiState {
pub appearance: crate::ui::appearance::AppearancePreferences,
pub conn: ConnState,
@ -31,6 +50,7 @@ pub struct UiState {
pub bookmarks: Vec<super::NodeBookmark>,
pub selected_bookmark: usize,
pub status_msg: Option<crate::ui::i18n::Message>,
pub trust_prompt: Option<TrustPrompt>,
pub channels: Vec<super::Channel>,
pub active_channel: Option<String>,

View file

@ -75,6 +75,41 @@ pub fn process_net_events(state: &mut AppState) {
});
}
}
NetEvent::TrustProblem(problem) => {
use crate::ui::state::{TrustPrompt, TrustPromptKind};
use vnox_client::net::TrustProblem;
state.ui.trust_prompt = Some(match problem {
TrustProblem::Untrusted {
address,
fingerprint,
} => TrustPrompt {
kind: TrustPromptKind::FirstUse,
address,
received: fingerprint,
expected: String::new(),
},
TrustProblem::FingerprintChanged {
address,
expected,
actual,
} => TrustPrompt {
kind: TrustPromptKind::FingerprintChanged,
address,
received: actual,
expected,
},
TrustProblem::IdentityChanged {
address,
expected,
actual,
} => TrustPrompt {
kind: TrustPromptKind::IdentityChanged,
address,
received: actual,
expected,
},
});
}
NetEvent::Disconnected { reason, will_retry } => {
if let Some(ui) = &state.webhooks {
ui.disconnected();
@ -97,10 +132,14 @@ pub fn process_net_events(state: &mut AppState) {
state.ui.active_channel = None;
state.ui.user_names.clear();
state.ui.rtt_ms = None;
state.ui.status_msg = Some(crate::ui::i18n::Message::with(
"Disconnected: {reason}",
vec![("reason", reason.to_string())],
));
state.ui.status_msg = if state.ui.trust_prompt.is_some() {
None
} else {
Some(crate::ui::i18n::Message::with(
"Disconnected: {reason}",
vec![("reason", reason.to_string())],
))
};
}
if !will_retry {
state.ui.dm_conversations.clear();
@ -348,6 +387,7 @@ fn process_net_event(ui: &mut UiState, net: &NetHandle, event: NetEvent) {
| NetEvent::WebhookError(_) => unreachable!("handled before generic UI dispatch"),
NetEvent::Connected { .. }
| NetEvent::Disconnected { .. }
| NetEvent::TrustProblem(_)
| NetEvent::Reconnecting { .. }
| NetEvent::VoicePacket { .. }
| NetEvent::E2eeDmKeyExchange { .. }