Honour certificate verification mode when custom trust roots are set (TransportServices) - #185
Merged
Conversation
|
|
…rtServices) With custom trustRoots, the TransportServices transports installed a verify block that anchored the custom roots and then evaluated the SecTrust exactly as Network.framework configured it — with the default SSL policy, including hostname matching. The configured CertificateVerification mode was never consulted, so .noHostnameVerification behaved like full verification (rejecting any certificate whose SANs don't cover the endpoint, e.g. private-CA deployments or IP-dialled peers), and .noVerification still evaluated and could fail the handshake. The verify block now honours the mode: .noHostnameVerification re-policies the trust for SSL use with no hostname before evaluating (chain validation against the custom roots is unchanged), and .noVerification installs no verify block at all, matching the Posix transport's NIOSSL semantics for both modes.
dmonagle
force-pushed
the
fix/custom-trust-roots-verification
branch
from
July 20, 2026 08:36
d6f372d to
9001353
Compare
glbrntt
enabled auto-merge (squash)
July 20, 2026 10:45
Contributor
Author
|
The two failing jobs (Linux nightly-main / nightly-next) reproduce on |
dongjoon-hyun
added a commit
to apache/spark-connect-swift
that referenced
this pull request
Aug 4, 2026
### What changes were proposed in this pull request? This PR upgrades the `grpc-swift-nio-transport` dependency to `2.9.1`. ### Why are the changes needed? To adopt the latest `grpc-swift-nio-transport` release (`2.9.1`, 2026-08-03). - https://github.com/grpc/grpc-swift-nio-transport/releases/tag/2.9.1 - grpc/grpc-swift-nio-transport#185 - grpc/grpc-swift-nio-transport#187 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Pass the CIs. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Fable 5 Closes #476 from dongjoon-hyun/SPARK-58542. Authored-by: Dongjoon Hyun <dongjoon@apache.org> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
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.
Fixes #184.
Motivation
With
trustRoots: .certificates(...), the TransportServices transports install a verify block that anchors the custom roots and then callsSecTrustEvaluateAsyncWithErroron the trust exactly as Network.framework configured it — with the default SSL policy, which includes hostname matching. The configuredCertificateVerificationmode is never consulted there:.noHostnameVerificationbehaves like full verification: any certificate whose SANs don't cover the dialled endpoint is rejected (errSSLBadCert), even though the chain validates against the custom roots. This breaks private-CA deployments whose certs deliberately carry no DNS/IP SANs, and peers dialled by IP address. The identical configuration works with the Posix transport, where the mode maps to NIOSSL'scertificateVerification = .noHostnameVerification..noVerificationstill installs the evaluating block and can fail the handshake despite verification being explicitly disabled.Modifications
The verify block now receives the verification mode and whether it is evaluating server or client certificates:
.noHostnameVerification: the trust is re-policied withSecPolicyCreateSSL(<role>, nil)before evaluation — chain validation against the custom anchors is unchanged, hostname matching is skipped..noVerification: no verify block is installed (the callers already setsec_protocol_options_set_peer_authentication_required(false)for this mode), matching NIOSSL semantics..fullVerification: behaviour unchanged.Result
.noHostnameVerification+ custom trust roots connects when the chain is valid but the hostname doesn't match, on both client and server TransportServices transports, matching the Posix transport.New regression test (
testClientNoHostnameVerificationIgnoresHostname) covers all client/server transport combinations; without the source change the two TransportServices-client cases fail withNWError.tls(-9808). Existing TLS suites pass (HTTP2TransportTLSEnabledTests,TLSConfigurationTests).