Skip to content

Commit 65cdfba

Browse files
gtcooke94copybara-github
authored andcommitted
[Security][XDS] Support Verification with SPIFFE Bundle Maps (grpc#40321)
This PR adds APIs discussed in grpc/proposal#506 and https://github.com/grpc/proposal/blob/master/A87-mtls-spiffe-support.md to support verification with SPIFFE Bundle Map roots. RELEASE NOTES: * Adds support for SPIFFE Bundle Maps in as roots of trust per [gRFC A87](https://github.com/grpc/proposal/blob/master/A87-mtls-spiffe-support.md) and [gRFC L127](grpc/proposal#506) Closes grpc#40321 COPYBARA_INTEGRATE_REVIEW=grpc#40321 from gtcooke94:spiffe_verification 6ddc24e PiperOrigin-RevId: 793688101
1 parent ac15e06 commit 65cdfba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3756
-58
lines changed

CMakeLists.txt

Lines changed: 684 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build_autogenerated.yaml

Lines changed: 192 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

include/grpc/credentials.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,14 +656,20 @@ grpc_tls_certificate_provider_static_data_create(
656656
* be null if no identity credentials are needed.
657657
* - root_cert_path is the file path to the root certificate bundle. This
658658
* may be null if no root certs are needed.
659+
* - spiffe_bundle_map_path is the file path to the SPIFFE Bundle Map. If
660+
* configured, this will be used to find the roots of trust for a given SPIFFE
661+
* domain during verification. See
662+
* https://github.com/grpc/proposal/blob/master/A87-mtls-spiffe-support.md for
663+
* more details on SPIFFE verification.
659664
* - refresh_interval_sec is the refreshing interval that we will check the
660665
* files for updates.
661666
* It does not take ownership of parameters.
662667
*/
663668
GRPCAPI grpc_tls_certificate_provider*
664669
grpc_tls_certificate_provider_file_watcher_create(
665670
const char* private_key_path, const char* identity_certificate_path,
666-
const char* root_cert_path, unsigned int refresh_interval_sec);
671+
const char* root_cert_path, const char* spiffe_bundle_map_path,
672+
unsigned int refresh_interval_sec);
667673

668674
/**
669675
* EXPERIMENTAL API - Subject to change

include/grpcpp/security/tls_certificate_provider.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,27 @@ class GRPCXX_DLL FileWatcherCertificateProvider final
109109
FileWatcherCertificateProvider(const std::string& private_key_path,
110110
const std::string& identity_certificate_path,
111111
const std::string& root_cert_path,
112+
const std::string& spiffe_bundle_map_path,
112113
unsigned int refresh_interval_sec);
113114
// Constructor to get credential updates from identity file paths only.
114115
FileWatcherCertificateProvider(const std::string& private_key_path,
115116
const std::string& identity_certificate_path,
116117
unsigned int refresh_interval_sec)
117118
: FileWatcherCertificateProvider(private_key_path,
118-
identity_certificate_path, "",
119+
identity_certificate_path, "", "",
119120
refresh_interval_sec) {}
120121
// Constructor to get credential updates from root file path only.
121122
FileWatcherCertificateProvider(const std::string& root_cert_path,
122123
unsigned int refresh_interval_sec)
123-
: FileWatcherCertificateProvider("", "", root_cert_path,
124+
: FileWatcherCertificateProvider("", "", root_cert_path, "",
124125
refresh_interval_sec) {}
126+
FileWatcherCertificateProvider(const std::string& private_key_path,
127+
const std::string& identity_certificate_path,
128+
const std::string& root_cert_path,
129+
unsigned int refresh_interval_sec)
130+
: FileWatcherCertificateProvider(
131+
private_key_path, identity_certificate_path, root_cert_path, "",
132+
refresh_interval_sec) {}
125133

126134
~FileWatcherCertificateProvider() override;
127135

src/core/credentials/transport/tls/grpc_tls_certificate_provider.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,17 +509,18 @@ grpc_tls_certificate_provider* grpc_tls_certificate_provider_static_data_create(
509509
std::move(root_cert_core), std::move(identity_pairs_core));
510510
}
511511

512-
// TODO(gtcooke94): Add a parameter to set the spiffe_bundle_map_path
513512
grpc_tls_certificate_provider*
514513
grpc_tls_certificate_provider_file_watcher_create(
515514
const char* private_key_path, const char* identity_certificate_path,
516-
const char* root_cert_path, unsigned int refresh_interval_sec) {
515+
const char* root_cert_path, const char* spiffe_bundle_map_path,
516+
unsigned int refresh_interval_sec) {
517517
grpc_core::ExecCtx exec_ctx;
518518
return new grpc_core::FileWatcherCertificateProvider(
519519
private_key_path == nullptr ? "" : private_key_path,
520520
identity_certificate_path == nullptr ? "" : identity_certificate_path,
521521
root_cert_path == nullptr ? "" : root_cert_path,
522-
/*spiffe_bundle_map_path=*/"", refresh_interval_sec);
522+
spiffe_bundle_map_path == nullptr ? "" : spiffe_bundle_map_path,
523+
refresh_interval_sec);
523524
}
524525

525526
void grpc_tls_certificate_provider_release(

0 commit comments

Comments
 (0)