-
Notifications
You must be signed in to change notification settings - Fork 260
New RPCConnectionManager: Single unified manager, no ringbuffer, OpenSSL-owned sockets
#8117
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
Draft
Eddy Ashton (eddyashton)
wants to merge
75
commits into
main
Choose a base branch
from
rpc_connection_manager
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
75 commits
Select commit
Hold shift + click to select a range
aaab091
Add LoopExecutor
eddyashton 113d71c
checkpoint: OpenSSL-native transport subsystem (green) before RPC cut…
eddyashton b543bf7
WIP: OpenSSL-native RPC cutover - sessions plaintext+SessionWriter, t…
eddyashton aea2b27
OpenSSL-native RPC cutover: relocate RPC listening into enclave lib, …
eddyashton 45a1a27
Wire outbound client TLS (peer CA verification + client cert via tls:…
eddyashton 82fc341
Listener resolves bind address via getaddrinfo (hostnames + IPv6), fi…
eddyashton bbb9d3b
Graceful connection close: flush buffered output before teardown so a…
eddyashton 8d81979
Fix spurious connection closes: clear OpenSSL thread-local error queu…
eddyashton 592fc5f
Restore UDP echo via DatagramServer (UDP socket in epoll loop) + echo…
eddyashton d9f0a51
Format pass
eddyashton 396cfa8
Cleanup: remove dead code from cutover - LoopExecutor (unused), orpha…
eddyashton 50c47b7
Removed unused SNI
eddyashton d2a3b8a
Remove unused function
eddyashton 55422b6
Idle connection timeout: move idle_connection_timeout HostConfig->CCF…
eddyashton 6591f98
Restore custom protocol sessions on OpenSSL RPC path
eddyashton a0a4972
Format
eddyashton 61be04b
Fix RPC session metrics for session-initiated closes
eddyashton 3d5b4c2
Address RPC transport review feedback
eddyashton 66fbfb5
Format
eddyashton 6f38be3
Update comments
eddyashton e15f4c4
buh
eddyashton 5ca4413
Handle open ledger chunks in SNP recovery checks
eddyashton ebf2bd8
Fix JWT tests - prefer to bind on IPv4
eddyashton d0dbfdf
Format
eddyashton eb982cf
Stop RPC transports before host shutdown
eddyashton c41e1c3
Report outbound client connection closes
eddyashton 59da3e7
Add some debug logging
eddyashton eb18b7d
Remove debug
eddyashton 0a42036
Remove more TEMP debug logging
eddyashton b539ff4
Add CURLE_SSL_CONNECT_ERROR to transient transport error classifications
eddyashton 05da0bc
Merge cleanup N
eddyashton 8866b05
Restore explicit-port-before-ephemeral RPC interface bind ordering
eddyashton f70101a
Merge branch 'main' of https://github.com/microsoft/CCF into rpc_conn…
eddyashton f7ee1ff
Better context management - an AL4 fix
eddyashton 7b83c5e
Merge branch 'main' into rpc_connection_manager
eddyashton 97ca674
Refactor HTTP session classes to directly inherit from ccf::Plaintext…
eddyashton 3de7b3f
Rewrite docs, audit compat with previous
eddyashton 43b55d4
Remove some dead code
eddyashton 77d8aa3
More unification and cleanup
eddyashton 46b59b6
Merge branch 'main' of https://github.com/microsoft/CCF into rpc_conn…
eddyashton eee4afe
Merge branch 'main' into rpc_connection_manager
achamayou 3bd9f7e
Use uv_poll_t rather than a custom epoll loop
eddyashton 8b6a09c
Merge branch 'main' of https://github.com/microsoft/CCF into rpc_conn…
eddyashton cb13dc2
Merge branch 'rpc_connection_manager' of https://github.com/microsoft…
eddyashton 6834e42
Tidy
eddyashton c1f13d0
TSAN the unit test
eddyashton 511532f
Tidier
eddyashton 72c1b22
Handle empty port case in OpenSSL and Datagram server initialization
eddyashton e2d94ca
Disable Nagle on inbound RPC connections
4da54d7
Merge branch 'main' into rpc_connection_manager
achamayou ab55b28
Fix thread dispatch
eddyashton 8a810fe
Merge branch 'rpc_connection_manager' of https://github.com/microsoft…
eddyashton 85b11a4
Review tidying
eddyashton c50ab93
More fixes? Impossible to know at this point
eddyashton 0a3a178
Merge branch 'main' into rpc_connection_manager
achamayou 46a4df2
Reduce copies
eddyashton 71b8c53
Merge branch 'main' into rpc_connection_manager
achamayou d7d2ea4
Restore inbound backpressure
eddyashton 4e96084
More review tidy-up
eddyashton 3769e9e
Merge branch 'rpc_connection_manager' of https://github.com/microsoft…
eddyashton 9ad1eb0
Merge branch 'main' of https://github.com/microsoft/CCF into rpc_conn…
eddyashton 0af7572
More review feedback cleanup
eddyashton 2fd0a95
Format and pyproject version
eddyashton c82475f
Wake zero-worker enclaves for queued TLS work
eddyashton 8ae80ff
Merge branch 'main' into rpc_connection_manager
eddyashton 66371ba
Update changelog and improve OpenSSL server tests and header file
eddyashton a7f22b3
Update CMakeLists and improve rpc_tls_client and openssl_server_test …
eddyashton b0d7982
Update changelog and enhance HTTP curl functionality and tests
eddyashton 57c7504
Merge branch 'main' into rpc_connection_manager
achamayou bfa22a5
Synchronize public AFT state queries
eddyashton 1a0469e
Refactor raft.h to improve code clarity and reduce complexity
eddyashton 063faf5
Merge branch 'main' into rpc_connection_manager
eddyashton 59dac99
Merge branch 'main' into rpc_connection_manager
achamayou a009f1a
Remove bundled AFT synchronization changes
eddyashton b399062
Apply suggestion from @achamayou
eddyashton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # TLS certificate helpers (client tooling only) | ||
|
|
||
| These helpers configure an OpenSSL client with a trusted root and an owned | ||
| identity: | ||
|
|
||
| - `CA` parses one or more root certificates and populates an `SSL_CTX`'s | ||
| trusted certificate store. | ||
| - `Cert` holds a client's own certificate and private key, and applies them | ||
| (and the peer verification mode) to an `SSL_CTX` or `SSL`. | ||
|
|
||
| Their only consumer is `TlsClient` in the parent directory, used by the C++ | ||
| test and perf clients. **No node code uses them.** The node's inbound TLS is | ||
| handled by `src/host/tls`, which builds its own `SSL_CTX`, and its outbound | ||
| requests go through libcurl. |
File renamed without changes.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the Apache 2.0 License. | ||
|
|
||
| // Unit tests for the certificate helpers used by the C++ test clients, which | ||
| // configure an OpenSSL context and connection with a trusted root and an owned | ||
| // identity. The TLS transport itself is tested in | ||
| // src/host/test/openssl_server_test.cpp. | ||
|
|
||
| #include "ccf/crypto/ec_key_pair.h" | ||
| #include "ccf/crypto/verifier.h" | ||
| #include "ccf/ds/x509_time_fmt.h" | ||
| #include "clients/tls/ca.h" | ||
| #include "clients/tls/cert.h" | ||
| #include "crypto/certs.h" | ||
|
|
||
| #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN | ||
| #include <chrono> | ||
| #include <doctest/doctest.h> | ||
| #include <memory> | ||
| #include <optional> | ||
| #include <string> | ||
|
|
||
| namespace | ||
| { | ||
| constexpr size_t certificate_validity_period_days = 365; | ||
|
|
||
| std::string valid_from_yesterday() | ||
| { | ||
| using namespace std::literals; | ||
| return ccf::ds::to_x509_time_string(std::chrono::system_clock::now() - 24h); | ||
| } | ||
|
|
||
| ccf::crypto::Pem generate_self_signed_cert( | ||
| const ccf::crypto::ECKeyPairPtr& kp, const std::string& name) | ||
| { | ||
| return ccf::crypto::create_self_signed_cert( | ||
| kp, name, {}, valid_from_yesterday(), certificate_validity_period_days); | ||
| } | ||
|
|
||
| struct NetworkCA | ||
| { | ||
| ccf::crypto::ECKeyPairPtr kp; | ||
| ccf::crypto::Pem cert; | ||
| }; | ||
|
|
||
| /// Get self-signed CA certificate. | ||
| NetworkCA get_ca() | ||
| { | ||
| auto kp = ccf::crypto::make_ec_key_pair(); | ||
| return {kp, generate_self_signed_cert(kp, "CN=issuer")}; | ||
| } | ||
|
|
||
| /// Creates a ::tls::Cert endorsed by the given CA. | ||
| std::unique_ptr<::tls::Cert> get_dummy_cert( | ||
| NetworkCA& net_ca, const std::string& name, bool auth_required = true) | ||
| { | ||
| auto ca = std::make_unique<::tls::CA>(net_ca.cert.str()); | ||
|
|
||
| // Create a signing request and sign with the CA | ||
| auto kp = ccf::crypto::make_ec_key_pair(); | ||
| auto crt = ccf::crypto::create_endorsed_cert( | ||
| kp, | ||
| "CN=" + name, | ||
| {}, | ||
| valid_from_yesterday(), | ||
| certificate_validity_period_days, | ||
| net_ca.kp->private_key_pem(), | ||
| net_ca.cert); | ||
|
|
||
| // Verify node certificate with the CA's certificate | ||
| auto v = ccf::crypto::make_verifier(crt); | ||
| REQUIRE(v->verify_certificate({&net_ca.cert})); | ||
|
|
||
| return std::make_unique<::tls::Cert>( | ||
| std::move(ca), crt, kp->private_key_pem(), std::nullopt, auth_required); | ||
| } | ||
| } | ||
|
|
||
| TEST_CASE("CA configures trusted certificate store") | ||
| { | ||
| auto ca = get_ca(); | ||
| ::tls::CA trusted_ca(ca.cert.str(), true); | ||
| ccf::crypto::OpenSSL::Unique_SSL_CTX ctx(TLS_method()); | ||
|
|
||
| trusted_ca.configure_trusted_cert_store(ctx); | ||
|
|
||
| auto* store = SSL_CTX_get_cert_store(ctx); | ||
| REQUIRE(store != nullptr); | ||
| auto* params = X509_STORE_get0_param(store); | ||
| REQUIRE(params != nullptr); | ||
| REQUIRE( | ||
| (X509_VERIFY_PARAM_get_flags(params) & X509_V_FLAG_PARTIAL_CHAIN) != 0); | ||
| } | ||
|
|
||
| TEST_CASE("Cert configures TLS verification and own certificate") | ||
| { | ||
| auto ca = get_ca(); | ||
|
|
||
| SUBCASE("auth_required requires a peer certificate") | ||
| { | ||
| auto cert = get_dummy_cert(ca, "server"); | ||
| ccf::crypto::OpenSSL::Unique_SSL_CTX ctx(TLS_method()); | ||
|
|
||
| cert->configure_context(ctx); | ||
| ccf::crypto::OpenSSL::Unique_SSL ssl(ctx); | ||
| cert->configure_connection(ssl); | ||
|
|
||
| constexpr auto expected_verify_mode = | ||
| SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT; | ||
| REQUIRE(SSL_CTX_get_verify_mode(ctx) == expected_verify_mode); | ||
| REQUIRE(SSL_get_verify_mode(ssl) == expected_verify_mode); | ||
| REQUIRE(SSL_CTX_get0_certificate(ctx) != nullptr); | ||
| REQUIRE(SSL_get_certificate(ssl) != nullptr); | ||
| } | ||
|
|
||
| SUBCASE("without auth_required a peer certificate is requested, not required") | ||
| { | ||
| auto cert = get_dummy_cert(ca, "server", false); | ||
| ccf::crypto::OpenSSL::Unique_SSL_CTX ctx(TLS_method()); | ||
|
|
||
| cert->configure_context(ctx); | ||
| ccf::crypto::OpenSSL::Unique_SSL ssl(ctx); | ||
| cert->configure_connection(ssl); | ||
|
|
||
| // The connection inherits the context's verification mode | ||
| REQUIRE((SSL_get_verify_mode(ssl) & SSL_VERIFY_PEER) != 0); | ||
| REQUIRE((SSL_get_verify_mode(ssl) & SSL_VERIFY_FAIL_IF_NO_PEER_CERT) == 0); | ||
| } | ||
| } | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.