This is an automated email from the ASF dual-hosted git repository.

zixuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-client-go.git


The following commit(s) were added to refs/heads/master by this push:
     new 03aabd4  Fix load tls certificate (#888)
03aabd4 is described below

commit 03aabd44663505e1ed2791ec46ad526ec988c12d
Author: Zixuan Liu <[email protected]>
AuthorDate: Tue Nov 15 18:26:47 2022 +0800

    Fix load tls certificate (#888)
    
    Signed-off-by: Zixuan Liu <[email protected]>
---
 pulsar/internal/connection.go  | 2 +-
 pulsar/internal/http_client.go | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/pulsar/internal/connection.go b/pulsar/internal/connection.go
index c34f25d..fc1b349 100644
--- a/pulsar/internal/connection.go
+++ b/pulsar/internal/connection.go
@@ -986,7 +986,7 @@ func (c *connection) getTLSConfig() (*tls.Config, error) {
                c.log.Debugf("getTLSConfig(): setting tlsConfig.ServerName = 
%+v", tlsConfig.ServerName)
        }
 
-       if c.tlsOptions.CertFile != "" || c.tlsOptions.KeyFile != "" {
+       if c.tlsOptions.CertFile != "" && c.tlsOptions.KeyFile != "" {
                cert, err := tls.LoadX509KeyPair(c.tlsOptions.CertFile, 
c.tlsOptions.KeyFile)
                if err != nil {
                        return nil, errors.New(err.Error())
diff --git a/pulsar/internal/http_client.go b/pulsar/internal/http_client.go
index 3c68dac..7abf70d 100644
--- a/pulsar/internal/http_client.go
+++ b/pulsar/internal/http_client.go
@@ -346,7 +346,7 @@ func getDefaultTransport(tlsConfig *TLSOptions) 
(http.RoundTripper, error) {
                        cfg.RootCAs.AppendCertsFromPEM(rootCA)
                }
 
-               if tlsConfig.CertFile != "" || tlsConfig.KeyFile != "" {
+               if tlsConfig.CertFile != "" && tlsConfig.KeyFile != "" {
                        cert, err := tls.LoadX509KeyPair(tlsConfig.CertFile, 
tlsConfig.KeyFile)
                        if err != nil {
                                return nil, errors.New(err.Error())

Reply via email to