Skip to content

Commit 48ac36f

Browse files
authored
Fix: #180 Allow microcks client to handle insecure TLS requests (#182)
Signed-off-by: Harsh4902 <[email protected]>
1 parent 1e98293 commit 48ac36f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

cmd/login.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ microcks login http://localhost:8080 --sso --sso-launch-browser=false
6767
os.Exit(1)
6868
}
6969

70+
config.InsecureTLS = globalClientOpts.InsecureTLS
71+
config.CaCertPaths = globalClientOpts.CaCertPaths
72+
config.Verbose = globalClientOpts.Verbose
73+
7074
server = args[0]
7175
mc := connectors.NewMicrocksClient(server)
7276
keycloakUrl, err := mc.GetKeycloakURL()

pkg/connectors/microcks_client.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,16 @@ func NewClient(opts ClientOptions) (MicrocksClient, error) {
149149
c.Verbose = opts.Verbose
150150
}
151151

152-
c.httpClient = &http.Client{}
152+
if config.InsecureTLS || len(config.CaCertPaths) > 0 {
153+
tlsConfig := config.CreateTLSConfig()
154+
tr := &http.Transport{
155+
TLSClientConfig: tlsConfig,
156+
}
157+
c.httpClient = &http.Client{Transport: tr}
158+
} else {
159+
c.httpClient = http.DefaultClient
160+
}
161+
153162
if localCfg != nil {
154163
err = c.refreshAuthToken(localCfg, ctxName, opts.ConfigPath)
155164
if err != nil {

0 commit comments

Comments
 (0)