2.8 KiB
2.8 KiB
Plan for TLS Termination and Dynamic Port Handling
Task
Modify the l4p (layer 4 proxy) to perform TLS termination and handle dynamic/random ports for backend services. The backend services are on a specific IPv6 address, and the user can dynamically determine the hostname of these services in the format "https://{port}.my-host". The proxy should listen on port 443 and use SNI for routing.
Completed Actions
- Added
tokio-rustls,rustls-pemfile,anyhowdependencies toCargo.toml. - Modified
src/config/config_v1.rsto includeTlsTerminationConfig,CertificateConfig,SniCertificateConfigstructs and updatedServerConfig. - Created
src/tls.rs(multiple iterations due to compilation issues). - Integrated
anyhow::Resultinto various functions and importedContexttosrc/servers/mod.rs. - Corrected imports in
src/main.rs,src/servers/mod.rs,src/servers/protocol/tcp.rs. - Removed
mod tls;fromsrc/servers/protocol/mod.rs. - Attempted to fix various compilation errors related to
rustlsAPI changes, lifetime issues, andtokiotask handling. - Changed
handle.await??;to explicit match for debugging purposes.
Current State (with persistent errors)
The code currently has compilation errors, primarily related to:
src/servers/mod.rs: Still showing an error formap_errnot found for unit type(). This arises from the complex doubleResulthandling (Result<anyhow::Result<()>, JoinError>) when awaiting spawned tasks.src/tls.rs: Facing issues withrustls::pki_types::PrivateKeyDerandCertificateDerconversions, specifically for ensuring'staticlifetimes and incorrect method usages liketo_vec()oras_ref(), orinto_owned()methods not existing for certain types. Theborrowed data escapes outside of functionerror indicates deeper lifetime mismatches.
Next Steps (Requires Manual Intervention)
- Refactor
src/servers/mod.rserror handling: The currentmatch handle.awaitblock needs to be carefully reviewed to ensure correct unwraping of the nestedResulttypes and proper error propagation fromtokio::task::JoinErrortoanyhow::Error. - Re-evaluate
src/tls.rsrustls::pki_typesusage: A deeper understanding ofrustls-pki-typescrate and itsCertificateDerandPrivateKeyDerlifetimes and conversion methods is needed. The specific error messageno method named to_vec found for struct PrivatePkcs8KeyDeris a key indicator of incorrect usage. - Review
rustlsversion and documentation: It might be helpful to review therustlsandtokio-rustlsdocumentation for version-specific changes and best practices regardingpki_typesand asynchronous error handling.
This commit contains the work in progress as of the current session, including these unresolved errors, to allow for external review and debugging.