You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by li...@apache.org on 2022/01/28 05:53:56 UTC
[rocketmq-client-cpp] 01/01: Upgrade grpc to v1.44.0-pre2
This is an automated email from the ASF dual-hosted git repository.
lizhanhui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq-client-cpp.git
commit ac2b07f49c0f37c3f4b229d62414d93ee29f3584
Author: Li Zhanhui <li...@gmail.com>
AuthorDate: Fri Jan 28 13:52:39 2022 +0800
Upgrade grpc to v1.44.0-pre2
---
bazel/rocketmq_deps.bzl | 9 ++++++---
src/main/cpp/client/ClientManagerImpl.cpp | 9 +++++----
src/main/cpp/client/include/ClientManagerImpl.h | 2 +-
src/main/cpp/client/include/TlsHelper.h | 26 ++++---------------------
src/test/cpp/it/RpcClientTest.cpp | 6 +-----
src/test/cpp/it/TopicPublishInfoTest.cpp | 7 +------
6 files changed, 18 insertions(+), 41 deletions(-)
diff --git a/bazel/rocketmq_deps.bzl b/bazel/rocketmq_deps.bzl
index d593bee..be4509a 100644
--- a/bazel/rocketmq_deps.bzl
+++ b/bazel/rocketmq_deps.bzl
@@ -83,9 +83,12 @@ def rocketmq_deps():
if "com_github_grpc_grpc" not in native.existing_rules():
http_archive(
name = "com_github_grpc_grpc",
- strip_prefix = "grpc-1.39.0",
- sha256 = "b16992aa1c949c10d5d5ce2a62f9d99fa7de77da2943e643fb66dcaf075826d6",
- urls = ["https://github.com/grpc/grpc/archive/v1.39.0.tar.gz"],
+ strip_prefix = "grpc-1.44.0-pre2-oss",
+ sha256 = "c12a560ad6cd55afcd6f6d8da533267fa7132704d27d0857b01c0d2e2b634fea",
+ urls = [
+ "https://shutian.oss-cn-hangzhou.aliyuncs.com/cdn/grpc/grpc-1.44.0-pre2-oss.tar.gz",
+ "https://github.com/lizhanhui/grpc/archive/refs/tags/v1.44.0-pre2-oss.tar.gz",
+ ],
)
if "io_opentelemetry_cpp" not in native.existing_rules():
diff --git a/src/main/cpp/client/ClientManagerImpl.cpp b/src/main/cpp/client/ClientManagerImpl.cpp
index db77dc8..55591dc 100644
--- a/src/main/cpp/client/ClientManagerImpl.cpp
+++ b/src/main/cpp/client/ClientManagerImpl.cpp
@@ -53,8 +53,8 @@ ClientManagerImpl::ClientManagerImpl(std::string resource_namespace)
latency_histogram_("Message-Latency", 11) {
spdlog::set_level(spdlog::level::trace);
assignLabels(latency_histogram_);
- server_authorization_check_config_ = std::make_shared<grpc::experimental::TlsServerAuthorizationCheckConfig>(
- std::make_shared<TlsServerAuthorizationChecker>());
+ // server_authorization_check_config_ = std::make_shared<grpc::experimental::TlsServerAuthorizationCheckConfig>(
+ // std::make_shared<TlsServerAuthorizationChecker>());
// Make use of encryption only at the moment.
std::vector<grpc::experimental::IdentityKeyCertPair> identity_key_cert_list;
@@ -65,10 +65,11 @@ ClientManagerImpl::ClientManagerImpl(std::string resource_namespace)
identity_key_cert_list.emplace_back(pair);
certificate_provider_ =
std::make_shared<grpc::experimental::StaticDataCertificateProvider>(TlsHelper::CA, identity_key_cert_list);
- tls_channel_credential_options_.set_server_verification_option(GRPC_TLS_SKIP_ALL_SERVER_VERIFICATION);
+ // tls_channel_credential_options_.set_server_verification_option(GRPC_TLS_SKIP_ALL_SERVER_VERIFICATION);
tls_channel_credential_options_.set_certificate_provider(certificate_provider_);
- tls_channel_credential_options_.set_server_authorization_check_config(server_authorization_check_config_);
+ // tls_channel_credential_options_.set_server_authorization_check_config(server_authorization_check_config_);
tls_channel_credential_options_.watch_root_certs();
+ tls_channel_credential_options_.set_verify_server_certs(false);
tls_channel_credential_options_.watch_identity_key_cert_pairs();
channel_credential_ = grpc::experimental::TlsCredentials(tls_channel_credential_options_);
diff --git a/src/main/cpp/client/include/ClientManagerImpl.h b/src/main/cpp/client/include/ClientManagerImpl.h
index 47d3390..4c7a559 100644
--- a/src/main/cpp/client/include/ClientManagerImpl.h
+++ b/src/main/cpp/client/include/ClientManagerImpl.h
@@ -265,7 +265,7 @@ private:
/**
* TLS configuration
*/
- std::shared_ptr<grpc::experimental::TlsServerAuthorizationCheckConfig> server_authorization_check_config_;
+ // std::shared_ptr<grpc::experimental::TlsServerAuthorizationCheckConfig> server_authorization_check_config_;
std::shared_ptr<grpc::experimental::CertificateProviderInterface> certificate_provider_;
grpc::experimental::TlsChannelCredentialsOptions tls_channel_credential_options_;
std::shared_ptr<grpc::ChannelCredentials> channel_credential_;
diff --git a/src/main/cpp/client/include/TlsHelper.h b/src/main/cpp/client/include/TlsHelper.h
index b96f4d6..8d6c174 100644
--- a/src/main/cpp/client/include/TlsHelper.h
+++ b/src/main/cpp/client/include/TlsHelper.h
@@ -16,16 +16,15 @@
*/
#pragma once
-#include "rocketmq/RocketMQ.h"
#include <string>
#include <utility>
+#include "grpcpp/client_context.h"
+#include "grpcpp/create_channel.h"
#include "grpcpp/security/tls_credentials_options.h"
-#include <grpcpp/client_context.h>
-#include <grpcpp/create_channel.h>
-#include <openssl/x509.h>
+#include "openssl/x509.h"
-#include "spdlog/spdlog.h"
+#include "LoggerImpl.h"
ROCKETMQ_NAMESPACE_BEGIN
@@ -41,21 +40,4 @@ public:
static const char* client_private_key;
};
-class TlsServerAuthorizationChecker : public grpc::experimental::TlsServerAuthorizationCheckInterface {
-public:
- int Schedule(grpc::experimental::TlsServerAuthorizationCheckArg* arg) override {
- if (nullptr == arg) {
- return 0;
- }
-
- arg->set_success(1);
- arg->set_status(GRPC_STATUS_OK);
- return 0;
- }
-
- ~TlsServerAuthorizationChecker() override {
- SPDLOG_DEBUG("~TlsServerAuthorizationChecker() invoked");
- }
-};
-
ROCKETMQ_NAMESPACE_END
\ No newline at end of file
diff --git a/src/test/cpp/it/RpcClientTest.cpp b/src/test/cpp/it/RpcClientTest.cpp
index fe39204..9709c4f 100644
--- a/src/test/cpp/it/RpcClientTest.cpp
+++ b/src/test/cpp/it/RpcClientTest.cpp
@@ -44,8 +44,6 @@ class RpcClientTest : public ::testing::Test {
protected:
RpcClientTest() : completion_queue_(std::make_shared<grpc::CompletionQueue>()) {
- server_authorization_check_config_ = std::make_shared<grpc::experimental::TlsServerAuthorizationCheckConfig>(
- std::make_shared<TlsServerAuthorizationChecker>());
std::vector<grpc::experimental::IdentityKeyCertPair> pem_list;
grpc::experimental::IdentityKeyCertPair pair{};
pair.private_key = TlsHelper::client_private_key;
@@ -54,8 +52,7 @@ protected:
certificate_provider_ =
std::make_shared<grpc::experimental::StaticDataCertificateProvider>(TlsHelper::CA, pem_list);
tls_channel_credential_options_.set_certificate_provider(certificate_provider_);
- tls_channel_credential_options_.set_server_verification_option(GRPC_TLS_SKIP_ALL_SERVER_VERIFICATION);
- tls_channel_credential_options_.set_server_authorization_check_config(server_authorization_check_config_);
+ tls_channel_credential_options_.set_verify_server_certs(false);
tls_channel_credential_options_.watch_root_certs();
tls_channel_credential_options_.watch_identity_key_cert_pairs();
channel_credential_ = grpc::experimental::TlsCredentials(tls_channel_credential_options_);
@@ -200,7 +197,6 @@ protected:
CredentialsProviderPtr credentials_provider_;
std::shared_ptr<grpc::experimental::StaticDataCertificateProvider> certificate_provider_;
grpc::experimental::TlsChannelCredentialsOptions tls_channel_credential_options_;
- std::shared_ptr<grpc::experimental::TlsServerAuthorizationCheckConfig> server_authorization_check_config_;
std::shared_ptr<grpc::ChannelCredentials> channel_credential_;
grpc::ChannelArguments channel_arguments_;
std::string message_id_{UniqueIdGenerator::instance().next()};
diff --git a/src/test/cpp/it/TopicPublishInfoTest.cpp b/src/test/cpp/it/TopicPublishInfoTest.cpp
index 1edfea0..4a6fcfb 100644
--- a/src/test/cpp/it/TopicPublishInfoTest.cpp
+++ b/src/test/cpp/it/TopicPublishInfoTest.cpp
@@ -29,10 +29,6 @@ ROCKETMQ_NAMESPACE_BEGIN
class TopicPublishInfoTest : public ::testing::Test {
protected:
TopicPublishInfoTest() : completion_queue_(std::make_shared<grpc::CompletionQueue>()) {
- server_authorization_check_config_ = std::make_shared<grpc::experimental::TlsServerAuthorizationCheckConfig>(
- std::make_shared<TlsServerAuthorizationChecker>());
- tls_channel_credential_option_.set_server_verification_option(GRPC_TLS_SKIP_HOSTNAME_VERIFICATION);
-
std::vector<grpc::experimental::IdentityKeyCertPair> pem_list;
grpc::experimental::IdentityKeyCertPair pair{};
pair.private_key = TlsHelper::client_private_key;
@@ -41,7 +37,7 @@ protected:
certificate_provider_ =
std::make_shared<grpc::experimental::StaticDataCertificateProvider>(TlsHelper::CA, pem_list);
tls_channel_credential_option_.set_certificate_provider(certificate_provider_);
- tls_channel_credential_option_.set_server_authorization_check_config(server_authorization_check_config_);
+ tls_channel_credential_option_.set_verify_server_certs(false);
tls_channel_credential_option_.watch_root_certs();
tls_channel_credential_option_.watch_identity_key_cert_pairs();
channel_credential_ = grpc::experimental::TlsCredentials(tls_channel_credential_option_);
@@ -87,7 +83,6 @@ protected:
CredentialsProviderPtr credentials_provider_;
std::shared_ptr<grpc::experimental::CertificateProviderInterface> certificate_provider_;
grpc::experimental::TlsChannelCredentialsOptions tls_channel_credential_option_;
- std::shared_ptr<grpc::experimental::TlsServerAuthorizationCheckConfig> server_authorization_check_config_;
std::shared_ptr<grpc::ChannelCredentials> channel_credential_;
grpc::ChannelArguments channel_arguments_;
};