summaryrefslogtreecommitdiffstats
path: root/library/cpp/actors/interconnect/interconnect_stream.cpp
diff options
context:
space:
mode:
authoryuryalekseev <[email protected]>2022-07-22 13:33:44 +0300
committeryuryalekseev <[email protected]>2022-07-22 13:33:44 +0300
commit5aaaf1ee4044f09b292da97e6b89c1d886ab37cf (patch)
treebf5278ad72b0668a21f97db7ded330bdc7e2b614 /library/cpp/actors/interconnect/interconnect_stream.cpp
parent48b8dd7fa906ee3da1a1c9ddf102b2aa5e6773c8 (diff)
Modify interconnect to get root CA in a grpc way if CA file is not provided.
Diffstat (limited to 'library/cpp/actors/interconnect/interconnect_stream.cpp')
-rw-r--r--library/cpp/actors/interconnect/interconnect_stream.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/library/cpp/actors/interconnect/interconnect_stream.cpp b/library/cpp/actors/interconnect/interconnect_stream.cpp
index ad46453acb7..ff3f0f0b52c 100644
--- a/library/cpp/actors/interconnect/interconnect_stream.cpp
+++ b/library/cpp/actors/interconnect/interconnect_stream.cpp
@@ -1,10 +1,15 @@
#include "interconnect_stream.h"
#include "logging.h"
+
+#include <library/cpp/grpc/common/default_root_certs.h>
#include <library/cpp/openssl/init/init.h>
+
#include <util/network/socket.h>
+
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/pem.h>
+#include <openssl/x509_vfy.h>
#if defined(_win_)
#include <util/system/file.h>
@@ -319,6 +324,20 @@ namespace NInterconnect {
if (caFilePath) {
ret = SSL_CTX_load_verify_locations(Ctx.get(), caFilePath.data(), nullptr);
Y_VERIFY(ret == 1);
+ } else {
+ auto defaultPemRootCerts = NGrpc::GetDefaultPemRootCerts();
+ if (defaultPemRootCerts != nullptr) {
+ std::unique_ptr<BIO, TDeleter> bio(BIO_new_mem_buf(defaultPemRootCerts, -1));
+ Y_VERIFY(bio);
+
+ auto store = SSL_CTX_get_cert_store(Ctx.get());
+ Y_VERIFY(store != nullptr);
+
+ while (auto cert = PEM_read_bio_X509(bio.get(), nullptr, 0, nullptr)) {
+ ret = X509_STORE_add_cert(store, cert);
+ Y_VERIFY(ret == 1, "X509_STORE_add_cert failed, reason: %s", ERR_reason_error_string(ERR_peek_last_error()));
+ }
+ }
}
int success = SSL_CTX_set_cipher_list(Ctx.get(), ciphers ? ciphers.data() : "AES128-GCM-SHA256");