Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tls: implement SPIFFE Certificate Validator for independent multiple trust domain support #14884

Merged
merged 46 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
ceae724
Add SPIFFE validator
mathetake Jan 31, 2021
521c3a6
Initial impl
mathetake Feb 1, 2021
d82ca2c
Test
mathetake Feb 1, 2021
3e57b43
Trust bundle nullcheck
mathetake Feb 1, 2021
8476b3a
add tests
mathetake Feb 2, 2021
d8c9076
add additional tests
mathetake Feb 2, 2021
8d88b16
impl addClientValidationContext and add additional tests
mathetake Feb 2, 2021
0dd80aa
impl updateDigestForSessionId
mathetake Feb 2, 2021
6d2732f
fix format
mathetake Feb 2, 2021
e34f79c
fix test build
mathetake Feb 2, 2021
6619ad7
fix build failure in quic
mathetake Feb 3, 2021
ee204d0
Add integration test
mathetake Feb 3, 2021
2f53ac2
Add additonal integration test
mathetake Feb 3, 2021
2077588
Merge remote-tracking branch 'origin/main' into spiffe-cert
mathetake Feb 3, 2021
093cf70
Add stats
mathetake Feb 3, 2021
3eb65f9
Add doc
mathetake Feb 3, 2021
7d8514a
fix doc
mathetake Feb 3, 2021
1b3d256
fix -c opt test failure
mathetake Feb 3, 2021
4c83dc0
fix compiletime_option build & add tests for coverage
mathetake Feb 3, 2021
f1aa358
increase coverage
mathetake Feb 4, 2021
8cbbbd1
fix format
mathetake Feb 4, 2021
fed1388
Merge remote-tracking branch 'origin/main' into spiffe-cert
mathetake Feb 5, 2021
5346527
Review: define TrustDomain msg
mathetake Feb 5, 2021
7339c3c
Do manual parsing instead of regexp
mathetake Feb 7, 2021
8cfadd7
review: use envoy_cc_extensions and mv files
mathetake Feb 7, 2021
842fc3a
Merge remote-tracking branch 'origin/main' into spiffe-cert
mathetake Feb 8, 2021
19aa7bd
fix doc
mathetake Feb 8, 2021
5dc2e31
add well_known_names.h
mathetake Feb 8, 2021
8c8c6b9
fix test build
mathetake Feb 8, 2021
81452de
fix coverage exception
mathetake Feb 8, 2021
306d52f
Revert default_validator modification
mathetake Feb 9, 2021
adddac0
Merge remote-tracking branch 'origin/main' into spiffe-cert
mathetake Feb 24, 2021
5664a31
Review: style and simplification
mathetake Feb 24, 2021
85738e3
Review: take min of expiration days over all certs
mathetake Feb 24, 2021
1008f1e
Merge remote-tracking branch 'origin/main' into spiffe-cert
mathetake Feb 25, 2021
63e4901
Review: constify certificateValidationContext
mathetake Feb 25, 2021
67024cb
Fix test build failure
mathetake Feb 25, 2021
9825778
Fix mock signature
mathetake Feb 25, 2021
b4b084d
Merge remote-tracking branch 'origin/main' into spiffe-cert
mathetake Mar 1, 2021
e6b2c0f
review: check only URI SAN
mathetake Mar 1, 2021
cdfb3ce
review: up_ref after append
mathetake Mar 1, 2021
88517d2
review: add CODEOWNER and add version history
mathetake Mar 2, 2021
409e7d1
Merge remote-tracking branch 'origin/main' into spiffe-cert
mathetake Mar 2, 2021
a75b70d
review: not only listener but also cluster
mathetake Mar 2, 2021
dcc9634
Merge remote-tracking branch 'origin/main' into spiffe-cert
mathetake Mar 2, 2021
684420f
fix order of new features
mathetake Mar 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion api/envoy/extensions/transport_sockets/tls/v3/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ syntax = "proto3";
package envoy.extensions.transport_sockets.tls.v3;

import "envoy/config/core/v3/base.proto";
import "envoy/config/core/v3/extension.proto";
import "envoy/type/matcher/v3/string.proto";

import "google/protobuf/any.proto";
Expand Down Expand Up @@ -212,7 +213,7 @@ message TlsSessionTicketKeys {
[(validate.rules).repeated = {min_items: 1}, (udpa.annotations.sensitive) = true];
}

