xds: file_watcher cert provider: support identity-only and roots-only configs#12800
Open
paulmurhy123 wants to merge 1 commit intogrpc:masterfrom
Open
xds: file_watcher cert provider: support identity-only and roots-only configs#12800paulmurhy123 wants to merge 1 commit intogrpc:masterfrom
paulmurhy123 wants to merge 1 commit intogrpc:masterfrom
Conversation
… configs
The file_watcher CertificateProviderProvider previously required all of
certificate_file, private_key_file, and ca_certificate_file (or
spiffe_trust_bundle_map_file) in every config. One-way TLS deployments
(clients that only verify the server, or servers that don't validate client
certs) had to supply unused identity or trust files just to satisfy the
validator.
CertProviderSslContextProvider already routes identity-only and roots-only
modes correctly via its three TLS topology helpers (isMtls,
isRegularTlsAndClientSide, isRegularTlsAndServerSide); the validator was the
only thing forcing every plugin instance to carry both halves. Allow either
half to be omitted, require certificate_file/private_key_file as a pair,
require at least one of {identity pair, ca file, spiffe map file}, and gate
the identity-reload branch in FileWatcherCertificateProvider on certFile
being non-null.
Throw UnsupportedOperationException (not IllegalArgumentException) when a
roots-only config is asked to deliver identity updates, so
CertificateProviderStore.createOrGetProvider's catch block can fall back
from its initial notifyCertUpdates=true probe to the caller's actual value.
Without this, legitimate roots-only callers (notifyCertUpdates=false) would
fail on the store's unconditional first probe.
This matches the contract the grpc-go pemfile provider already implements
(credentials/tls/certprovider/pemfile/watcher.go validate()): at least one
file required, identity cert + key paired.
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.
Summary
The
file_watcherCertificateProviderProvidercurrently requires all ofcertificate_file,private_key_file, andca_certificate_file(orspiffe_trust_bundle_map_file) in every config. This forces one-way TLS deployments — clients that only verify the server, or servers that don't validate client certs — to supply unused identity or trust files purely to satisfy the validator.This change relaxes the validator to accept three valid topologies:
certificate_file+private_key_file)ca_certificate_fileorspiffe_trust_bundle_map_file)certificate_fileandprivate_key_filemust travel together; at least one of{identity pair, ca file, spiffe map file}must be present.Why no other layer needs to change
CertProviderSslContextProvideralready handles all three TLS topologies via itsisMtls/isRegularTlsAndClientSide/isRegularTlsAndServerSidehelpers, and only asks the underlyingCertificateProviderfor whichever halves the xDS-sideCommonTlsContextreferences. Thefile_watchervalidator was the lone bottleneck preventing per-instance plugin configs from being identity-only or roots-only. Two corresponding tweaks at the runtime-provider level:FileWatcherCertificateProvider's constructor dropscheckNotNulloncertFile/keyFile, adds the same pairing/at-least-one invariants, andcheckAndReloadCertificatesgates the identity-reload branch oncertFile != nullso roots-only providers don't trip on missing identity files.notifyCertUpdates=trueis requested for a roots-only config, both layers throwUnsupportedOperationException(notIllegalArgumentException) soCertificateProviderStore.createOrGetProvider's probe-then-fall-back catch block can engage. Without this, legitimate roots-only callers (notifyCertUpdates=false) would fail on the store's unconditional first probe.Prior art
The grpc-go
pemfileprovider — the Go counterpart of this Javafile_watcherplugin — already implements exactly this contract. Fromcredentials/tls/certprovider/pemfile/watcher.golines 80-86:This PR aligns grpc-java's
file_watcherwith the grpc-gopemfilesemantics: at least one of{identity pair, root, spiffe}required, identity cert + key paired.Test plan
FileWatcherCertificateProviderProviderTest: identity-only, ca-roots-only, spiffe-roots-only succeed; cert-without-key, key-without-cert, and empty config raiseNullPointerExceptionwith new messages;notifyCertUpdates=truewith roots-only raisesUnsupportedOperationException; regression test verifies theCertificateProviderStoreprobe-then-fall-back contract.FileWatcherCertificateProviderTest: identity-only / ca-roots-only / spiffe-roots-only providers reload only their configured half; constructor rejects unpaired identity, both-halves-missing, andnotifyCertUpdates=truewithout identity.:grpc-xds:testpasses (3956 tests, 0 failures).:grpc-xds:checkstyleMainand:grpc-xds:checkstyleTestclean.