aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/grpc/src/cpp/common
diff options
context:
space:
mode:
authordvshkurko <dvshkurko@yandex-team.ru>2022-02-10 16:45:52 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:52 +0300
commitc768a99151e47c3a4bb7b92c514d256abd301c4d (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /contrib/libs/grpc/src/cpp/common
parent321ee9bce31ec6e238be26dbcbe539cffa2c3309 (diff)
downloadydb-c768a99151e47c3a4bb7b92c514d256abd301c4d.tar.gz
Restoring authorship annotation for <dvshkurko@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/grpc/src/cpp/common')
-rw-r--r--contrib/libs/grpc/src/cpp/common/alarm.cc36
-rw-r--r--contrib/libs/grpc/src/cpp/common/channel_arguments.cc36
-rw-r--r--contrib/libs/grpc/src/cpp/common/channel_filter.h16
-rw-r--r--contrib/libs/grpc/src/cpp/common/completion_queue_cc.cc8
-rw-r--r--contrib/libs/grpc/src/cpp/common/core_codegen.cc18
-rw-r--r--contrib/libs/grpc/src/cpp/common/tls_credentials_options.cc488
-rw-r--r--contrib/libs/grpc/src/cpp/common/tls_credentials_options_util.cc282
-rw-r--r--contrib/libs/grpc/src/cpp/common/tls_credentials_options_util.h112
-rw-r--r--contrib/libs/grpc/src/cpp/common/validate_service_config.cc72
9 files changed, 534 insertions, 534 deletions
diff --git a/contrib/libs/grpc/src/cpp/common/alarm.cc b/contrib/libs/grpc/src/cpp/common/alarm.cc
index bfbf26ed4d..a2612874b2 100644
--- a/contrib/libs/grpc/src/cpp/common/alarm.cc
+++ b/contrib/libs/grpc/src/cpp/common/alarm.cc
@@ -42,7 +42,7 @@ class AlarmImpl : public ::grpc::internal::CompletionQueueTag {
grpc_timer_init_unset(&timer_);
}
~AlarmImpl() {}
- bool FinalizeResult(void** tag, bool* /*status*/) override {
+ bool FinalizeResult(void** tag, bool* /*status*/) override {
*tag = tag_;
Unref();
return true;
@@ -54,23 +54,23 @@ class AlarmImpl : public ::grpc::internal::CompletionQueueTag {
cq_ = cq->cq();
tag_ = tag;
GPR_ASSERT(grpc_cq_begin_op(cq_, this));
- GRPC_CLOSURE_INIT(
- &on_alarm_,
- [](void* arg, grpc_error* error) {
- // queue the op on the completion queue
- AlarmImpl* alarm = static_cast<AlarmImpl*>(arg);
- alarm->Ref();
- // Preserve the cq and reset the cq_ so that the alarm
- // can be reset when the alarm tag is delivered.
- grpc_completion_queue* cq = alarm->cq_;
- alarm->cq_ = nullptr;
- grpc_cq_end_op(
- cq, alarm, error,
- [](void* /*arg*/, grpc_cq_completion* /*completion*/) {}, arg,
- &alarm->completion_);
- GRPC_CQ_INTERNAL_UNREF(cq, "alarm");
- },
- this, grpc_schedule_on_exec_ctx);
+ GRPC_CLOSURE_INIT(
+ &on_alarm_,
+ [](void* arg, grpc_error* error) {
+ // queue the op on the completion queue
+ AlarmImpl* alarm = static_cast<AlarmImpl*>(arg);
+ alarm->Ref();
+ // Preserve the cq and reset the cq_ so that the alarm
+ // can be reset when the alarm tag is delivered.
+ grpc_completion_queue* cq = alarm->cq_;
+ alarm->cq_ = nullptr;
+ grpc_cq_end_op(
+ cq, alarm, error,
+ [](void* /*arg*/, grpc_cq_completion* /*completion*/) {}, arg,
+ &alarm->completion_);
+ GRPC_CQ_INTERNAL_UNREF(cq, "alarm");
+ },
+ this, grpc_schedule_on_exec_ctx);
grpc_timer_init(&timer_, grpc_timespec_to_millis_round_up(deadline),
&on_alarm_);
}
diff --git a/contrib/libs/grpc/src/cpp/common/channel_arguments.cc b/contrib/libs/grpc/src/cpp/common/channel_arguments.cc
index 63232a5129..5a5dd91b5e 100644
--- a/contrib/libs/grpc/src/cpp/common/channel_arguments.cc
+++ b/contrib/libs/grpc/src/cpp/common/channel_arguments.cc
@@ -31,7 +31,7 @@ namespace grpc {
ChannelArguments::ChannelArguments() {
// This will be ignored if used on the server side.
- SetString(GRPC_ARG_PRIMARY_USER_AGENT_STRING, "grpc-c++/" + grpc::Version());
+ SetString(GRPC_ARG_PRIMARY_USER_AGENT_STRING, "grpc-c++/" + grpc::Version());
}
ChannelArguments::ChannelArguments(const ChannelArguments& other)
@@ -39,26 +39,26 @@ ChannelArguments::ChannelArguments(const ChannelArguments& other)
args_.reserve(other.args_.size());
auto list_it_dst = strings_.begin();
auto list_it_src = other.strings_.begin();
- for (const auto& a : other.args_) {
+ for (const auto& a : other.args_) {
grpc_arg ap;
- ap.type = a.type;
- GPR_ASSERT(list_it_src->c_str() == a.key);
+ ap.type = a.type;
+ GPR_ASSERT(list_it_src->c_str() == a.key);
ap.key = const_cast<char*>(list_it_dst->c_str());
++list_it_src;
++list_it_dst;
- switch (a.type) {
+ switch (a.type) {
case GRPC_ARG_INTEGER:
- ap.value.integer = a.value.integer;
+ ap.value.integer = a.value.integer;
break;
case GRPC_ARG_STRING:
- GPR_ASSERT(list_it_src->c_str() == a.value.string);
+ GPR_ASSERT(list_it_src->c_str() == a.value.string);
ap.value.string = const_cast<char*>(list_it_dst->c_str());
++list_it_src;
++list_it_dst;
break;
case GRPC_ARG_POINTER:
- ap.value.pointer = a.value.pointer;
- ap.value.pointer.p = a.value.pointer.vtable->copy(ap.value.pointer.p);
+ ap.value.pointer = a.value.pointer;
+ ap.value.pointer.p = a.value.pointer.vtable->copy(ap.value.pointer.p);
break;
}
args_.push_back(ap);
@@ -67,9 +67,9 @@ ChannelArguments::ChannelArguments(const ChannelArguments& other)
ChannelArguments::~ChannelArguments() {
grpc_core::ExecCtx exec_ctx;
- for (auto& arg : args_) {
- if (arg.type == GRPC_ARG_POINTER) {
- arg.value.pointer.vtable->destroy(arg.value.pointer.p);
+ for (auto& arg : args_) {
+ if (arg.type == GRPC_ARG_POINTER) {
+ arg.value.pointer.vtable->destroy(arg.value.pointer.p);
}
}
}
@@ -95,12 +95,12 @@ void ChannelArguments::SetSocketMutator(grpc_socket_mutator* mutator) {
grpc_arg mutator_arg = grpc_socket_mutator_to_arg(mutator);
bool replaced = false;
grpc_core::ExecCtx exec_ctx;
- for (auto& arg : args_) {
- if (arg.type == mutator_arg.type &&
+ for (auto& arg : args_) {
+ if (arg.type == mutator_arg.type &&
TString(arg.key) == TString(mutator_arg.key)) {
GPR_ASSERT(!replaced);
- arg.value.pointer.vtable->destroy(arg.value.pointer.p);
- arg.value.pointer = mutator_arg.value.pointer;
+ arg.value.pointer.vtable->destroy(arg.value.pointer.p);
+ arg.value.pointer = mutator_arg.value.pointer;
replaced = true;
}
}
@@ -123,13 +123,13 @@ void ChannelArguments::SetUserAgentPrefix(
}
bool replaced = false;
auto strings_it = strings_.begin();
- for (auto& arg : args_) {
+ for (auto& arg : args_) {
++strings_it;
if (arg.type == GRPC_ARG_STRING) {
if (TString(arg.key) == GRPC_ARG_PRIMARY_USER_AGENT_STRING) {
GPR_ASSERT(arg.value.string == strings_it->c_str());
*(strings_it) = user_agent_prefix + " " + arg.value.string;
- arg.value.string = const_cast<char*>(strings_it->c_str());
+ arg.value.string = const_cast<char*>(strings_it->c_str());
replaced = true;
break;
}
diff --git a/contrib/libs/grpc/src/cpp/common/channel_filter.h b/contrib/libs/grpc/src/cpp/common/channel_filter.h
index f5d5dfbb6a..5ce720b307 100644
--- a/contrib/libs/grpc/src/cpp/common/channel_filter.h
+++ b/contrib/libs/grpc/src/cpp/common/channel_filter.h
@@ -236,13 +236,13 @@ class ChannelData {
// TODO(roth): Come up with a more C++-like API for the channel element.
/// Initializes the channel data.
- virtual grpc_error* Init(grpc_channel_element* /*elem*/,
- grpc_channel_element_args* /*args*/) {
+ virtual grpc_error* Init(grpc_channel_element* /*elem*/,
+ grpc_channel_element_args* /*args*/) {
return GRPC_ERROR_NONE;
}
// Called before destruction.
- virtual void Destroy(grpc_channel_element* /*elem*/) {}
+ virtual void Destroy(grpc_channel_element* /*elem*/) {}
virtual void StartTransportOp(grpc_channel_element* elem, TransportOp* op);
@@ -259,15 +259,15 @@ class CallData {
// TODO(roth): Come up with a more C++-like API for the call element.
/// Initializes the call data.
- virtual grpc_error* Init(grpc_call_element* /*elem*/,
- const grpc_call_element_args* /*args*/) {
+ virtual grpc_error* Init(grpc_call_element* /*elem*/,
+ const grpc_call_element_args* /*args*/) {
return GRPC_ERROR_NONE;
}
// Called before destruction.
- virtual void Destroy(grpc_call_element* /*elem*/,
- const grpc_call_final_info* /*final_info*/,
- grpc_closure* /*then_call_closure*/) {}
+ virtual void Destroy(grpc_call_element* /*elem*/,
+ const grpc_call_final_info* /*final_info*/,
+ grpc_closure* /*then_call_closure*/) {}
/// Starts a new stream operation.
virtual void StartTransportStreamOpBatch(grpc_call_element* elem,
diff --git a/contrib/libs/grpc/src/cpp/common/completion_queue_cc.cc b/contrib/libs/grpc/src/cpp/common/completion_queue_cc.cc
index 6cab616d53..96a7105eaf 100644
--- a/contrib/libs/grpc/src/cpp/common/completion_queue_cc.cc
+++ b/contrib/libs/grpc/src/cpp/common/completion_queue_cc.cc
@@ -58,8 +58,8 @@ CompletionQueue::NextStatus CompletionQueue::AsyncNextInternal(
case GRPC_QUEUE_SHUTDOWN:
return SHUTDOWN;
case GRPC_OP_COMPLETE:
- auto core_cq_tag =
- static_cast<::grpc::internal::CompletionQueueTag*>(ev.tag);
+ auto core_cq_tag =
+ static_cast<::grpc::internal::CompletionQueueTag*>(ev.tag);
*ok = ev.success != 0;
*tag = core_cq_tag;
if (core_cq_tag->FinalizeResult(tag, ok)) {
@@ -86,8 +86,8 @@ bool CompletionQueue::CompletionQueueTLSCache::Flush(void** tag, bool* ok) {
flushed_ = true;
if (grpc_completion_queue_thread_local_cache_flush(cq_->cq_, &res_tag,
&res)) {
- auto core_cq_tag =
- static_cast<::grpc::internal::CompletionQueueTag*>(res_tag);
+ auto core_cq_tag =
+ static_cast<::grpc::internal::CompletionQueueTag*>(res_tag);
*ok = res == 1;
if (core_cq_tag->FinalizeResult(tag, ok)) {
return true;
diff --git a/contrib/libs/grpc/src/cpp/common/core_codegen.cc b/contrib/libs/grpc/src/cpp/common/core_codegen.cc
index 0966358d6f..75383ed511 100644
--- a/contrib/libs/grpc/src/cpp/common/core_codegen.cc
+++ b/contrib/libs/grpc/src/cpp/common/core_codegen.cc
@@ -81,7 +81,7 @@ void CoreCodegen::gpr_free(void* p) { return ::gpr_free(p); }
void CoreCodegen::grpc_init() { ::grpc_init(); }
void CoreCodegen::grpc_shutdown() { ::grpc_shutdown(); }
-void CoreCodegen::gpr_mu_init(gpr_mu* mu) { ::gpr_mu_init(mu); }
+void CoreCodegen::gpr_mu_init(gpr_mu* mu) { ::gpr_mu_init(mu); }
void CoreCodegen::gpr_mu_destroy(gpr_mu* mu) { ::gpr_mu_destroy(mu); }
void CoreCodegen::gpr_mu_lock(gpr_mu* mu) { ::gpr_mu_lock(mu); }
void CoreCodegen::gpr_mu_unlock(gpr_mu* mu) { ::gpr_mu_unlock(mu); }
@@ -123,9 +123,9 @@ void CoreCodegen::grpc_call_unref(grpc_call* call) { ::grpc_call_unref(call); }
void* CoreCodegen::grpc_call_arena_alloc(grpc_call* call, size_t length) {
return ::grpc_call_arena_alloc(call, length);
}
-const char* CoreCodegen::grpc_call_error_to_string(grpc_call_error error) {
- return ::grpc_call_error_to_string(error);
-}
+const char* CoreCodegen::grpc_call_error_to_string(grpc_call_error error) {
+ return ::grpc_call_error_to_string(error);
+}
int CoreCodegen::grpc_byte_buffer_reader_init(grpc_byte_buffer_reader* reader,
grpc_byte_buffer* buffer) {
@@ -142,11 +142,11 @@ int CoreCodegen::grpc_byte_buffer_reader_next(grpc_byte_buffer_reader* reader,
return ::grpc_byte_buffer_reader_next(reader, slice);
}
-int CoreCodegen::grpc_byte_buffer_reader_peek(grpc_byte_buffer_reader* reader,
- grpc_slice** slice) {
- return ::grpc_byte_buffer_reader_peek(reader, slice);
-}
-
+int CoreCodegen::grpc_byte_buffer_reader_peek(grpc_byte_buffer_reader* reader,
+ grpc_slice** slice) {
+ return ::grpc_byte_buffer_reader_peek(reader, slice);
+}
+
grpc_byte_buffer* CoreCodegen::grpc_raw_byte_buffer_create(grpc_slice* slice,
size_t nslices) {
return ::grpc_raw_byte_buffer_create(slice, nslices);
diff --git a/contrib/libs/grpc/src/cpp/common/tls_credentials_options.cc b/contrib/libs/grpc/src/cpp/common/tls_credentials_options.cc
index cf5eec58a4..7e435ac1de 100644
--- a/contrib/libs/grpc/src/cpp/common/tls_credentials_options.cc
+++ b/contrib/libs/grpc/src/cpp/common/tls_credentials_options.cc
@@ -1,98 +1,98 @@
-/*
- *
- * Copyright 2019 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
+/*
+ *
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
#include <grpc/support/alloc.h>
-#include <grpcpp/security/tls_credentials_options.h>
+#include <grpcpp/security/tls_credentials_options.h>
#include "y_absl/container/inlined_vector.h"
-#include "src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h"
-#include "src/cpp/common/tls_credentials_options_util.h"
-
+#include "src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h"
+#include "src/cpp/common/tls_credentials_options_util.h"
+
namespace grpc {
-namespace experimental {
-
-/** TLS key materials config API implementation **/
+namespace experimental {
+
+/** TLS key materials config API implementation **/
void TlsKeyMaterialsConfig::set_pem_root_certs(
const TString& pem_root_certs) {
pem_root_certs_ = pem_root_certs;
-}
-
-void TlsKeyMaterialsConfig::add_pem_key_cert_pair(
- const PemKeyCertPair& pem_key_cert_pair) {
- pem_key_cert_pair_list_.push_back(pem_key_cert_pair);
-}
-
-void TlsKeyMaterialsConfig::set_key_materials(
+}
+
+void TlsKeyMaterialsConfig::add_pem_key_cert_pair(
+ const PemKeyCertPair& pem_key_cert_pair) {
+ pem_key_cert_pair_list_.push_back(pem_key_cert_pair);
+}
+
+void TlsKeyMaterialsConfig::set_key_materials(
const TString& pem_root_certs,
const std::vector<PemKeyCertPair>& pem_key_cert_pair_list) {
pem_key_cert_pair_list_ = pem_key_cert_pair_list;
pem_root_certs_ = pem_root_certs;
-}
-
-/** TLS credential reload arg API implementation **/
-TlsCredentialReloadArg::TlsCredentialReloadArg(
- grpc_tls_credential_reload_arg* arg)
- : c_arg_(arg) {
- if (c_arg_ != nullptr && c_arg_->context != nullptr) {
- gpr_log(GPR_ERROR, "c_arg context has already been set");
- }
- c_arg_->context = static_cast<void*>(this);
- c_arg_->destroy_context = &TlsCredentialReloadArgDestroyContext;
-}
-
-TlsCredentialReloadArg::~TlsCredentialReloadArg() {}
-
-void* TlsCredentialReloadArg::cb_user_data() const {
- return c_arg_->cb_user_data;
-}
-bool TlsCredentialReloadArg::is_pem_key_cert_pair_list_empty() const {
- return c_arg_->key_materials_config->pem_key_cert_pair_list().empty();
-}
-
-grpc_ssl_certificate_config_reload_status TlsCredentialReloadArg::status()
- const {
- return c_arg_->status;
-}
-
+}
+
+/** TLS credential reload arg API implementation **/
+TlsCredentialReloadArg::TlsCredentialReloadArg(
+ grpc_tls_credential_reload_arg* arg)
+ : c_arg_(arg) {
+ if (c_arg_ != nullptr && c_arg_->context != nullptr) {
+ gpr_log(GPR_ERROR, "c_arg context has already been set");
+ }
+ c_arg_->context = static_cast<void*>(this);
+ c_arg_->destroy_context = &TlsCredentialReloadArgDestroyContext;
+}
+
+TlsCredentialReloadArg::~TlsCredentialReloadArg() {}
+
+void* TlsCredentialReloadArg::cb_user_data() const {
+ return c_arg_->cb_user_data;
+}
+bool TlsCredentialReloadArg::is_pem_key_cert_pair_list_empty() const {
+ return c_arg_->key_materials_config->pem_key_cert_pair_list().empty();
+}
+
+grpc_ssl_certificate_config_reload_status TlsCredentialReloadArg::status()
+ const {
+ return c_arg_->status;
+}
+
TString TlsCredentialReloadArg::error_details() const {
return c_arg_->error_details->error_details();
-}
-
-void TlsCredentialReloadArg::set_cb_user_data(void* cb_user_data) {
- c_arg_->cb_user_data = cb_user_data;
-}
-
-void TlsCredentialReloadArg::set_pem_root_certs(
+}
+
+void TlsCredentialReloadArg::set_cb_user_data(void* cb_user_data) {
+ c_arg_->cb_user_data = cb_user_data;
+}
+
+void TlsCredentialReloadArg::set_pem_root_certs(
const TString& pem_root_certs) {
- ::grpc_core::UniquePtr<char> c_pem_root_certs(
- gpr_strdup(pem_root_certs.c_str()));
- c_arg_->key_materials_config->set_pem_root_certs(std::move(c_pem_root_certs));
-}
-
+ ::grpc_core::UniquePtr<char> c_pem_root_certs(
+ gpr_strdup(pem_root_certs.c_str()));
+ c_arg_->key_materials_config->set_pem_root_certs(std::move(c_pem_root_certs));
+}
+
namespace {
::grpc_core::PemKeyCertPair ConvertToCorePemKeyCertPair(
const TlsKeyMaterialsConfig::PemKeyCertPair& pem_key_cert_pair) {
- grpc_ssl_pem_key_cert_pair* ssl_pair =
- (grpc_ssl_pem_key_cert_pair*)gpr_malloc(
- sizeof(grpc_ssl_pem_key_cert_pair));
- ssl_pair->private_key = gpr_strdup(pem_key_cert_pair.private_key.c_str());
- ssl_pair->cert_chain = gpr_strdup(pem_key_cert_pair.cert_chain.c_str());
+ grpc_ssl_pem_key_cert_pair* ssl_pair =
+ (grpc_ssl_pem_key_cert_pair*)gpr_malloc(
+ sizeof(grpc_ssl_pem_key_cert_pair));
+ ssl_pair->private_key = gpr_strdup(pem_key_cert_pair.private_key.c_str());
+ ssl_pair->cert_chain = gpr_strdup(pem_key_cert_pair.cert_chain.c_str());
return ::grpc_core::PemKeyCertPair(ssl_pair);
}
@@ -100,10 +100,10 @@ namespace {
void TlsCredentialReloadArg::add_pem_key_cert_pair(
const TlsKeyMaterialsConfig::PemKeyCertPair& pem_key_cert_pair) {
- c_arg_->key_materials_config->add_pem_key_cert_pair(
+ c_arg_->key_materials_config->add_pem_key_cert_pair(
ConvertToCorePemKeyCertPair(pem_key_cert_pair));
-}
-
+}
+
void TlsCredentialReloadArg::set_key_materials(
const TString& pem_root_certs,
std::vector<TlsKeyMaterialsConfig::PemKeyCertPair> pem_key_cert_pair_list) {
@@ -124,163 +124,163 @@ void TlsCredentialReloadArg::set_key_materials(
c_pem_key_cert_pair_list);
}
-void TlsCredentialReloadArg::set_key_materials_config(
- const std::shared_ptr<TlsKeyMaterialsConfig>& key_materials_config) {
- if (key_materials_config == nullptr) {
- c_arg_->key_materials_config = nullptr;
- return;
- }
+void TlsCredentialReloadArg::set_key_materials_config(
+ const std::shared_ptr<TlsKeyMaterialsConfig>& key_materials_config) {
+ if (key_materials_config == nullptr) {
+ c_arg_->key_materials_config = nullptr;
+ return;
+ }
::y_absl::InlinedVector<::grpc_core::PemKeyCertPair, 1>
- c_pem_key_cert_pair_list;
- for (const auto& key_cert_pair :
- key_materials_config->pem_key_cert_pair_list()) {
- grpc_ssl_pem_key_cert_pair* ssl_pair =
- (grpc_ssl_pem_key_cert_pair*)gpr_malloc(
- sizeof(grpc_ssl_pem_key_cert_pair));
- ssl_pair->private_key = gpr_strdup(key_cert_pair.private_key.c_str());
- ssl_pair->cert_chain = gpr_strdup(key_cert_pair.cert_chain.c_str());
- ::grpc_core::PemKeyCertPair c_pem_key_cert_pair =
- ::grpc_core::PemKeyCertPair(ssl_pair);
- c_pem_key_cert_pair_list.emplace_back(std::move(c_pem_key_cert_pair));
- }
- ::grpc_core::UniquePtr<char> c_pem_root_certs(
- gpr_strdup(key_materials_config->pem_root_certs().c_str()));
- if (c_arg_->key_materials_config == nullptr) {
- c_arg_->key_materials_config = grpc_tls_key_materials_config_create();
- }
- c_arg_->key_materials_config->set_key_materials(
+ c_pem_key_cert_pair_list;
+ for (const auto& key_cert_pair :
+ key_materials_config->pem_key_cert_pair_list()) {
+ grpc_ssl_pem_key_cert_pair* ssl_pair =
+ (grpc_ssl_pem_key_cert_pair*)gpr_malloc(
+ sizeof(grpc_ssl_pem_key_cert_pair));
+ ssl_pair->private_key = gpr_strdup(key_cert_pair.private_key.c_str());
+ ssl_pair->cert_chain = gpr_strdup(key_cert_pair.cert_chain.c_str());
+ ::grpc_core::PemKeyCertPair c_pem_key_cert_pair =
+ ::grpc_core::PemKeyCertPair(ssl_pair);
+ c_pem_key_cert_pair_list.emplace_back(std::move(c_pem_key_cert_pair));
+ }
+ ::grpc_core::UniquePtr<char> c_pem_root_certs(
+ gpr_strdup(key_materials_config->pem_root_certs().c_str()));
+ if (c_arg_->key_materials_config == nullptr) {
+ c_arg_->key_materials_config = grpc_tls_key_materials_config_create();
+ }
+ c_arg_->key_materials_config->set_key_materials(
key_materials_config->pem_root_certs().c_str(), c_pem_key_cert_pair_list);
- c_arg_->key_materials_config->set_version(key_materials_config->version());
-}
-
-void TlsCredentialReloadArg::set_status(
- grpc_ssl_certificate_config_reload_status status) {
- c_arg_->status = status;
-}
-
-void TlsCredentialReloadArg::set_error_details(
+ c_arg_->key_materials_config->set_version(key_materials_config->version());
+}
+
+void TlsCredentialReloadArg::set_status(
+ grpc_ssl_certificate_config_reload_status status) {
+ c_arg_->status = status;
+}
+
+void TlsCredentialReloadArg::set_error_details(
const TString& error_details) {
c_arg_->error_details->set_error_details(error_details.c_str());
-}
-
-void TlsCredentialReloadArg::OnCredentialReloadDoneCallback() {
- if (c_arg_->cb == nullptr) {
- gpr_log(GPR_ERROR, "credential reload arg callback API is nullptr");
- return;
- }
- c_arg_->cb(c_arg_);
-}
-
-/** gRPC TLS credential reload config API implementation **/
-TlsCredentialReloadConfig::TlsCredentialReloadConfig(
- std::shared_ptr<TlsCredentialReloadInterface> credential_reload_interface)
- : credential_reload_interface_(std::move(credential_reload_interface)) {
- c_config_ = grpc_tls_credential_reload_config_create(
- nullptr, &TlsCredentialReloadConfigCSchedule,
- &TlsCredentialReloadConfigCCancel, nullptr);
- c_config_->set_context(static_cast<void*>(this));
-}
-
-TlsCredentialReloadConfig::~TlsCredentialReloadConfig() {}
-
-/** gRPC TLS server authorization check arg API implementation **/
-TlsServerAuthorizationCheckArg::TlsServerAuthorizationCheckArg(
- grpc_tls_server_authorization_check_arg* arg)
- : c_arg_(arg) {
- if (c_arg_ != nullptr && c_arg_->context != nullptr) {
- gpr_log(GPR_ERROR, "c_arg context has already been set");
- }
- c_arg_->context = static_cast<void*>(this);
- c_arg_->destroy_context = &TlsServerAuthorizationCheckArgDestroyContext;
-}
-
-TlsServerAuthorizationCheckArg::~TlsServerAuthorizationCheckArg() {}
-
-void* TlsServerAuthorizationCheckArg::cb_user_data() const {
- return c_arg_->cb_user_data;
-}
-
-int TlsServerAuthorizationCheckArg::success() const { return c_arg_->success; }
-
+}
+
+void TlsCredentialReloadArg::OnCredentialReloadDoneCallback() {
+ if (c_arg_->cb == nullptr) {
+ gpr_log(GPR_ERROR, "credential reload arg callback API is nullptr");
+ return;
+ }
+ c_arg_->cb(c_arg_);
+}
+
+/** gRPC TLS credential reload config API implementation **/
+TlsCredentialReloadConfig::TlsCredentialReloadConfig(
+ std::shared_ptr<TlsCredentialReloadInterface> credential_reload_interface)
+ : credential_reload_interface_(std::move(credential_reload_interface)) {
+ c_config_ = grpc_tls_credential_reload_config_create(
+ nullptr, &TlsCredentialReloadConfigCSchedule,
+ &TlsCredentialReloadConfigCCancel, nullptr);
+ c_config_->set_context(static_cast<void*>(this));
+}
+
+TlsCredentialReloadConfig::~TlsCredentialReloadConfig() {}
+
+/** gRPC TLS server authorization check arg API implementation **/
+TlsServerAuthorizationCheckArg::TlsServerAuthorizationCheckArg(
+ grpc_tls_server_authorization_check_arg* arg)
+ : c_arg_(arg) {
+ if (c_arg_ != nullptr && c_arg_->context != nullptr) {
+ gpr_log(GPR_ERROR, "c_arg context has already been set");
+ }
+ c_arg_->context = static_cast<void*>(this);
+ c_arg_->destroy_context = &TlsServerAuthorizationCheckArgDestroyContext;
+}
+
+TlsServerAuthorizationCheckArg::~TlsServerAuthorizationCheckArg() {}
+
+void* TlsServerAuthorizationCheckArg::cb_user_data() const {
+ return c_arg_->cb_user_data;
+}
+
+int TlsServerAuthorizationCheckArg::success() const { return c_arg_->success; }
+
TString TlsServerAuthorizationCheckArg::target_name() const {
TString cpp_target_name(c_arg_->target_name);
- return cpp_target_name;
-}
-
+ return cpp_target_name;
+}
+
TString TlsServerAuthorizationCheckArg::peer_cert() const {
TString cpp_peer_cert(c_arg_->peer_cert);
- return cpp_peer_cert;
-}
-
+ return cpp_peer_cert;
+}
+
TString TlsServerAuthorizationCheckArg::peer_cert_full_chain() const {
TString cpp_peer_cert_full_chain(c_arg_->peer_cert_full_chain);
return cpp_peer_cert_full_chain;
}
-grpc_status_code TlsServerAuthorizationCheckArg::status() const {
- return c_arg_->status;
-}
-
+grpc_status_code TlsServerAuthorizationCheckArg::status() const {
+ return c_arg_->status;
+}
+
TString TlsServerAuthorizationCheckArg::error_details() const {
return c_arg_->error_details->error_details();
-}
-
-void TlsServerAuthorizationCheckArg::set_cb_user_data(void* cb_user_data) {
- c_arg_->cb_user_data = cb_user_data;
-}
-
-void TlsServerAuthorizationCheckArg::set_success(int success) {
- c_arg_->success = success;
-}
-
-void TlsServerAuthorizationCheckArg::set_target_name(
+}
+
+void TlsServerAuthorizationCheckArg::set_cb_user_data(void* cb_user_data) {
+ c_arg_->cb_user_data = cb_user_data;
+}
+
+void TlsServerAuthorizationCheckArg::set_success(int success) {
+ c_arg_->success = success;
+}
+
+void TlsServerAuthorizationCheckArg::set_target_name(
const TString& target_name) {
- c_arg_->target_name = gpr_strdup(target_name.c_str());
-}
-
-void TlsServerAuthorizationCheckArg::set_peer_cert(
+ c_arg_->target_name = gpr_strdup(target_name.c_str());
+}
+
+void TlsServerAuthorizationCheckArg::set_peer_cert(
const TString& peer_cert) {
- c_arg_->peer_cert = gpr_strdup(peer_cert.c_str());
-}
-
+ c_arg_->peer_cert = gpr_strdup(peer_cert.c_str());
+}
+
void TlsServerAuthorizationCheckArg::set_peer_cert_full_chain(
const TString& peer_cert_full_chain) {
c_arg_->peer_cert_full_chain = gpr_strdup(peer_cert_full_chain.c_str());
}
-void TlsServerAuthorizationCheckArg::set_status(grpc_status_code status) {
- c_arg_->status = status;
-}
-
-void TlsServerAuthorizationCheckArg::set_error_details(
+void TlsServerAuthorizationCheckArg::set_status(grpc_status_code status) {
+ c_arg_->status = status;
+}
+
+void TlsServerAuthorizationCheckArg::set_error_details(
const TString& error_details) {
c_arg_->error_details->set_error_details(error_details.c_str());
-}
-
-void TlsServerAuthorizationCheckArg::OnServerAuthorizationCheckDoneCallback() {
- if (c_arg_->cb == nullptr) {
- gpr_log(GPR_ERROR, "server authorizaton check arg callback API is nullptr");
- return;
- }
- c_arg_->cb(c_arg_);
-}
-
-/** gRPC TLS server authorization check config API implementation. **/
-TlsServerAuthorizationCheckConfig::TlsServerAuthorizationCheckConfig(
- std::shared_ptr<TlsServerAuthorizationCheckInterface>
- server_authorization_check_interface)
- : server_authorization_check_interface_(
- std::move(server_authorization_check_interface)) {
- c_config_ = grpc_tls_server_authorization_check_config_create(
- nullptr, &TlsServerAuthorizationCheckConfigCSchedule,
- &TlsServerAuthorizationCheckConfigCCancel, nullptr);
- c_config_->set_context(static_cast<void*>(this));
-}
-
-TlsServerAuthorizationCheckConfig::~TlsServerAuthorizationCheckConfig() {}
-
-/** gRPC TLS credential options API implementation **/
-TlsCredentialsOptions::TlsCredentialsOptions(
+}
+
+void TlsServerAuthorizationCheckArg::OnServerAuthorizationCheckDoneCallback() {
+ if (c_arg_->cb == nullptr) {
+ gpr_log(GPR_ERROR, "server authorizaton check arg callback API is nullptr");
+ return;
+ }
+ c_arg_->cb(c_arg_);
+}
+
+/** gRPC TLS server authorization check config API implementation. **/
+TlsServerAuthorizationCheckConfig::TlsServerAuthorizationCheckConfig(
+ std::shared_ptr<TlsServerAuthorizationCheckInterface>
+ server_authorization_check_interface)
+ : server_authorization_check_interface_(
+ std::move(server_authorization_check_interface)) {
+ c_config_ = grpc_tls_server_authorization_check_config_create(
+ nullptr, &TlsServerAuthorizationCheckConfigCSchedule,
+ &TlsServerAuthorizationCheckConfigCCancel, nullptr);
+ c_config_->set_context(static_cast<void*>(this));
+}
+
+TlsServerAuthorizationCheckConfig::~TlsServerAuthorizationCheckConfig() {}
+
+/** gRPC TLS credential options API implementation **/
+TlsCredentialsOptions::TlsCredentialsOptions(
grpc_tls_server_verification_option server_verification_option,
std::shared_ptr<TlsKeyMaterialsConfig> key_materials_config,
std::shared_ptr<TlsCredentialReloadConfig> credential_reload_config,
@@ -292,7 +292,7 @@ TlsCredentialsOptions::TlsCredentialsOptions(
std::move(server_authorization_check_config)) {}
TlsCredentialsOptions::TlsCredentialsOptions(
- grpc_ssl_client_certificate_request_type cert_request_type,
+ grpc_ssl_client_certificate_request_type cert_request_type,
std::shared_ptr<TlsKeyMaterialsConfig> key_materials_config,
std::shared_ptr<TlsCredentialReloadConfig> credential_reload_config)
: TlsCredentialsOptions(cert_request_type, GRPC_TLS_SERVER_VERIFICATION,
@@ -302,42 +302,42 @@ TlsCredentialsOptions::TlsCredentialsOptions(
TlsCredentialsOptions::TlsCredentialsOptions(
grpc_ssl_client_certificate_request_type cert_request_type,
grpc_tls_server_verification_option server_verification_option,
- std::shared_ptr<TlsKeyMaterialsConfig> key_materials_config,
- std::shared_ptr<TlsCredentialReloadConfig> credential_reload_config,
- std::shared_ptr<TlsServerAuthorizationCheckConfig>
- server_authorization_check_config)
- : cert_request_type_(cert_request_type),
+ std::shared_ptr<TlsKeyMaterialsConfig> key_materials_config,
+ std::shared_ptr<TlsCredentialReloadConfig> credential_reload_config,
+ std::shared_ptr<TlsServerAuthorizationCheckConfig>
+ server_authorization_check_config)
+ : cert_request_type_(cert_request_type),
server_verification_option_(server_verification_option),
- key_materials_config_(std::move(key_materials_config)),
- credential_reload_config_(std::move(credential_reload_config)),
- server_authorization_check_config_(
- std::move(server_authorization_check_config)) {
- c_credentials_options_ = grpc_tls_credentials_options_create();
- grpc_tls_credentials_options_set_cert_request_type(c_credentials_options_,
- cert_request_type_);
- if (key_materials_config_ != nullptr) {
- grpc_tls_credentials_options_set_key_materials_config(
- c_credentials_options_,
- ConvertToCKeyMaterialsConfig(key_materials_config_));
- }
- if (credential_reload_config_ != nullptr) {
- grpc_tls_credentials_options_set_credential_reload_config(
- c_credentials_options_, credential_reload_config_->c_config());
- }
- if (server_authorization_check_config_ != nullptr) {
- grpc_tls_credentials_options_set_server_authorization_check_config(
- c_credentials_options_, server_authorization_check_config_->c_config());
- }
+ key_materials_config_(std::move(key_materials_config)),
+ credential_reload_config_(std::move(credential_reload_config)),
+ server_authorization_check_config_(
+ std::move(server_authorization_check_config)) {
+ c_credentials_options_ = grpc_tls_credentials_options_create();
+ grpc_tls_credentials_options_set_cert_request_type(c_credentials_options_,
+ cert_request_type_);
+ if (key_materials_config_ != nullptr) {
+ grpc_tls_credentials_options_set_key_materials_config(
+ c_credentials_options_,
+ ConvertToCKeyMaterialsConfig(key_materials_config_));
+ }
+ if (credential_reload_config_ != nullptr) {
+ grpc_tls_credentials_options_set_credential_reload_config(
+ c_credentials_options_, credential_reload_config_->c_config());
+ }
+ if (server_authorization_check_config_ != nullptr) {
+ grpc_tls_credentials_options_set_server_authorization_check_config(
+ c_credentials_options_, server_authorization_check_config_->c_config());
+ }
grpc_tls_credentials_options_set_server_verification_option(
c_credentials_options_, server_verification_option);
-}
-
+}
+
/** Whenever a TlsCredentialsOptions instance is created, the caller takes
* ownership of the c_credentials_options_ pointer (see e.g. the implementation
* of the TlsCredentials API in secure_credentials.cc). For this reason, the
* TlsCredentialsOptions destructor is not responsible for freeing
* c_credentials_options_. **/
-TlsCredentialsOptions::~TlsCredentialsOptions() {}
-
-} // namespace experimental
+TlsCredentialsOptions::~TlsCredentialsOptions() {}
+
+} // namespace experimental
} // namespace grpc
diff --git a/contrib/libs/grpc/src/cpp/common/tls_credentials_options_util.cc b/contrib/libs/grpc/src/cpp/common/tls_credentials_options_util.cc
index 99d6eaf26c..ed84003212 100644
--- a/contrib/libs/grpc/src/cpp/common/tls_credentials_options_util.cc
+++ b/contrib/libs/grpc/src/cpp/common/tls_credentials_options_util.cc
@@ -1,149 +1,149 @@
-/*
- *
- * Copyright 2019 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
+/*
+ *
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
#include "y_absl/container/inlined_vector.h"
#include <grpcpp/security/tls_credentials_options.h>
-#include "src/cpp/common/tls_credentials_options_util.h"
-
+#include "src/cpp/common/tls_credentials_options_util.h"
+
namespace grpc {
-namespace experimental {
-
-/** Converts the Cpp key materials to C key materials; this allocates memory for
- * the C key materials. Note that the user must free
- * the underlying pointer to private key and cert chain duplicates; they are not
- * freed when the grpc_core::UniquePtr<char> member variables of PemKeyCertPair
- * are unused. Similarly, the user must free the underlying pointer to
- * c_pem_root_certs. **/
-grpc_tls_key_materials_config* ConvertToCKeyMaterialsConfig(
- const std::shared_ptr<TlsKeyMaterialsConfig>& config) {
- if (config == nullptr) {
- return nullptr;
- }
- grpc_tls_key_materials_config* c_config =
- grpc_tls_key_materials_config_create();
+namespace experimental {
+
+/** Converts the Cpp key materials to C key materials; this allocates memory for
+ * the C key materials. Note that the user must free
+ * the underlying pointer to private key and cert chain duplicates; they are not
+ * freed when the grpc_core::UniquePtr<char> member variables of PemKeyCertPair
+ * are unused. Similarly, the user must free the underlying pointer to
+ * c_pem_root_certs. **/
+grpc_tls_key_materials_config* ConvertToCKeyMaterialsConfig(
+ const std::shared_ptr<TlsKeyMaterialsConfig>& config) {
+ if (config == nullptr) {
+ return nullptr;
+ }
+ grpc_tls_key_materials_config* c_config =
+ grpc_tls_key_materials_config_create();
::y_absl::InlinedVector<::grpc_core::PemKeyCertPair, 1>
- c_pem_key_cert_pair_list;
- for (const auto& key_cert_pair : config->pem_key_cert_pair_list()) {
- grpc_ssl_pem_key_cert_pair* ssl_pair =
- (grpc_ssl_pem_key_cert_pair*)gpr_malloc(
- sizeof(grpc_ssl_pem_key_cert_pair));
- ssl_pair->private_key = gpr_strdup(key_cert_pair.private_key.c_str());
- ssl_pair->cert_chain = gpr_strdup(key_cert_pair.cert_chain.c_str());
- ::grpc_core::PemKeyCertPair c_pem_key_cert_pair =
- ::grpc_core::PemKeyCertPair(ssl_pair);
- c_pem_key_cert_pair_list.push_back(::std::move(c_pem_key_cert_pair));
- }
+ c_pem_key_cert_pair_list;
+ for (const auto& key_cert_pair : config->pem_key_cert_pair_list()) {
+ grpc_ssl_pem_key_cert_pair* ssl_pair =
+ (grpc_ssl_pem_key_cert_pair*)gpr_malloc(
+ sizeof(grpc_ssl_pem_key_cert_pair));
+ ssl_pair->private_key = gpr_strdup(key_cert_pair.private_key.c_str());
+ ssl_pair->cert_chain = gpr_strdup(key_cert_pair.cert_chain.c_str());
+ ::grpc_core::PemKeyCertPair c_pem_key_cert_pair =
+ ::grpc_core::PemKeyCertPair(ssl_pair);
+ c_pem_key_cert_pair_list.push_back(::std::move(c_pem_key_cert_pair));
+ }
c_config->set_key_materials(config->pem_root_certs().c_str(),
c_pem_key_cert_pair_list);
- c_config->set_version(config->version());
- return c_config;
-}
-
-/** The C schedule and cancel functions for the credential reload config.
- * They populate a C credential reload arg with the result of a C++ credential
- * reload schedule/cancel API. **/
-int TlsCredentialReloadConfigCSchedule(void* /*config_user_data*/,
- grpc_tls_credential_reload_arg* arg) {
- if (arg == nullptr || arg->config == nullptr ||
- arg->config->context() == nullptr) {
- gpr_log(GPR_ERROR, "credential reload arg was not properly initialized");
- return 1;
- }
- TlsCredentialReloadConfig* cpp_config =
- static_cast<TlsCredentialReloadConfig*>(arg->config->context());
- TlsCredentialReloadArg* cpp_arg = new TlsCredentialReloadArg(arg);
- int schedule_result = cpp_config->Schedule(cpp_arg);
- return schedule_result;
-}
-
-void TlsCredentialReloadConfigCCancel(void* /*config_user_data*/,
- grpc_tls_credential_reload_arg* arg) {
- if (arg == nullptr || arg->config == nullptr ||
- arg->config->context() == nullptr) {
- gpr_log(GPR_ERROR, "credential reload arg was not properly initialized");
- return;
- }
- if (arg->context == nullptr) {
- gpr_log(GPR_ERROR, "credential reload arg schedule has already completed");
- return;
- }
- TlsCredentialReloadConfig* cpp_config =
- static_cast<TlsCredentialReloadConfig*>(arg->config->context());
- TlsCredentialReloadArg* cpp_arg =
- static_cast<TlsCredentialReloadArg*>(arg->context);
- cpp_config->Cancel(cpp_arg);
-}
-
-void TlsCredentialReloadArgDestroyContext(void* context) {
- if (context != nullptr) {
- TlsCredentialReloadArg* cpp_arg =
- static_cast<TlsCredentialReloadArg*>(context);
- delete cpp_arg;
- }
-}
-
-/** The C schedule and cancel functions for the server authorization check
- * config. They populate a C server authorization check arg with the result
- * of a C++ server authorization check schedule/cancel API. **/
-int TlsServerAuthorizationCheckConfigCSchedule(
- void* /*config_user_data*/, grpc_tls_server_authorization_check_arg* arg) {
- if (arg == nullptr || arg->config == nullptr ||
- arg->config->context() == nullptr) {
- gpr_log(GPR_ERROR,
- "server authorization check arg was not properly initialized");
- return 1;
- }
- TlsServerAuthorizationCheckConfig* cpp_config =
- static_cast<TlsServerAuthorizationCheckConfig*>(arg->config->context());
- TlsServerAuthorizationCheckArg* cpp_arg =
- new TlsServerAuthorizationCheckArg(arg);
- int schedule_result = cpp_config->Schedule(cpp_arg);
- return schedule_result;
-}
-
-void TlsServerAuthorizationCheckConfigCCancel(
- void* /*config_user_data*/, grpc_tls_server_authorization_check_arg* arg) {
- if (arg == nullptr || arg->config == nullptr ||
- arg->config->context() == nullptr) {
- gpr_log(GPR_ERROR,
- "server authorization check arg was not properly initialized");
- return;
- }
- if (arg->context == nullptr) {
- gpr_log(GPR_ERROR,
- "server authorization check arg schedule has already completed");
- return;
- }
- TlsServerAuthorizationCheckConfig* cpp_config =
- static_cast<TlsServerAuthorizationCheckConfig*>(arg->config->context());
- TlsServerAuthorizationCheckArg* cpp_arg =
- static_cast<TlsServerAuthorizationCheckArg*>(arg->context);
- cpp_config->Cancel(cpp_arg);
-}
-
-void TlsServerAuthorizationCheckArgDestroyContext(void* context) {
- if (context != nullptr) {
- TlsServerAuthorizationCheckArg* cpp_arg =
- static_cast<TlsServerAuthorizationCheckArg*>(context);
- delete cpp_arg;
- }
-}
-
-} // namespace experimental
+ c_config->set_version(config->version());
+ return c_config;
+}
+
+/** The C schedule and cancel functions for the credential reload config.
+ * They populate a C credential reload arg with the result of a C++ credential
+ * reload schedule/cancel API. **/
+int TlsCredentialReloadConfigCSchedule(void* /*config_user_data*/,
+ grpc_tls_credential_reload_arg* arg) {
+ if (arg == nullptr || arg->config == nullptr ||
+ arg->config->context() == nullptr) {
+ gpr_log(GPR_ERROR, "credential reload arg was not properly initialized");
+ return 1;
+ }
+ TlsCredentialReloadConfig* cpp_config =
+ static_cast<TlsCredentialReloadConfig*>(arg->config->context());
+ TlsCredentialReloadArg* cpp_arg = new TlsCredentialReloadArg(arg);
+ int schedule_result = cpp_config->Schedule(cpp_arg);
+ return schedule_result;
+}
+
+void TlsCredentialReloadConfigCCancel(void* /*config_user_data*/,
+ grpc_tls_credential_reload_arg* arg) {
+ if (arg == nullptr || arg->config == nullptr ||
+ arg->config->context() == nullptr) {
+ gpr_log(GPR_ERROR, "credential reload arg was not properly initialized");
+ return;
+ }
+ if (arg->context == nullptr) {
+ gpr_log(GPR_ERROR, "credential reload arg schedule has already completed");
+ return;
+ }
+ TlsCredentialReloadConfig* cpp_config =
+ static_cast<TlsCredentialReloadConfig*>(arg->config->context());
+ TlsCredentialReloadArg* cpp_arg =
+ static_cast<TlsCredentialReloadArg*>(arg->context);
+ cpp_config->Cancel(cpp_arg);
+}
+
+void TlsCredentialReloadArgDestroyContext(void* context) {
+ if (context != nullptr) {
+ TlsCredentialReloadArg* cpp_arg =
+ static_cast<TlsCredentialReloadArg*>(context);
+ delete cpp_arg;
+ }
+}
+
+/** The C schedule and cancel functions for the server authorization check
+ * config. They populate a C server authorization check arg with the result
+ * of a C++ server authorization check schedule/cancel API. **/
+int TlsServerAuthorizationCheckConfigCSchedule(
+ void* /*config_user_data*/, grpc_tls_server_authorization_check_arg* arg) {
+ if (arg == nullptr || arg->config == nullptr ||
+ arg->config->context() == nullptr) {
+ gpr_log(GPR_ERROR,
+ "server authorization check arg was not properly initialized");
+ return 1;
+ }
+ TlsServerAuthorizationCheckConfig* cpp_config =
+ static_cast<TlsServerAuthorizationCheckConfig*>(arg->config->context());
+ TlsServerAuthorizationCheckArg* cpp_arg =
+ new TlsServerAuthorizationCheckArg(arg);
+ int schedule_result = cpp_config->Schedule(cpp_arg);
+ return schedule_result;
+}
+
+void TlsServerAuthorizationCheckConfigCCancel(
+ void* /*config_user_data*/, grpc_tls_server_authorization_check_arg* arg) {
+ if (arg == nullptr || arg->config == nullptr ||
+ arg->config->context() == nullptr) {
+ gpr_log(GPR_ERROR,
+ "server authorization check arg was not properly initialized");
+ return;
+ }
+ if (arg->context == nullptr) {
+ gpr_log(GPR_ERROR,
+ "server authorization check arg schedule has already completed");
+ return;
+ }
+ TlsServerAuthorizationCheckConfig* cpp_config =
+ static_cast<TlsServerAuthorizationCheckConfig*>(arg->config->context());
+ TlsServerAuthorizationCheckArg* cpp_arg =
+ static_cast<TlsServerAuthorizationCheckArg*>(arg->context);
+ cpp_config->Cancel(cpp_arg);
+}
+
+void TlsServerAuthorizationCheckArgDestroyContext(void* context) {
+ if (context != nullptr) {
+ TlsServerAuthorizationCheckArg* cpp_arg =
+ static_cast<TlsServerAuthorizationCheckArg*>(context);
+ delete cpp_arg;
+ }
+}
+
+} // namespace experimental
} // namespace grpc
diff --git a/contrib/libs/grpc/src/cpp/common/tls_credentials_options_util.h b/contrib/libs/grpc/src/cpp/common/tls_credentials_options_util.h
index 889fa3b55c..4ee04d15d7 100644
--- a/contrib/libs/grpc/src/cpp/common/tls_credentials_options_util.h
+++ b/contrib/libs/grpc/src/cpp/common/tls_credentials_options_util.h
@@ -1,58 +1,58 @@
-/*
- *
- * Copyright 2019 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef GRPC_INTERNAL_CPP_COMMON_TLS_CREDENTIALS_OPTIONS_UTIL_H
-#define GRPC_INTERNAL_CPP_COMMON_TLS_CREDENTIALS_OPTIONS_UTIL_H
-
-#include <grpc/grpc_security.h>
-#include <grpcpp/security/tls_credentials_options.h>
-
-#include "src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h"
-
+/*
+ *
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef GRPC_INTERNAL_CPP_COMMON_TLS_CREDENTIALS_OPTIONS_UTIL_H
+#define GRPC_INTERNAL_CPP_COMMON_TLS_CREDENTIALS_OPTIONS_UTIL_H
+
+#include <grpc/grpc_security.h>
+#include <grpcpp/security/tls_credentials_options.h>
+
+#include "src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h"
+
namespace grpc {
-namespace experimental {
-
-/** The following function is exposed for testing purposes. **/
-grpc_tls_key_materials_config* ConvertToCKeyMaterialsConfig(
- const std::shared_ptr<TlsKeyMaterialsConfig>& config);
-
-/** The following 4 functions convert the user-provided schedule or cancel
- * functions into C style schedule or cancel functions. These are internal
- * functions, not meant to be accessed by the user. **/
-int TlsCredentialReloadConfigCSchedule(void* config_user_data,
- grpc_tls_credential_reload_arg* arg);
-
-void TlsCredentialReloadConfigCCancel(void* config_user_data,
- grpc_tls_credential_reload_arg* arg);
-
-int TlsServerAuthorizationCheckConfigCSchedule(
- void* config_user_data, grpc_tls_server_authorization_check_arg* arg);
-
-void TlsServerAuthorizationCheckConfigCCancel(
- void* config_user_data, grpc_tls_server_authorization_check_arg* arg);
-
-/** The following 2 functions cleanup data created in the above C schedule
- * functions. **/
-void TlsCredentialReloadArgDestroyContext(void* context);
-
-void TlsServerAuthorizationCheckArgDestroyContext(void* context);
-
-} // namespace experimental
+namespace experimental {
+
+/** The following function is exposed for testing purposes. **/
+grpc_tls_key_materials_config* ConvertToCKeyMaterialsConfig(
+ const std::shared_ptr<TlsKeyMaterialsConfig>& config);
+
+/** The following 4 functions convert the user-provided schedule or cancel
+ * functions into C style schedule or cancel functions. These are internal
+ * functions, not meant to be accessed by the user. **/
+int TlsCredentialReloadConfigCSchedule(void* config_user_data,
+ grpc_tls_credential_reload_arg* arg);
+
+void TlsCredentialReloadConfigCCancel(void* config_user_data,
+ grpc_tls_credential_reload_arg* arg);
+
+int TlsServerAuthorizationCheckConfigCSchedule(
+ void* config_user_data, grpc_tls_server_authorization_check_arg* arg);
+
+void TlsServerAuthorizationCheckConfigCCancel(
+ void* config_user_data, grpc_tls_server_authorization_check_arg* arg);
+
+/** The following 2 functions cleanup data created in the above C schedule
+ * functions. **/
+void TlsCredentialReloadArgDestroyContext(void* context);
+
+void TlsServerAuthorizationCheckArgDestroyContext(void* context);
+
+} // namespace experimental
} // namespace grpc
-
-#endif // GRPC_INTERNAL_CPP_COMMON_TLS_CREDENTIALS_OPTIONS_UTIL_H
+
+#endif // GRPC_INTERNAL_CPP_COMMON_TLS_CREDENTIALS_OPTIONS_UTIL_H
diff --git a/contrib/libs/grpc/src/cpp/common/validate_service_config.cc b/contrib/libs/grpc/src/cpp/common/validate_service_config.cc
index f263c95f03..f63cfbc68c 100644
--- a/contrib/libs/grpc/src/cpp/common/validate_service_config.cc
+++ b/contrib/libs/grpc/src/cpp/common/validate_service_config.cc
@@ -1,40 +1,40 @@
-/*
- *
- * Copyright 2019 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <grpc/grpc.h>
-#include <grpcpp/support/validate_service_config.h>
-
-#include "src/core/ext/filters/client_channel/service_config.h"
-
-namespace grpc {
-namespace experimental {
+/*
+ *
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <grpc/grpc.h>
+#include <grpcpp/support/validate_service_config.h>
+
+#include "src/core/ext/filters/client_channel/service_config.h"
+
+namespace grpc {
+namespace experimental {
TString ValidateServiceConfigJSON(const TString& service_config_json) {
- grpc_init();
- grpc_error* error = GRPC_ERROR_NONE;
+ grpc_init();
+ grpc_error* error = GRPC_ERROR_NONE;
grpc_core::ServiceConfig::Create(/*args=*/nullptr,
service_config_json.c_str(), &error);
TString return_value;
- if (error != GRPC_ERROR_NONE) {
- return_value = grpc_error_string(error);
- GRPC_ERROR_UNREF(error);
- }
- grpc_shutdown();
- return return_value;
-}
-} // namespace experimental
-} // namespace grpc
+ if (error != GRPC_ERROR_NONE) {
+ return_value = grpc_error_string(error);
+ GRPC_ERROR_UNREF(error);
+ }
+ grpc_shutdown();
+ return return_value;
+}
+} // namespace experimental
+} // namespace grpc