Skip to content

Commit 8fe7e0c

Browse files
committed
Fix: Allow all true-ish YAML values
1 parent f060f7e commit 8fe7e0c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pkg/scope/cluster.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222
"crypto/tls"
2323
"fmt"
2424
"net/http"
25+
"slices"
26+
"strings"
2527

2628
"github.com/go-logr/logr"
2729
"github.com/luthermonson/go-proxmox"
@@ -153,7 +155,7 @@ func (s *ClusterScope) setupProxmoxClient(ctx context.Context) (capmox.Client, e
153155
tokenSecret := string(secret.Data["secret"])
154156
url := string(secret.Data["url"])
155157

156-
tlsInsecure := string(secret.Data["insecure"]) != "false"
158+
tlsInsecure, tlsInsecureSet := secret.Data["insecure"]
157159
tlsRootCA := secret.Data["root_ca"]
158160

159161
rootCerts, err := tlshelper.SystemRootsWithCert(tlsRootCA)
@@ -163,7 +165,12 @@ func (s *ClusterScope) setupProxmoxClient(ctx context.Context) (capmox.Client, e
163165

164166
tr := &http.Transport{
165167
TLSClientConfig: &tls.Config{
166-
InsecureSkipVerify: tlsInsecure, //#nosec:G402 // Default retained, user can enable cert checking
168+
// When "insecure" is unset we retain the pre-v0.7 behavior of
169+
// setting the connection insecure. If it is set we compare
170+
// against YAML true-ish values.
171+
//
172+
//#nosec:G402 // Intended to enable insecure mode for unknown CAs
173+
InsecureSkipVerify: !tlsInsecureSet || slices.Contains([]string{"1", "on", "true", "yes", "y"}, strings.ToLower(string(tlsInsecure))),
167174
RootCAs: rootCerts,
168175
},
169176
}

0 commit comments

Comments
 (0)