// [#next-free-field: 12]
// [#next-free-field: 13]
message CertificateValidationContext {
option (udpa.annotations.versioning).previous_message_type =
"envoy.api.v2.auth.CertificateValidationContext";
Expand Down Expand Up @@ -372,4 +373,11 @@ message CertificateValidationContext {
// Certificate trust chain verification mode.
TrustChainVerification trust_chain_verification = 10
[(validate.rules).enum = {defined_only: true}];

// The configuration of an extension specific certificate validator.
// If specified, all the values above are *ignored*.
// Currently only
// :ref:`envoy.extensions.transport_sockets.tls.v3.SPIFFECertValidatorConfig <envoy_v3_api_msg_extensions.transport_sockets.tls.v3.SPIFFECertValidatorConfig>`
// is implemented in Envoy.
config.core.v3.TypedExtensionConfig custom_validator_config = 12;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
syntax = "proto3";

package envoy.extensions.transport_sockets.tls.v3;

import "envoy/config/core/v3/base.proto";

import "udpa/annotations/sensitive.proto";
import "udpa/annotations/status.proto";
import "udpa/annotations/versioning.proto";
import "validate/validate.proto";

option java_package = "io.envoyproxy.envoy.extensions.transport_sockets.tls.v3";
option java_outer_classname = "TlsSpiffeValidatorConfigProto";
option java_multiple_files = true;
option (udpa.annotations.file_status).package_version_status = ACTIVE;

// [#protodoc-title: SPIFFE Certificate Validator Configuration]

// Configuration specific to the SPIFFE certificate validator provided at
// :ref:`envoy.extensions.transport_sockets.tls.v3.CertificateValidationContext.custom_validator_config<envoy_api_field_extensions.transport_sockets.tls.v3.CertificateValidationContext.custom_validator_config>`.
//
// Example:
//
// .. code-block:: yaml
mathetake marked this conversation as resolved.
Show resolved Hide resolved
//
// custom_validator_config:
// name: envoy.tls.cert_validator.spiffe
// typed_config:
// "@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.SPIFFECertValidatorConfig
// trust_bundles:
// foo.com:
// filename: "foo.pem"
// envoy.com:
// filename: "envoy.pem"
//
// In this example, a presented peer certificate whose SAN matches `spiffe//foo.com/**` is validated against
// the "foo.pem" x.509 certificate. All the trust bundles are isolated from each other, so no trust domain can mint
// a SVID belonging to another trust domain. That means, in this example, a SVID signed by `envoy.com`'s CA with `spiffe//foo.com/**`
// SAN would be rejected since Envoy selects the trust bundle according to the presented SAN before validate the certificate.
message SPIFFECertValidatorConfig {
// This field specifies the x.509 trust bundles used for validating incoming X.509-SVID(s).
// The key is a SPIFFE trust domain, `example.com`, `foo.bar.gov` for example,
// and maps to a data source storing x.509 trust bundle.
// Note that the key must *not* have "spiffe://" prefix.
map<string, config.core.v3.DataSource> trust_bundles = 1;
mathetake marked this conversation as resolved.
Show resolved Hide resolved
mathetake marked this conversation as resolved.
Show resolved Hide resolved
}
10 changes: 9 additions & 1 deletion api/envoy/extensions/transport_sockets/tls/v4alpha/common.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions generated_api_shadow/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ proto_library(
"//envoy/config/retry/omit_canary_hosts/v2:pkg",
"//envoy/config/retry/omit_canary_hosts/v3:pkg",
"//envoy/config/retry/previous_hosts/v2:pkg",
"//envoy/config/retry/previous_hosts/v3:pkg",
"//envoy/config/route/v3:pkg",
"//envoy/config/tap/v3:pkg",
"//envoy/config/trace/v3:pkg",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions include/envoy/ssl/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ envoy_cc_library(
envoy_cc_library(
name = "certificate_validation_context_config_interface",
hdrs = ["certificate_validation_context_config.h"],
external_deps = ["abseil_optional"],
deps = [
"//source/common/common:matchers_lib",
"@envoy_api//envoy/extensions/transport_sockets/tls/v3:pkg_cc_proto",
Expand Down
14 changes: 14 additions & 0 deletions include/envoy/ssl/certificate_validation_context_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
#include <string>
#include <vector>

#include "envoy/api/api.h"
#include "envoy/common/pure.h"
#include "envoy/extensions/transport_sockets/tls/v3/cert.pb.h"
#include "envoy/type/matcher/v3/string.pb.h"

#include "absl/types/optional.h"

namespace Envoy {
namespace Ssl {

Expand Down Expand Up @@ -69,6 +72,17 @@ class CertificateValidationContextConfig {
virtual envoy::extensions::transport_sockets::tls::v3::CertificateValidationContext::
TrustChainVerification
trustChainVerification() const PURE;

/**
* @return the configuration for the custom certificate validator if configured.
*/
virtual const absl::optional<envoy::config::core::v3::TypedExtensionConfig>&
customValidatorConfig() const PURE;

/**
* @return a reference to the api object.
*/
virtual Api::Api& api() PURE;
};

using CertificateValidationContextConfigPtr = std::unique_ptr<CertificateValidationContextConfig>;
Expand Down
2 changes: 1 addition & 1 deletion include/envoy/ssl/context_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ContextConfig {
/**
* @return CertificateValidationContextConfig the certificate validation context config.
*/
virtual const CertificateValidationContextConfig* certificateValidationContext() const PURE;
virtual CertificateValidationContextConfig* certificateValidationContext() const PURE;
mathetake marked this conversation as resolved.
Show resolved Hide resolved

/**
* @return The minimum TLS protocol version to negotiate.
Expand Down
1 change: 1 addition & 0 deletions source/common/ssl/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ envoy_cc_library(
name = "certificate_validation_context_config_impl_lib",
srcs = ["certificate_validation_context_config_impl.cc"],
hdrs = ["certificate_validation_context_config_impl.h"],
external_deps = ["abseil_optional"],
deps = [
"//include/envoy/api:api_interface",
"//include/envoy/ssl:certificate_validation_context_config_interface",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ CertificateValidationContextConfigImpl::CertificateValidationContextConfigImpl(
verify_certificate_spki_list_(config.verify_certificate_spki().begin(),
config.verify_certificate_spki().end()),
allow_expired_certificate_(config.allow_expired_certificate()),
trust_chain_verification_(config.trust_chain_verification()) {
trust_chain_verification_(config.trust_chain_verification()),
custom_validator_config_(
config.has_custom_validator_config()
? absl::make_optional<envoy::config::core::v3::TypedExtensionConfig>(
config.custom_validator_config())
: absl::nullopt),
api_(api) {
if (ca_cert_.empty()) {
if (!certificate_revocation_list_.empty()) {
throw EnvoyException(fmt::format("Failed to load CRL from {} without trusted CA",
Expand Down
Loading