feat(gateway): TLS 1.3 only control plane and LNEx v3 channel-bound handshake
Replace the X25519/HKDF/ChaCha20 TCP layer with rustls TLS 1.3 (ALPN vnox-lnex/3). Auto-generate a self-signed certificate keyed by the server identity or load an operator certificate, publish the SPKI fingerprint, bind HELLO and AUTH signatures to the TLS exporter, reject plaintext, TLS 1.2 and LNEx v2 peers with an explicit error. BREAKING: protocol v3.
This commit is contained in:
parent
41cc0fe632
commit
ff051b7480
45 changed files with 1322 additions and 806 deletions
|
|
@ -102,12 +102,11 @@ pub async fn handle<S: AsyncRead + AsyncWrite + Unpin>(
|
|||
.iter()
|
||||
.map(info)
|
||||
.collect();
|
||||
return io::send_encrypted(
|
||||
return io::send_frame(
|
||||
ctx.stream,
|
||||
PacketId::WebhookListResult,
|
||||
ctx.seq,
|
||||
&to_payload(&WebhookListResult { hooks, request_id }),
|
||||
ctx.crypto,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
|
@ -221,7 +220,7 @@ pub async fn handle<S: AsyncRead + AsyncWrite + Unpin>(
|
|||
}
|
||||
h
|
||||
};
|
||||
io::send_encrypted(
|
||||
io::send_frame(
|
||||
ctx.stream,
|
||||
PacketId::WebhookResult,
|
||||
ctx.seq,
|
||||
|
|
@ -230,7 +229,6 @@ pub async fn handle<S: AsyncRead + AsyncWrite + Unpin>(
|
|||
secret,
|
||||
request_id,
|
||||
}),
|
||||
ctx.crypto,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
|
@ -240,7 +238,7 @@ async fn error<S: AsyncRead + AsyncWrite + Unpin>(
|
|||
code: ErrorCode,
|
||||
msg: &str,
|
||||
) -> Result<()> {
|
||||
io::send_encrypted(
|
||||
io::send_frame(
|
||||
ctx.stream,
|
||||
PacketId::WebhookErrorResult,
|
||||
ctx.seq,
|
||||
|
|
@ -249,7 +247,6 @@ async fn error<S: AsyncRead + AsyncWrite + Unpin>(
|
|||
code: code as u32,
|
||||
message: msg.into(),
|
||||
}),
|
||||
ctx.crypto,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ fn rate_limit_and_content_boundaries() {
|
|||
|
||||
#[tokio::test]
|
||||
async fn lnex_management_rejects_stranger_and_creates_only_for_owner() {
|
||||
use crate::proto::{PacketId, SessionCrypto, WebhookRequest, flags, to_payload};
|
||||
use crate::proto::{PacketId, WebhookRequest, to_payload};
|
||||
let (s, _, _) = fixture().await;
|
||||
let req = WebhookRequest {
|
||||
id: String::new(),
|
||||
|
|
@ -343,13 +343,11 @@ async fn lnex_management_rejects_stranger_and_creates_only_for_owner() {
|
|||
("owner", PacketId::WebhookResult),
|
||||
] {
|
||||
let session = session::create(&s.sessions, user.into(), user.into()).await;
|
||||
let crypto = SessionCrypto::derive(&[3; 32], &session.session_id);
|
||||
let (mut stream, mut peer) = tokio::io::duplex(65536);
|
||||
let mut seq = 0;
|
||||
let mut ctx = crate::handler::Ctx {
|
||||
stream: &mut stream,
|
||||
seq: &mut seq,
|
||||
crypto: &crypto,
|
||||
state: &s,
|
||||
};
|
||||
management::handle(
|
||||
|
|
@ -362,7 +360,10 @@ async fn lnex_management_rejects_stranger_and_creates_only_for_owner() {
|
|||
.unwrap();
|
||||
let (header, _) = crate::net::io::read_packet(&mut peer).await.unwrap();
|
||||
assert_eq!(header.packet_id, expected as u16);
|
||||
assert_ne!(header.flags & flags::ENCRYPTED, 0);
|
||||
assert_eq!(
|
||||
header.flags, 0,
|
||||
"TLS protects the stream; frames carry no flags"
|
||||
);
|
||||
}
|
||||
let hooks = s.storage.hooks("target").await.unwrap();
|
||||
assert_eq!(hooks.len(), 2);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue