Skip to content

Commit

Permalink
Use system certs
Browse files Browse the repository at this point in the history
  • Loading branch information
hightoxicity committed Nov 28, 2019
1 parent c410357 commit 0fc723d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions connector/gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package gitlab

import (
"context"
"crypto/tls"
"crypto/x509"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -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"))
Expand Down

0 comments on commit 0fc723d

Please sign in to comment.