Hi - I am trying to call a restful API using a certificate. The pem file I have is of the format:
-----BEGIN RSA PRIVATE KEY----- data is here -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- data is here -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- data is here -----END CERTIFICATE----- The code that i am using is //creating the certificate for call caCert, err := ioutil.ReadFile("certFil.pem") if err != nil { log.Fatal(err) } caCertPool := x509.NewCertPool() caCertPool.AppendCertsFromPEM(caCert) client := &http.Client{ Transport: &http.Transport{ TLSClientConfig: &tls.Config{ RootCAs: caCertPool, }, }, } //end of creating the certificate for call //creating the body for call url := "https://mydomain.com:11215/myuri/path1/path2" fmt.Println("URL:>", url) var jsonStr = []byte(`{ "My JSON" } `) req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr)) req.Header.Set("Accept", "application/json;v=3") req.Header.Set("Cache-Control", "no-cache, no-store") req.Header.Set("Connection", "Keep-Alive") req.Header.Set("User-Agent", "HttpClient") req.Header.Set("Content-Type", "application/json;v=3") //client := &http.Client{} resp, err := client.Do(req) if err != nil { panic(err) } defer resp.Body.Close() When I run this code I get an exception: x509: certificate is valid for anotherDomain.com, not myDomain.com Can you please help me solve this issue? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.