diff options
-rw-r--r-- | client/httpclient.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/client/httpclient.go b/client/httpclient.go index fceb0f4..a2ecfd0 100644 --- a/client/httpclient.go +++ b/client/httpclient.go @@ -74,6 +74,13 @@ func NewHTTPClientWithOpts(gitlabURL, gitlabRelativeURLRoot, caFile, caPath stri } else if strings.HasPrefix(gitlabURL, httpProtocol) { transport, host = buildHttpTransport(gitlabURL) } else if strings.HasPrefix(gitlabURL, httpsProtocol) { + if _, err := os.Stat(caFile); err != nil { + if os.IsNotExist(err) { + return nil, fmt.Errorf("cannot find cafile '%s': %w", caFile, ErrCafileNotFound) + } + return nil, err + } + hcc := &httpClientCfg{ caFile: caFile, caPath: caPath, @@ -83,13 +90,6 @@ func NewHTTPClientWithOpts(gitlabURL, gitlabRelativeURLRoot, caFile, caPath stri opt(hcc) } - if _, err := os.Stat(caFile); err != nil { - if os.IsNotExist(err) { - return nil, fmt.Errorf("cannot find cafile '%s': %w", caFile, ErrCafileNotFound) - } - return nil, err - } - transport, host, err = buildHttpsTransport(*hcc, selfSignedCert, gitlabURL) if err != nil { return nil, err |