Skip to content

Commit edbc84c

Browse files
feat(Mountain): Add TLS infrastructure and land:// protocol support
This commit introduces a comprehensive TLS certificate management system and custom URI scheme handler for the Mountain backend, enabling secure local HTTPS services and webview isolation. ## New Components ### CertificateManager (TLS Infrastructure) - Implements a complete PKI with root CA stored in OS keyring - Generates ECDSA P-256 server certificates signed by the CA - Supports automatic certificate renewal (30-day threshold) - Uses `rcgen` for certificate generation, `x509-parser` for validation - Integrates with `rustls` for TLS server configuration - Provides `anyhow` for improved error handling ### ServiceRegistry - Tracks mapping from `land://` domain names to local HTTP service ports - Thread-safe using `Arc<RwLock<HashMap>>` - Supports both HTTP and HTTPS service registration - Provides health check functionality for registered services - TLS certificates are provisioned on-demand via CertificateManager ### Scheme Handler (land:// protocol) - Handles `land://` custom URI scheme for webview isolation - Routes requests to local HTTP services via ServiceRegistry - Implements CORS headers for cross-origin requests - Provides static asset caching for performance - Supports HTTP/HTTPS forwarding to local services ### DNS Integration (Mist) - Starts Hickory DNS server on port 5380 (or fallback to random port) - Registers DNS commands: `dns_get_server_info`, `dns_get_zone_info`, `dns_get_forward_allowlist`, `dns_get_health_status`, `dns_resolve`, `dns_test_resolution`, `dns_health_check` - Provides DNS-based protocol resolution for land:// URIs ### Tauri Commands - TLS: `tls_initialize`, `tls_get_ca_cert`, `tls_get_server_cert_info`, `tls_renew_certificate`, `tls_get_all_certs`, `tls_check_cert_status` - DNS: Commands registered in Entry.rs for webview access ## Configuration Updates - tauri.conf.json: Updated CSP to allow `land:` protocol in connect-src, default-src, font-src, img-src - Cargo.toml: Changed binary path, added dev-dependencies and TLS/rustls dependencies - Entry.rs: Initializes ServiceRegistry, DNS server, and scheme handler in setup hook ## Tests Added - `tests/certificate_tests.rs`: Integration tests for CertificateManager - `tests/service_registry_tests.rs`: Service registration and health check tests This infrastructure enables the Land architecture to securely serve HTTPS to the webview while maintaining isolation through the `land://` custom protocol scheme.
1 parent 5f772e3 commit edbc84c

13 files changed

Lines changed: 4516 additions & 18 deletions

Cargo.toml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[[bin]]
22
name = "Mountain"
3-
path = "Source/Library.rs"
3+
path = "Source/main.rs"
44

55
[build-dependencies]
66
json5 = { workspace = true }
@@ -12,6 +12,10 @@ toml = { workspace = true }
1212
tonic-build = { workspace = true, features = ["transport"] }
1313
tonic-prost-build = { workspace = true }
1414

15+
[dev-dependencies]
16+
tokio-test = { workspace = true }
17+
futures = { workspace = true }
18+
1519
[dependencies]
1620
tauri = { workspace = true, features = [
1721
"compression",
@@ -28,13 +32,15 @@ tauri-plugin-localhost = { workspace = true }
2832
tauri-plugin-log = { workspace = true }
2933

3034
async-trait = { workspace = true }
35+
anyhow = { workspace = true } # TODO: Added for error handling in CertificateManager
3136
base64 = { workspace = true }
3237
chrono = { workspace = true, features = ["serde"] }
3338
colored = { workspace = true }
3439
Common = { workspace = true }
3540
dirs = { workspace = true }
3641
Echo = { workspace = true }
3742
Air = { workspace = true, optional = true }
43+
Mist = { workspace = true }
3844
env_logger = { workspace = true }
3945
futures-util = { workspace = true, features = ["sink", "std"] }
4046
globset = { workspace = true }
@@ -61,6 +67,12 @@ thiserror = { workspace = true }
6167
tokio = { workspace = true, features = ["full"] }
6268
tokio-tungstenite = { workspace = true, features = ["rustls-tls-native-roots"] }
6369
tokio-util = { workspace = true, features = ["full"] }
70+
pem = { workspace = true }
71+
rcgen = { workspace = true }
72+
p256 = { workspace = true }
73+
x509-parser = { workspace = true }
74+
rustls-pki-types = { workspace = true }
75+
rustls = { workspace = true } # TODO: Added for TLS configuration in CertificateManager
6476
toml = { workspace = true }
6577
tonic = { workspace = true }
6678
tonic-prost = { workspace = true }

0 commit comments

Comments
 (0)