skip https verification if GIT_SSL_NO_VERIFY is set
This commit is contained in:
parent
7a08d7001f
commit
f83b028792
@ -1,6 +1,7 @@
|
||||
package gitmediaclient
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
@ -150,8 +151,25 @@ func validateMediaHeader(contentType string, reader io.Reader) (bool, *gitmedia.
|
||||
return true, nil
|
||||
}
|
||||
|
||||
var httpClient *http.Client
|
||||
|
||||
func getHttpClient() *http.Client {
|
||||
if httpClient == nil {
|
||||
if len(os.Getenv("GIT_SSL_NO_VERIFY")) > 0 {
|
||||
tr := &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
}
|
||||
httpClient = &http.Client{Transport: tr}
|
||||
} else {
|
||||
httpClient = http.DefaultClient
|
||||
}
|
||||
}
|
||||
|
||||
return httpClient
|
||||
}
|
||||
|
||||
func doRequest(req *http.Request, creds Creds) (*http.Response, *gitmedia.WrappedError) {
|
||||
res, err := http.DefaultClient.Do(req)
|
||||
res, err := getHttpClient().Do(req)
|
||||
|
||||
var wErr *gitmedia.WrappedError
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user