feat:Support for TLSv1.3#3319
Open
neilxxxxx wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds explicit TLSv1.3 protocol selection support to brpc’s SSL/TLS configuration by extending protocol parsing/bitmasks and wiring TLSv1.3 enable/disable into SSL_CTX option setup, plus a unit test that validates TLSv1.3 negotiation.
Changes:
- Add
TLSv1_3protocol flag, parse"TLSv1.3"inChannelSSLOptions::protocols, and applySSL_OP_NO_TLSv1_3when appropriate. - Update client-side default protocol list / documentation to include TLSv1.3.
- Add a unit test that performs a direct OpenSSL handshake and asserts
"TLSv1.3"is negotiated (when supported by the SSL library).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/brpc_ssl_unittest.cpp | Adds TLSv1.3 negotiation test via direct SSL_do_handshake() and SSL_get_version(). |
| src/brpc/ssl_options.h | Updates documented available/default protocol strings to include TLSv1.3. |
| src/brpc/ssl_options.cpp | Updates ChannelSSLOptions default protocols string to include TLSv1.3. |
| src/brpc/details/ssl_helper.h | Adds TLSv1_3 to SSLProtocol bitmask enum. |
| src/brpc/details/ssl_helper.cpp | Adds TLSv1.3 parsing and SSL_OP_NO_TLSv1_3 handling; enables TLSv1.3 in server default protocol mask. |
Comments suppressed due to low confidence (1)
src/brpc/details/ssl_helper.cpp:600
- CreateServerSSLContext now enables TLSv1.3 in the server-side default protocol mask. If the feature is meant to be strictly opt-in (as stated in the PR description), the server side also needs a way to control/disable TLSv1.3 (e.g., a protocols field in ServerSSLOptions, similar to ChannelSSLOptions), otherwise non-brpc clients that support TLSv1.3 may negotiate it by default.
int protocols = TLSv1 | TLSv1_1 | TLSv1_2 | TLSv1_3;
if (!options.disable_ssl3) {
protocols |= SSLv3;
}
if (SetSSLOptions(ssl_ctx.get(), options.ciphers,
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+89
to
93
| } else if (strncasecmp(protocol.data(), "TLSv1.3", protocol.size()) == 0) { | ||
| protocol_flag |= TLSv1_3; | ||
| } else { | ||
| LOG(ERROR) << "Unknown SSL protocol=" << protocol; | ||
| return -1; |
Comment on lines
+449
to
+453
| #ifdef SSL_OP_NO_TLSv1_3 | ||
| if (!(protocols & TLSv1_3)) { | ||
| ssloptions |= SSL_OP_NO_TLSv1_3; | ||
| } | ||
| #endif // SSL_OP_NO_TLSv1_3 |
Comment on lines
28
to
31
| ChannelSSLOptions::ChannelSSLOptions() | ||
| : ciphers("DEFAULT") | ||
| , protocols("TLSv1, TLSv1.1, TLSv1.2") | ||
| , protocols("TLSv1, TLSv1.1, TLSv1.2, TLSv1.3") | ||
| {} |
Comment on lines
81
to
84
| // SSL protocols used for SSL handshake, separated by comma. | ||
| // Available protocols: SSLv3, TLSv1, TLSv1.1, TLSv1.2 | ||
| // Default: TLSv1, TLSv1.1, TLSv1.2 | ||
| // Available protocols: SSLv3, TLSv1, TLSv1.1, TLSv1.2, TLSv1.3 | ||
| // Default: TLSv1, TLSv1.1, TLSv1.2, TLSv1.3 | ||
| std::string protocols; |
Contributor
|
This PR has merge conflict now. |
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
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.
What problem does this PR solve?
Issue Number: resolve #
Problem Summary:
Previously, brpc only supported TLSv1.0/1.1/1.2 for SSL/TLS connections.
With the increasing industry adoption of TLSv1.3 (RFC 8446) and the deprecation
of older TLS versions by major cloud services and browsers, there is a need
to add TLSv1.3 support in brpc to:
What is changed and the side effects?
Changed:
enable TLSv1.3 protocol methods when available
Side effects:
Performance effects:
and supports 0-RTT resumption for returning connections
Breaking backward compatibility:
TLSv1.2 remain unchanged. Users must explicitly set the TLS version
to enable TLSv1.3.
Check List:
https://github.com/apache/brpc/blob/master/CODE_OF_CONDUCT.md.