Skip to content

[ssl] Server side handshaker factory stores a map of key signers#42002

Closed
rockspore wants to merge 14 commits into
grpc:masterfrom
rockspore:server-signer-fix
Closed

[ssl] Server side handshaker factory stores a map of key signers#42002
rockspore wants to merge 14 commits into
grpc:masterfrom
rockspore:server-signer-fix

Conversation

@rockspore

@rockspore rockspore commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

The server takes a vector of key/cert pairs for SNI. So it could have the same number of private key signers. Right now it keeps only one, which is incorrect.

This is a bug fix so it could be worth a patch release as suggested by @gtcooke94.

One open question is whether we should store the key_signer in the handshaker. As of now , I still find the code to be easier to read and manage by doing that, especially when we introduce the key_signer from the certificate selector later on. But I acknowledge in this case, key signers are 1-1 mapped to SSL_CTXs and there is some overhead by copying it to each handshaker and the ownership also gets less clear.

----
DO NOT SUBMIT. This PR is for testing purposes only. [cl/893799990](http://cl/893799990)

PiperOrigin-RevId: 893799990
@rockspore rockspore added area/security release notes: yes Indicates if PR needs to be in release notes labels Apr 3, 2026
@rockspore rockspore self-assigned this Apr 3, 2026
@rockspore rockspore marked this pull request as ready for review April 3, 2026 22:53
@grpc-checks grpc-checks Bot added the bloat/low label Apr 3, 2026
Automated fix for refs/heads/server-signer-fix

@matthewstevenson88 matthewstevenson88 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR! A couple questions to make sure I understand before completing the full review.

Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread src/core/tsi/ssl_transport_security.cc Outdated

@rockspore rockspore left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for reviewing.

Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread src/core/tsi/ssl_transport_security.cc
Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread test/core/tsi/private_key_offload_test.cc Outdated
Comment thread test/core/tsi/private_key_offload_test.cc
Comment thread test/cpp/end2end/tls_private_key_signer_end2end_test.cc
@grpc-checks grpc-checks Bot added bloat/none and removed bloat/low labels Apr 8, 2026

@matthewstevenson88 matthewstevenson88 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please also fix the failing sanity tests.

Comment thread src/core/tsi/ssl_transport_security.cc
Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread src/core/tsi/ssl_transport_security.cc
Comment thread test/core/tsi/private_key_offload_test.cc
Comment thread test/core/tsi/private_key_offload_test.cc
Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Automated fix for refs/heads/server-signer-fix
Comment thread src/core/tsi/ssl_transport_security.cc
Comment thread test/core/tsi/private_key_offload_test.cc
Comment thread test/core/tsi/private_key_offload_test.cc
// Verifies that the server can successfully offload signing to an asynchronous
// custom signer.
TEST_F(TlsPrivateKeyOffloadTest, OffloadWithCustomKeySignerAsync) {
TEST_F(TlsPrivateKeyOffloadTest, OffloadWithCustomKeySignerAsyncWithSniMatch) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry I forgot to make the analogous comment here: should we also check that the peer name matches the SNI in the e2e tests?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note that we should not use the TSI-layer helper function here any more, so checking the SNI match is a bit clumsy but I added it.

JFYI, the bad signer added to the other cert that's not supposed to be picked also ensures the test goes the right way.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need the TSI-layer helper? We could just extract the analogous property from the auth context and compare to the hardcoded string.

Don't want to block on this, I think the PR is generally fine, but leaving this open to get your thoughts.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry I already added what you suggested. I just wanted to say that there were multiple SANs so we had to try matching each, and SAN can have wildcard. So it's less elegant than the unit test where we call a helper to get a boolean straighforwardly.

@rockspore rockspore removed the request for review from anniefrchz April 9, 2026 00:23

@markdroth markdroth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The fix looks good! My comments are mostly things to improve readability.

Please let me know if you have any questions. Thanks!

Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread src/core/tsi/ssl_transport_security.cc Outdated

@rockspore rockspore left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review, Mark!

Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread src/core/tsi/ssl_transport_security.cc Outdated
Comment thread src/core/tsi/ssl_transport_security.cc Outdated
rockspore added a commit to rockspore/grpc that referenced this pull request Apr 9, 2026
copybara-service Bot pushed a commit that referenced this pull request May 1, 2026
… correctly.

It was removed in #42002 and caused the `result` to be ignored after the ssl contexts get configured.

----
DO NOT SUBMIT. This PR is for testing purposes only. [cl/908809008](http://cl/908809008)

PiperOrigin-RevId: 908809008
copybara-service Bot pushed a commit that referenced this pull request May 4, 2026
… correctly.

It was removed in #42002 and caused the `result` to be ignored after the ssl contexts get configured.

----
DO NOT SUBMIT. This PR is for testing purposes only. [cl/908809008](http://cl/908809008)

PiperOrigin-RevId: 908809008
copybara-service Bot pushed a commit that referenced this pull request May 5, 2026
… correctly.

It was removed in #42002 and caused the `result` to be ignored after the ssl contexts get configured.

----
DO NOT SUBMIT. This PR is for testing purposes only. [cl/908809008](http://cl/908809008)

PiperOrigin-RevId: 908809008
copybara-service Bot pushed a commit that referenced this pull request May 5, 2026
… correctly.

It was removed in #42002 and caused the `result` to be ignored after the ssl contexts get configured.

----
DO NOT SUBMIT. This PR is for testing purposes only. [cl/908809008](http://cl/908809008)

PiperOrigin-RevId: 908809008
copybara-service Bot pushed a commit that referenced this pull request May 6, 2026
It was removed in #42002 and caused the `result` to be ignored after the ssl contexts get configured.

PiperOrigin-RevId: 911317681
asheshvidyut pushed a commit to a-detiste/grpc that referenced this pull request Jun 10, 2026
…c#42002)

The server takes a vector of key/cert pairs for SNI. So it could have the same number of private key signers. Right now it keeps only one, which is incorrect.

This is a bug fix so it could be worth a patch release as suggested by @gtcooke94.

One open question is whether we should store the `key_signer` in the handshaker. As of now , I still find the code to be easier to read and manage by doing that, especially when we introduce the `key_signer` from the certificate selector later on. But I acknowledge in this case, key signers are 1-1 mapped to SSL_CTXs and there is some overhead by copying it to each handshaker and the ownership also gets less clear.

Closes grpc#42002

COPYBARA_INTEGRATE_REVIEW=grpc#42002 from rockspore:server-signer-fix 971bfa7
PiperOrigin-RevId: 908273778
asheshvidyut pushed a commit to a-detiste/grpc that referenced this pull request Jun 10, 2026
It was removed in grpc#42002 and caused the `result` to be ignored after the ssl contexts get configured.

PiperOrigin-RevId: 911317681
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants