Skip to content

Commit f833d5f

Browse files
committed
fix insecure
1 parent f1be565 commit f833d5f

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

pkg/controller/vsphere/session/session.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package session
1818

1919
import (
2020
"context"
21+
"crypto/tls"
2122
"errors"
2223
"fmt"
2324
"io"
@@ -159,7 +160,7 @@ func newClientWithTimeout(ctx context.Context, u *url.URL, insecure bool, timeou
159160
*/
160161

161162
customTransport := &CustomTransport{
162-
RoundTripper: http.DefaultTransport,
163+
RoundTripper: createTransport(insecure),
163164
}
164165

165166
soapClient := soap.NewClient(u, insecure)
@@ -363,3 +364,18 @@ func (s *Session) WithCachingTagsManager(ctx context.Context, f func(m *CachingT
363364

364365
return f(m)
365366
}
367+
368+
// createTransport creates a transport that respects the insecure flag
369+
func createTransport(insecure bool) http.RoundTripper {
370+
if insecure {
371+
// Create a transport that skips TLS verification
372+
transport := &http.Transport{
373+
TLSClientConfig: &tls.Config{
374+
InsecureSkipVerify: true,
375+
},
376+
}
377+
return transport
378+
}
379+
// Use default transport for secure connections
380+
return http.DefaultTransport
381+
}

0 commit comments

Comments
 (0)