feat: add redis-compatible tls support - #58
Merged
Merged
Conversation
add tokio-rustls, rustls, and rustls-pemfile for upcoming tls support. uses rustls 0.23 with aws-lc-rs crypto backend by default.
new tls.rs module provides: - TlsConfig struct for cert/key paths and mTLS settings - load_tls_acceptor() to build tokio-rustls TlsAcceptor - clear error messages for common issues (file not found, invalid PEM) - optional client certificate verification via ca_cert_file
add redis-compatible tls flags: - --tls-port: port for tls connections - --tls-cert-file: server certificate path - --tls-key-file: server private key path - --tls-ca-cert-file: ca cert for client verification - --tls-auth-clients: require client certs (yes/no) validates that cert and key are provided when tls-port is set.
update handle() in connection.rs and concurrent_handler.rs to accept any type implementing AsyncRead + AsyncWrite + Unpin. this enables the same handler code to work with both TcpStream and TlsStream. moved set_nodelay() call to server.rs accept loop so it applies to the underlying tcp socket before any tls handshake.
- run() and run_concurrent() now accept optional TLS config - when TLS is configured: - loads certificate and key via load_tls_acceptor() - binds separate TLS listener on --tls-port - performs TLS handshake after TCP accept - passes TlsStream to generic connection handler - both plain TCP and TLS share the same: - connection semaphore (combined limit) - ServerContext and metrics - graceful shutdown handling - TLS handshake failures logged as warnings, connection dropped
- add tls to features list - document all tls cli flags in configuration table - add tls server startup example - add redis-cli tls connection examples
the doc comment for glob_match was accidentally placed above format_float. moved it to the correct location.
kacy
added a commit
that referenced
this pull request
Feb 11, 2026
* feat: add tls dependencies add tokio-rustls, rustls, and rustls-pemfile for upcoming tls support. uses rustls 0.23 with aws-lc-rs crypto backend by default. * feat: add tls config module new tls.rs module provides: - TlsConfig struct for cert/key paths and mTLS settings - load_tls_acceptor() to build tokio-rustls TlsAcceptor - clear error messages for common issues (file not found, invalid PEM) - optional client certificate verification via ca_cert_file * feat: add tls cli arguments add redis-compatible tls flags: - --tls-port: port for tls connections - --tls-cert-file: server certificate path - --tls-key-file: server private key path - --tls-ca-cert-file: ca cert for client verification - --tls-auth-clients: require client certs (yes/no) validates that cert and key are provided when tls-port is set. * refactor: make connection handlers generic over stream type update handle() in connection.rs and concurrent_handler.rs to accept any type implementing AsyncRead + AsyncWrite + Unpin. this enables the same handler code to work with both TcpStream and TlsStream. moved set_nodelay() call to server.rs accept loop so it applies to the underlying tcp socket before any tls handshake. * feat: add tls listener to server - run() and run_concurrent() now accept optional TLS config - when TLS is configured: - loads certificate and key via load_tls_acceptor() - binds separate TLS listener on --tls-port - performs TLS handshake after TCP accept - passes TlsStream to generic connection handler - both plain TCP and TLS share the same: - connection semaphore (combined limit) - ServerContext and metrics - graceful shutdown handling - TLS handshake failures logged as warnings, connection dropped * docs: add tls configuration to readme - add tls to features list - document all tls cli flags in configuration table - add tls server startup example - add redis-cli tls connection examples * fix: correct misplaced doc comment for glob_match the doc comment for glob_match was accidentally placed above format_float. moved it to the correct location. * style: apply cargo fmt to tls.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary
--tls-port) alongside plain TCP--tls-ca-cert-fileand--tls-auth-clientstest plan
design considerations
handle()accepts anyAsyncRead + AsyncWrite + Unpin, enabling code reuse between TCP and TLS