From 0fc723d62fefff0262237ad9c16058b21cfd668a Mon Sep 17 00:00:00 2001 From: "t.fouchard" Date: Mon, 7 Oct 2019 14:02:18 +0200 Subject: [PATCH] Use system certs --- connector/gitlab/gitlab.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/connector/gitlab/gitlab.go b/connector/gitlab/gitlab.go index a9b0abe2b2..0da420079c 100644 --- a/connector/gitlab/gitlab.go +++ b/connector/gitlab/gitlab.go @@ -3,6 +3,8 @@ package gitlab import ( "context" + "crypto/tls" + "crypto/x509" "encoding/json" "errors" "fmt" @@ -128,6 +130,17 @@ func (c *gitlabConnector) HandleCallback(s connector.Scopes, r *http.Request) (i ctx := r.Context() if c.httpClient != nil { ctx = context.WithValue(r.Context(), oauth2.HTTPClient, c.httpClient) + } else { + rootCAs, _ := x509.SystemCertPool() + if rootCAs == nil { + rootCAs = x509.NewCertPool() + } + c.httpClient = &http.Client{ + Transport: &http.Transport{ + TLSClientConfig: &tls.Config{ClientCAs: rootCAs}, + }, + } + ctx = context.WithValue(r.Context(), oauth2.HTTPClient, c.httpClient) } token, err := oauth2Config.Exchange(ctx, q.Get("code"))