Merge pull request #268 from zeeZ/fix-server-name-verification

Use hostname from request URL for server name verification.
pull/273/head
Hunter Long 2019-11-05 12:25:42 -08:00 committed by GitHub
commit c4d1cdcf0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -286,12 +286,15 @@ func HttpRequest(url, method string, content interface{}, headers []string, body
if content != nil {
req.Header.Set("Content-Type", content.(string))
}
verifyHost := req.URL.Hostname()
for _, h := range headers {
keyVal := strings.Split(h, "=")
if len(keyVal) == 2 {
if keyVal[0] != "" && keyVal[1] != "" {
if strings.ToLower(keyVal[0]) == "host" {
req.Host = strings.TrimSpace(keyVal[1])
verifyHost = req.Host
} else {
req.Header.Set(keyVal[0], keyVal[1])
}
@ -308,7 +311,7 @@ func HttpRequest(url, method string, content interface{}, headers []string, body
transport := &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: !verifySSL,
ServerName: req.Host,
ServerName: verifyHost,
},
DisableKeepAlives: true,
ResponseHeaderTimeout: timeout,