1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

add option to skip verification of jenkins server's certificate chain and hostname

This commit is contained in:
Anand Sudhir Prayaga
2018-07-18 14:10:29 +02:00
parent 4a1caf6e7c
commit 37b0d22dba
3 changed files with 22 additions and 2 deletions

View File

@@ -2,12 +2,15 @@ package jenkins
import (
"bytes"
"crypto/tls"
"encoding/json"
"io"
"io/ioutil"
"net/http"
"net/url"
"strings"
"github.com/senorprogrammer/wtf/wtf"
)
func Create(jenkinsURL string, username string, apiKey string) (*View, error) {
@@ -26,7 +29,13 @@ func Create(jenkinsURL string, username string, apiKey string) (*View, error) {
req, _ := http.NewRequest("GET", jenkinsAPIURL.String(), nil)
req.SetBasicAuth(username, apiKey)
httpClient := &http.Client{}
verifyServerCertificate := wtf.Config.UBool("wtf.mods.jenkins.verifyServerCertificate", true)
httpClient := &http.Client{Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: !verifyServerCertificate,
},
},
}
resp, err := httpClient.Do(req)
if err != nil {