Skip to content

Commit

Permalink
set transport to nil if there was an error connecting to the server w…
Browse files Browse the repository at this point in the history
…ith the file-based root ca

Signed-off-by: Chris Kim <[email protected]>
  • Loading branch information
Oats87 committed Jul 19, 2024
1 parent ce35815 commit d88c7eb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cmd/agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,13 @@ func run(ctx context.Context) error {
Timeout: time.Second * 5,
Transport: transport,
}
if _, err = httpClient.Get(server); err != nil && cluster.CAStrictVerify() {
logrus.Errorf("Could not securely connect to %s: %v", server, err)
os.Exit(1)
if _, err = httpClient.Get(server); err != nil {
if cluster.CAStrictVerify() {
logrus.Errorf("Could not securely connect to %s: %v", server, err)
os.Exit(1)
}
// onConnect will use the transport later on, so discard it as it doesn't work and fallback to the system store.
transport = nil
} else {
topContext = context.WithValue(topContext, cavalidator.CacertsValid, true)
systemStoreConnectionCheckRequired = false
Expand Down

0 comments on commit d88c7eb

Please sign in to comment.