Add TLS peer name verification for clients#3408
Open
wwbmmm wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR strengthens client-side TLS identity verification in bRPC by adding configurable peer name checks (DNS name / IP SAN) and defaulting HTTPS channels to verify the URL host when certificate verification is enabled, preventing trusted-but-wrong certificates from being accepted.
Changes:
- Added
VerifyOptions::expected_peer_nameand used it to configure OpenSSL hostname/IP verification (with explicit rejection on unsupported TLS backends / OpenSSL versions). - Derived
expected_peer_nameautomatically from the HTTPS URL host when verification is enabled and no explicit value is set, and included verification settings in the channel signature to avoid cross-sharing connections. - Added/updated unit tests covering correct and incorrect peer identities and invalid verification configurations.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/brpc_ssl_unittest.cpp | Adds SSL unit tests for expected peer name verification behavior and invalid configurations. |
| test/brpc_channel_unittest.cpp | Extends URL parsing tests to assert expected_peer_name is derived for HTTPS when verification is enabled. |
| src/brpc/ssl_options.h | Introduces VerifyOptions::expected_peer_name as a new verification configuration field. |
| src/brpc/details/ssl_helper.cpp | Configures OpenSSL host/IP verification parameters when expected_peer_name is set; rejects invalid configs/unsupported versions. |
| src/brpc/details/mesalink_ssl_helper.cpp | Rejects expected_peer_name because MesaLink lacks required peer-name verification support. |
| src/brpc/channel.cpp | Derives SNI + expected peer name from HTTPS URL host and includes verification mode/peer name in the channel signature. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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: null
Problem Summary:
Client TLS verification validates the certificate chain, but callers cannot
configure the DNS name or IP address expected in the peer certificate. This
makes it possible for a trusted certificate issued for another endpoint to be
accepted when only chain verification is configured.
What is changed and the side effects?
Changed:
VerifyOptions::expected_peer_namefor DNS name and IP SAN validation.certificate verification is enabled and no explicit peer name is configured.
the TLS backend cannot support it.
to prevent connections with different verification settings from being
shared.
invalid verification configurations.
Side effects:
handshake when
expected_peer_nameis configured.enabled now reject certificates that do not match the URL host. Callers that
intentionally connect through an alias can set
expected_peer_nameexplicitly.OpenSSL versions older than 1.0.2 and MesaLink reject configurations that
require peer name verification because they do not provide the required API.
Check List:
make -j6inbuild.build/test/brpc_ssl_unittestpasses.