From 87440d5a23f0fd894d949295a7c1ff85043550fc Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 28 Oct 2026 22:55:51 +0100 Subject: v0.4.0: add first-time TLS setup and server help --- src/bin/server/main.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/bin/server/main.rs') diff --git a/src/bin/server/main.rs b/src/bin/server/main.rs index 8dba415..2770387 100644 --- a/src/bin/server/main.rs +++ b/src/bin/server/main.rs @@ -8,6 +8,25 @@ use std::thread; fn main() { let args = args::parse_args(); + + if args.init { + match zagan_bet::server::setup::init_identity(std::path::Path::new("."), "localhost") { + Ok(report) => { + println!("TLS identity created:"); + println!(" {} (PKCS#12, empty password)", report.identity.display()); + println!(" {} (private key)", report.key.display()); + println!(" {} (certificate)", report.cert.display()); + println!("\nStart the server with:\n cargo run --bin server"); + println!("Clients will trust this certificate on first contact."); + } + Err(error) => { + eprintln!("TLS setup failed:\n{error}"); + std::process::exit(1); + } + } + return; + } + let listener = match TcpListener::bind(format!("{}:{}", args.ip, args.port)) { Ok(l) => l, Err(e) => { @@ -16,7 +35,7 @@ fn main() { } }; - let tls = match tls::TlsServer::new("identity.p12", "key.pem", args.unsafe_mode) { + let tls = match tls::TlsServer::new("identity.p12") { Ok(t) => Arc::new(t), Err(e) => { eprintln!("Failed to initialize TLS: {}", e); -- cgit v1.2.3