-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TSL support #584
TSL support #584
Conversation
…m server with timeouts Two levels of wrappers for the Axum server: Custom (with timeouts) -> axum-server -> axum
- Use axum-server isntead of directly the axum crate (like in the tracker). - Add wrapper to axum-server to enable timeouts.
…oml file ```toml [net] port = 3001 [net.tsl] ssl_cert_path = "./storage/index/lib/tls/localhost.crt" ssl_key_path = "./storage/index/lib/tls/localhost.key" ``` ```json { "net": { "port": 3001, "tsl": { "ssl_cert_path": "./storage/index/lib/tls/localhost.crt", "ssl_key_path": "./storage/index/lib/tls/localhost.key" } } } ``` The TSL configuration is optional, but if you have that table (dict), it must contain the fields. This is an invalid configuration: ``` [net.tsl] ssl_cert_path = "" ssl_key_path = "" ``` See torrust/torrust-tracker#853.
You can provide a certificate and certificate key files to run the API with HTTPs.
I can run the API with a self-signed certificate as described in:
However, I can't load any page. With * Trying 127.0.0.1:3001...
* Connected to localhost (127.0.0.1) port 3001 (#0)
* ALPN: offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* CAfile: /etc/ssl/certs/ca-certificates.crt
* CApath: /etc/ssl/certs
* OpenSSL/3.0.8: error:0A00010B:SSL routines::wrong version number
* Closing connection 0
curl: (35) OpenSSL/3.0.8: error:0A00010B:SSL routines::wrong version number With Firefox: I've tried with these files:
Generated with:
And also with certificates from https://github.com/programatik29/axum-server/tree/master/examples/self-signed-certs:
This is an example from axum-server: https://github.com/programatik29/axum-server/blob/master/examples/from_std_listener_rustls.rs I think I'm doing the same. @da2ce7 any idea? |
I made it work by commenting on the TimeoutAcceptor. It's a custom acceptor that introduces timeouts for the first client request after opening the HTTP connection. match tls {
Some(tls) => custom_axum::from_tcp_rustls_with_timeouts(socket, tls)
.handle(handle)
//.acceptor(TimeoutAcceptor)
.serve(router.into_make_service_with_connect_info::<std::net::SocketAddr>())
.await
.expect("API server should be running"),
None => custom_axum::from_tcp_with_timeouts(socket)
.handle(handle)
.acceptor(TimeoutAcceptor)
.serve(router.into_make_service_with_connect_info::<std::net::SocketAddr>())
.await
.expect("API server should be running"),
}; I added this TimeAcceptor to the Tracker, but I did not check that the TSL worked fine. I have to open an issue there to check it. I will probably not work. I'm going to remove that |
ACK 5d9e068 |
TSL does work with the TimeoutAccetor. How to enabled TSL for development with: ``` [net] port = 3001 [net.tsl] ssl_cert_path = "./storage/index/lib/tls/localhost.crt" ssl_key_path = "./storage/index/lib/tls/localhost.key" ``` You can fin the certificates in `./share/tsl`. This means there is no timeout for the first client request when you use TSL. The way to test tiemouts is: 1. Open a connection using telnet: `telnet 127.0.0.1 3001` 2. Wait 5 seconds. The connection should be closed after 5 seconds. That's what the TimeoutAcceptor does. Without the TimeoutAcceptor the connection will remain open until the client closes it.
5d9e068
to
1afe234
Compare
TSL support. Allow using HTTPs providing the cert and cert key.
TOML
JSON
The TSL configuration is optional, but if you have that toml table (
[net.tsl]
), it must contain the fields. This is an invalid configuration:See torrust/torrust-tracker#853.
Subtasks