From c335f3d80c8f476fb3870dcac792c5dda213d26c Mon Sep 17 00:00:00 2001 From: Baodi Shi Date: Mon, 26 Jun 2023 11:21:10 +0800 Subject: [PATCH] back tls related. --- index.d.ts | 2 ++ src/Client.cc | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/index.d.ts b/index.d.ts index bd471469..e11605a9 100644 --- a/index.d.ts +++ b/index.d.ts @@ -29,6 +29,8 @@ export interface ClientConfig { tlsTrustCertsFilePath?: string; tlsValidateHostname?: boolean; tlsAllowInsecureConnection?: boolean; + tlsCertificateFilePath?: string; + tlsPrivateKeyFilePath?: string; statsIntervalInSeconds?: number; log?: (level: LogLevel, file: string, line: number, message: string) => void; } diff --git a/src/Client.cc b/src/Client.cc index f557a089..f8eade78 100644 --- a/src/Client.cc +++ b/src/Client.cc @@ -38,6 +38,8 @@ static const std::string CFG_USE_TLS = "useTls"; static const std::string CFG_TLS_TRUST_CERT = "tlsTrustCertsFilePath"; static const std::string CFG_TLS_VALIDATE_HOSTNAME = "tlsValidateHostname"; static const std::string CFG_TLS_ALLOW_INSECURE = "tlsAllowInsecureConnection"; +static const std::string CFG_TLS_CERTIFICATE_FILE_PATH = "tlsCertificateFilePath"; +static const std::string CFG_TLS_PRIVATE_KEY_FILE_PATH = "tlsPrivateKeyFilePath"; static const std::string CFG_STATS_INTERVAL = "statsIntervalInSeconds"; static const std::string CFG_LOG = "log"; @@ -175,6 +177,12 @@ Client::Client(const Napi::CallbackInfo &info) : Napi::ObjectWrap(info) pulsar_client_configuration_set_validate_hostname(cClientConfig.get(), tlsValidateHostname.Value()); } + if (clientConfig.Has(CFG_TLS_ALLOW_INSECURE) && clientConfig.Get(CFG_TLS_ALLOW_INSECURE).IsBoolean()) { + Napi::Boolean tlsAllowInsecureConnection = clientConfig.Get(CFG_TLS_ALLOW_INSECURE).ToBoolean(); + pulsar_client_configuration_set_tls_allow_insecure_connection(cClientConfig.get(), + tlsAllowInsecureConnection.Value()); + } + if (clientConfig.Has(CFG_TLS_ALLOW_INSECURE) && clientConfig.Get(CFG_TLS_ALLOW_INSECURE).IsBoolean()) { Napi::Boolean tlsAllowInsecureConnection = clientConfig.Get(CFG_TLS_ALLOW_INSECURE).ToBoolean(); pulsar_client_configuration_set_tls_allow_insecure_connection(cClientConfig.get(),