I'm trying to skip certificate verification while trying to do a https request to a server. The client.Do() fails with the following error:
tls: failed to parse certificate from server: asn1: syntax error: PrintableString contains invalid character
Code Snippet:
var jsonStr = []byte(`{"grant_type":"client_credentials"}`)
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr))
fmt.Println("req:>", req)
//req.Header.Set("Content-Type", "application/json")
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.SetBasicAuth("opennms", "test123~")
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{Transport: tr}
//client := &http.Client{}
resp, err := client.Do(req)
fmt.Println("resp:>", resp)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println("response Body:", string(body))
What am I missing here?