Skip to content
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

Refresh certificates used for handshaking when they change on disk #2781

Merged
merged 10 commits into from Mar 6, 2020

Conversation

alexmiller-apple
Copy link
Contributor

@alexmiller-apple alexmiller-apple commented Mar 5, 2020

The first large chunk of this PR is a refactoring of how we specify
arguments TLS and how we load certificates:

The idea being that we keep around a TLSConfig that the configuration
that the user has provided, and then when we want to intialize an SSL
context, we ask the TLSConfig to load all certificates and return us a
LoadedTLSConfig that is a concrete set of certificate bytes in memory.

initTLS now just takes the in-memory bytes and applies them to the ssl
context.

This is a large refactor to lead up into certificate refeshing, where we
will periodically check for changes to the certificates, and then
re-load them and apply them to a new SSL context.

The second half is transforming the SSL context into an AsyncVar<Reference<ReferencedObject<SSLContext>>> so that we
can update the ssl context, but still keep the old one alive for open
connections, or connections that are undergoing a handshake.


This looks like a lot of code, but a pretty large chunk of it is a lot of copypaste, getters/setters, and mechanical transformations.

The idea being that we keep around a TLSConfig that the configuration
that the user has provided, and then when we want to intialize an SSL
context, we ask the TLSConfig to load all certificates and return us a
LoadedTLSConfig that is a concrete set of certificate bytes in memory.

initTLS now just takes the in-memory bytes and applies them to the ssl
context.

This is a large refactor to lead up into certificate refeshing, where we
will periodically check for changes to the certificates, and then
re-load them and apply them to a new SSL context.
@alexmiller-apple alexmiller-apple changed the title Refactor TLSParams into TLSConfig + LoadedTLSConfig Refresh certificates used for handshaking when they change on disk Mar 6, 2020
I went back and dug through all of the "what functions can throw what
types", and made sane decisions about them.  boost errors are
aggressively translated into FDB ones, whcih might result in multiple
lines of logging about errors, but this is in infrequently run code, so
it should be fine.
flow/TLSConfig.actor.cpp Outdated Show resolved Hide resolved
Co-Authored-By: A.J. Beamon <ajbeamon@users.noreply.github.com>
}
#ifndef TLS_DISABLED
boost::asio::ssl::context newContext(boost::asio::ssl::context::tls);
ConfigureSSLContext( tlsConfig.loadSync(), &newContext );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If loadSync() throws an io_error we should log a trace event and transform the error into a tls_error

@etschannen etschannen merged commit dbfc0cb into apple:release-6.2 Mar 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants