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
etschannen
merged 10 commits into
apple:release-6.2
from
alexmiller-apple:certificate-refresh
Mar 6, 2020
Merged
Refresh certificates used for handshaking when they change on disk #2781
etschannen
merged 10 commits into
apple:release-6.2
from
alexmiller-apple:certificate-refresh
Mar 6, 2020
Conversation
This file contains 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
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
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.
ajbeamon
reviewed
Mar 6, 2020
Co-Authored-By: A.J. Beamon <ajbeamon@users.noreply.github.com>
etschannen
reviewed
Mar 6, 2020
flow/Net2.actor.cpp
Outdated
} | ||
#ifndef TLS_DISABLED | ||
boost::asio::ssl::context newContext(boost::asio::ssl::context::tls); | ||
ConfigureSSLContext( tlsConfig.loadSync(), &newContext ); |
There was a problem hiding this comment.
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
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.
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 wecan 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.