|
|
|
@ -2079,52 +2079,54 @@ grpc_error_handle DownstreamTlsContextParse( |
|
|
|
|
XdsApi::DownstreamTlsContext* downstream_tls_context) { |
|
|
|
|
absl::string_view name = UpbStringToAbsl( |
|
|
|
|
envoy_config_core_v3_TransportSocket_name(transport_socket)); |
|
|
|
|
if (name == "envoy.transport_sockets.tls") { |
|
|
|
|
auto* typed_config = |
|
|
|
|
envoy_config_core_v3_TransportSocket_typed_config(transport_socket); |
|
|
|
|
if (typed_config != nullptr) { |
|
|
|
|
const upb_strview encoded_downstream_tls_context = |
|
|
|
|
google_protobuf_Any_value(typed_config); |
|
|
|
|
auto* downstream_tls_context_proto = |
|
|
|
|
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_parse( |
|
|
|
|
encoded_downstream_tls_context.data, |
|
|
|
|
encoded_downstream_tls_context.size, context.arena); |
|
|
|
|
if (downstream_tls_context_proto == nullptr) { |
|
|
|
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING( |
|
|
|
|
"Can't decode downstream tls context."); |
|
|
|
|
} |
|
|
|
|
auto* common_tls_context = |
|
|
|
|
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_common_tls_context( |
|
|
|
|
downstream_tls_context_proto); |
|
|
|
|
if (common_tls_context != nullptr) { |
|
|
|
|
grpc_error_handle error = CommonTlsContextParse( |
|
|
|
|
common_tls_context, &downstream_tls_context->common_tls_context); |
|
|
|
|
if (error != GRPC_ERROR_NONE) return error; |
|
|
|
|
} |
|
|
|
|
auto* require_client_certificate = |
|
|
|
|
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_require_client_certificate( |
|
|
|
|
downstream_tls_context_proto); |
|
|
|
|
if (require_client_certificate != nullptr) { |
|
|
|
|
downstream_tls_context->require_client_certificate = |
|
|
|
|
google_protobuf_BoolValue_value(require_client_certificate); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (downstream_tls_context->common_tls_context |
|
|
|
|
.tls_certificate_certificate_provider_instance.instance_name |
|
|
|
|
.empty()) { |
|
|
|
|
if (name != "envoy.transport_sockets.tls") { |
|
|
|
|
return GRPC_ERROR_CREATE_FROM_COPIED_STRING( |
|
|
|
|
absl::StrCat("Unrecognized transport socket: ", name).c_str()); |
|
|
|
|
} |
|
|
|
|
auto* typed_config = |
|
|
|
|
envoy_config_core_v3_TransportSocket_typed_config(transport_socket); |
|
|
|
|
if (typed_config != nullptr) { |
|
|
|
|
const upb_strview encoded_downstream_tls_context = |
|
|
|
|
google_protobuf_Any_value(typed_config); |
|
|
|
|
auto* downstream_tls_context_proto = |
|
|
|
|
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_parse( |
|
|
|
|
encoded_downstream_tls_context.data, |
|
|
|
|
encoded_downstream_tls_context.size, context.arena); |
|
|
|
|
if (downstream_tls_context_proto == nullptr) { |
|
|
|
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING( |
|
|
|
|
"TLS configuration provided but no " |
|
|
|
|
"tls_certificate_certificate_provider_instance found."); |
|
|
|
|
"Can't decode downstream tls context."); |
|
|
|
|
} |
|
|
|
|
auto* common_tls_context = |
|
|
|
|
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_common_tls_context( |
|
|
|
|
downstream_tls_context_proto); |
|
|
|
|
if (common_tls_context != nullptr) { |
|
|
|
|
grpc_error_handle error = CommonTlsContextParse( |
|
|
|
|
common_tls_context, &downstream_tls_context->common_tls_context); |
|
|
|
|
if (error != GRPC_ERROR_NONE) return error; |
|
|
|
|
} |
|
|
|
|
if (downstream_tls_context->require_client_certificate && |
|
|
|
|
downstream_tls_context->common_tls_context.combined_validation_context |
|
|
|
|
.validation_context_certificate_provider_instance.instance_name |
|
|
|
|
.empty()) { |
|
|
|
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING( |
|
|
|
|
"TLS configuration requires client certificates but no certificate " |
|
|
|
|
"provider instance specified for validation."); |
|
|
|
|
auto* require_client_certificate = |
|
|
|
|
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_require_client_certificate( |
|
|
|
|
downstream_tls_context_proto); |
|
|
|
|
if (require_client_certificate != nullptr) { |
|
|
|
|
downstream_tls_context->require_client_certificate = |
|
|
|
|
google_protobuf_BoolValue_value(require_client_certificate); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (downstream_tls_context->common_tls_context |
|
|
|
|
.tls_certificate_certificate_provider_instance.instance_name |
|
|
|
|
.empty()) { |
|
|
|
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING( |
|
|
|
|
"TLS configuration provided but no " |
|
|
|
|
"tls_certificate_certificate_provider_instance found."); |
|
|
|
|
} |
|
|
|
|
if (downstream_tls_context->require_client_certificate && |
|
|
|
|
downstream_tls_context->common_tls_context.combined_validation_context |
|
|
|
|
.validation_context_certificate_provider_instance.instance_name |
|
|
|
|
.empty()) { |
|
|
|
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING( |
|
|
|
|
"TLS configuration requires client certificates but no certificate " |
|
|
|
|
"provider instance specified for validation."); |
|
|
|
|
} |
|
|
|
|
return GRPC_ERROR_NONE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -3029,54 +3031,56 @@ grpc_error_handle CdsResponseParse( |
|
|
|
|
if (transport_socket != nullptr) { |
|
|
|
|
absl::string_view name = UpbStringToAbsl( |
|
|
|
|
envoy_config_core_v3_TransportSocket_name(transport_socket)); |
|
|
|
|
if (name == "envoy.transport_sockets.tls") { |
|
|
|
|
auto* typed_config = |
|
|
|
|
envoy_config_core_v3_TransportSocket_typed_config( |
|
|
|
|
transport_socket); |
|
|
|
|
if (typed_config != nullptr) { |
|
|
|
|
const upb_strview encoded_upstream_tls_context = |
|
|
|
|
google_protobuf_Any_value(typed_config); |
|
|
|
|
auto* upstream_tls_context = |
|
|
|
|
envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_parse( |
|
|
|
|
encoded_upstream_tls_context.data, |
|
|
|
|
encoded_upstream_tls_context.size, context.arena); |
|
|
|
|
if (upstream_tls_context == nullptr) { |
|
|
|
|
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING( |
|
|
|
|
absl::StrCat(cluster_name, |
|
|
|
|
": Can't decode upstream tls context.") |
|
|
|
|
.c_str())); |
|
|
|
|
resource_names_failed->insert(cluster_name); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
auto* common_tls_context = |
|
|
|
|
envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_common_tls_context( |
|
|
|
|
upstream_tls_context); |
|
|
|
|
if (common_tls_context != nullptr) { |
|
|
|
|
grpc_error_handle error = CommonTlsContextParse( |
|
|
|
|
common_tls_context, &cds_update.common_tls_context); |
|
|
|
|
if (error != GRPC_ERROR_NONE) { |
|
|
|
|
errors.push_back(grpc_error_add_child( |
|
|
|
|
GRPC_ERROR_CREATE_FROM_COPIED_STRING( |
|
|
|
|
absl::StrCat(cluster_name, ": error in TLS context") |
|
|
|
|
.c_str()), |
|
|
|
|
error)); |
|
|
|
|
resource_names_failed->insert(cluster_name); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (cds_update.common_tls_context.combined_validation_context |
|
|
|
|
.validation_context_certificate_provider_instance |
|
|
|
|
.instance_name.empty()) { |
|
|
|
|
if (name != "envoy.transport_sockets.tls") { |
|
|
|
|
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING( |
|
|
|
|
absl::StrCat("Unrecognized transport socket: ", name).c_str())); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
auto* typed_config = |
|
|
|
|
envoy_config_core_v3_TransportSocket_typed_config(transport_socket); |
|
|
|
|
if (typed_config != nullptr) { |
|
|
|
|
const upb_strview encoded_upstream_tls_context = |
|
|
|
|
google_protobuf_Any_value(typed_config); |
|
|
|
|
auto* upstream_tls_context = |
|
|
|
|
envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_parse( |
|
|
|
|
encoded_upstream_tls_context.data, |
|
|
|
|
encoded_upstream_tls_context.size, context.arena); |
|
|
|
|
if (upstream_tls_context == nullptr) { |
|
|
|
|
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING( |
|
|
|
|
absl::StrCat(cluster_name, |
|
|
|
|
"TLS configuration provided but no " |
|
|
|
|
"validation_context_certificate_provider_instance " |
|
|
|
|
"found.") |
|
|
|
|
": Can't decode upstream tls context.") |
|
|
|
|
.c_str())); |
|
|
|
|
resource_names_failed->insert(cluster_name); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
auto* common_tls_context = |
|
|
|
|
envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_common_tls_context( |
|
|
|
|
upstream_tls_context); |
|
|
|
|
if (common_tls_context != nullptr) { |
|
|
|
|
grpc_error_handle error = CommonTlsContextParse( |
|
|
|
|
common_tls_context, &cds_update.common_tls_context); |
|
|
|
|
if (error != GRPC_ERROR_NONE) { |
|
|
|
|
errors.push_back(grpc_error_add_child( |
|
|
|
|
GRPC_ERROR_CREATE_FROM_COPIED_STRING( |
|
|
|
|
absl::StrCat(cluster_name, ": error in TLS context") |
|
|
|
|
.c_str()), |
|
|
|
|
error)); |
|
|
|
|
resource_names_failed->insert(cluster_name); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (cds_update.common_tls_context.combined_validation_context |
|
|
|
|
.validation_context_certificate_provider_instance.instance_name |
|
|
|
|
.empty()) { |
|
|
|
|
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING( |
|
|
|
|
absl::StrCat(cluster_name, |
|
|
|
|
"TLS configuration provided but no " |
|
|
|
|
"validation_context_certificate_provider_instance " |
|
|
|
|
"found.") |
|
|
|
|
.c_str())); |
|
|
|
|
resource_names_failed->insert(cluster_name); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|