-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
simpler impl of dynamically swapping tls creds #2748
Conversation
This was done against v0.5. |
How does it know how to listen to the USR1 signal when we want to reload the certificate? |
@GentBinaku This default implementation doesn't reload the certificate. However, it allows you to provide a certificate loading implementation that will be used instead of the default by having the rocket builder |
@SergioBenitez It looks like in the master branch that the ability to specify a resolver is gone? |
@hcldan Nothing's changed with respect to that. The QUIC implementation uses an older rustls, but Rocket itself continues to use the same rustls. What issue are you running into? |
@SergioBenitez When I looked at master the TLSConfig seems to have changed. And the listener has moved files. I am not sure where the Are you in favor of this simpler implementation? If so, I will try again, but I don't want to devote much more time if you're going to want it done another way. |
I don't think this will work quite as-is, largely because the resolver can't be |
Check out the Can you push this past the finish line? What's left is some way for the user to register a resolver and for Rocket to pick it up. And docs and examples, of course. And later, an implementation of resolver that monitors for changes to the configured certs and provides an updated config if one is available. |
Copying from Matrix for posterity:
|
@SergioBenitez
I just wanted to clarify your meaning here. In my example the resolver is not async, no. Any other implementation (granted, I did not provide one that monitors the FS for changes) can poll, register for updates, whatever it wants and update some cached local current copy of those pieces of information. The one I was using periodically checks a secure store for updates and when found, will replace the values in the custom struct that will be used for the trait implementation. I thought it would be nice to keep the trait specific to the tls impl we are using and not try to wrap it in this project. And because of that, it was very unlikely that we would collide with another attempt at putting I think I like the fairing idea, because it really does belong mostly in the config of the server and not some ad-hoc state that we slap on. But I think I would prefer to see it referred to by the trait definition. I just took a look at your branch and I think while it might work, it is a bit overkill. The supplied resolver is handed over to the underlying tls impl and is used on every session negotiation. I'm not sure why the config would need to be "lazy" (unless there's some part of Rocket I'm not familiar with yet). When the server is launched, it should have all the info it needs via config. The resolver really shouldn't need to do anything special, be async, or be acquired in an async fashion (again, unless there's something that makes it necessary in Rocket). |
I see why it needs to be async. You've made the entire tls config dynamic. rusttls gave us a trait for doing that, why not just use that? |
I understand that the TLS library doesn't require it to be async, but the concern is that you might need to perform some kind of async operation, even a minimal one like taking a lock or reading from a channel, and be unable to do so. It's possible that this wouldn't be required for any implementation, but there's no evidence to suggest this one way or another as it stands. In this sense, making it async is the "safe" choice. Perhaps we need to implement a few "obvious" use cases to get some experience here.
How does it perform the replacement atomically?
The amount of confusion that can be caused by conflicting managed state types is considerable, while what we need to ensure that such a thing doesn't happen is roughly 0 lines of code: one private type in managed state versus another. There's no disadvantage to doing this, as far as I can tell.
Configuration needs to be "lazy," in the sense that rustls calls it lazy, to be able to dynamically select configuration based on the client. This is critical for being able to do something like SNI based certificate negotiation. This happens during the TLS handshake. |
This commit introduces the ability to dynamically select a TLS configuration based on the client's TLS hello. Added `Authority::set_port()`. Various `Config` structures for listeners removed. `UdsListener` is now `UnixListener`. `Bindable` removed in favor of new `Bind`. `Connection` requires `AsyncRead + AsyncWrite` again The `Debug` impl for `Endpoint` displays the underlying address in plaintext. `Listener` must be `Sized`. `tls` listener moved to `tls::TlsListener` The preview `quic` listener no longer implements `Listener`. All built-in listeners now implement `Bind<&Rocket>`. Clarified docs for `mtls::Certificate` guard. No reexporitng rustls from `tls`. Added `TlsConfig::server_config()`. Added some future helpers: `race()` and `race_io()`. Fix an issue where the logger wouldn't respect a configuration during error printing. Added Rocket::launch_with(), launch_on(), bind_launch(). Added a default client.pem to the TLS example. Revamped the testbench. Added tests for TLS resolvers, MTLS, listener failure output. TODO: clippy. TODO: UDS testing. Resolves #2730. Resolves #2363. Closes #2748. Closes #2683. Closes #2577.
This commit introduces the ability to dynamically select a TLS configuration based on the client's TLS hello. Added `Authority::set_port()`. Various `Config` structures for listeners removed. `UdsListener` is now `UnixListener`. `Bindable` removed in favor of new `Bind`. `Connection` requires `AsyncRead + AsyncWrite` again The `Debug` impl for `Endpoint` displays the underlying address in plaintext. `Listener` must be `Sized`. `tls` listener moved to `tls::TlsListener` The preview `quic` listener no longer implements `Listener`. All built-in listeners now implement `Bind<&Rocket>`. Clarified docs for `mtls::Certificate` guard. No reexporitng rustls from `tls`. Added `TlsConfig::server_config()`. Added some future helpers: `race()` and `race_io()`. Fix an issue where the logger wouldn't respect a configuration during error printing. Added Rocket::launch_with(), launch_on(), bind_launch(). Added a default client.pem to the TLS example. Revamped the testbench. Added tests for TLS resolvers, MTLS, listener failure output. TODO: clippy. TODO: UDS testing. Resolves #2730. Resolves #2363. Closes #2748. Closes #2683. Closes #2577.
This commit introduces the ability to dynamically select a TLS configuration based on the client's TLS hello. Added `Authority::set_port()`. Various `Config` structures for listeners removed. `UdsListener` is now `UnixListener`. `Bindable` removed in favor of new `Bind`. `Connection` requires `AsyncRead + AsyncWrite` again The `Debug` impl for `Endpoint` displays the underlying address in plaintext. `Listener` must be `Sized`. `tls` listener moved to `tls::TlsListener` The preview `quic` listener no longer implements `Listener`. All built-in listeners now implement `Bind<&Rocket>`. Clarified docs for `mtls::Certificate` guard. No reexporitng rustls from `tls`. Added `TlsConfig::server_config()`. Added some future helpers: `race()` and `race_io()`. Fix an issue where the logger wouldn't respect a configuration during error printing. Added Rocket::launch_with(), launch_on(), bind_launch(). Added a default client.pem to the TLS example. Revamped the testbench. Added tests for TLS resolvers, MTLS, listener failure output. TODO: clippy. TODO: UDS testing. Resolves #2730. Resolves #2363. Closes #2748. Closes #2683. Closes #2577.
closes #2363
reference: #2683