File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -8,13 +8,15 @@ import (
88 "context"
99 "crypto/tls"
1010 "crypto/x509"
11+ "encoding/base64"
1112 "net/http"
1213 "os"
1314 "strconv"
1415
1516 "github.com/pkg/errors"
1617
1718 "github.com/vmware-tanzu/tanzu-plugin-runtime/config"
19+ "github.com/vmware-tanzu/tanzu-plugin-runtime/log"
1820)
1921
2022const (
@@ -162,12 +164,22 @@ func (c *hubClient) getTLSConfig() *tls.Config {
162164 // If CACertData is present use it
163165 if certData .CACertData != "" {
164166 var pool * x509.CertPool
165- var err error
167+
168+ decodedCACertData , err := base64 .StdEncoding .DecodeString (certData .CACertData )
169+ if err != nil {
170+ log .Infof ("unable to use custom cert for '%s' endpoint. Error: %s" , c .tanzuHubEndpoint , err .Error ())
171+ return nil
172+ }
173+
166174 pool , err = x509 .SystemCertPool ()
167175 if err != nil || pool == nil {
168176 pool = x509 .NewCertPool ()
169177 }
170- pool .AppendCertsFromPEM ([]byte (certData .CACertData ))
178+
179+ if ok := pool .AppendCertsFromPEM (decodedCACertData ); ! ok {
180+ log .Infof ("unable to use custom cert for %s endpoint" , c .tanzuHubEndpoint )
181+ return nil
182+ }
171183 return & tls.Config {RootCAs : pool , MinVersion : tls .VersionTLS12 }
172184 }
173185
You can’t perform that action at this time.
0 commit comments