0

In my Go App, I make a call to Hostname+"/translate/12345

Thing is depending the environment, in local Hostname will be on http, and in production, it will be on https

When I test the production route on https with postman, there is no problem, route works fine.

But when I run it from WS, I get:

Get https://<mydomain.com>/translate/2327496366232: x509: certificate signed by unknown authority"

Here is my code:

var terID string
client := http.Client{}
req, err := http.NewRequest("GET", Hostname+"/translate/"+terID, nil)
if err != nil {
    return "", err
}
req.SetBasicAuth(Username, Password)
res, err := client.Do(req)
if err != nil {
    return "", err
}

What can I do to fix that ?

Juliatzin
  • 18,455
  • 40
  • 166
  • 325
  • 1
    close to https://stackoverflow.com/questions/12122159/how-to-do-a-https-request-with-bad-certificate / https://stackoverflow.com/questions/47464161/golang-http-x509-certificate-signed-by-unknown-authority-error –  May 10 '19 at 14:40

1 Answers1

1

According to https://github.com/andygrunwald/go-jira/issues/52, please try

import ("net/http"; "crypto/tls")

tr := &http.Transport{
    TLSClientConfig: &tls.Config{InsecureSkipVerify : true},
}
client := &http.Client{Transport: tr}
Wenli Wan
  • 605
  • 5
  • 8