# Issue with go client and self signed certificates

**URL:** <https://forum.opensearch.org/t/issue-with-go-client-and-self-signed-certificates/9142>\
**Category:** OpenSearch Client Libraries\
**Tags:** opensearch-go\
**Created:** [April 5, 2022, 11:21pm UTC](https://forum.opensearch.org/t/issue-with-go-client-and-self-signed-certificates/9142 "2022-04-05T23:21:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thedraketaylor](https://avatars.discourse-cdn.com/v4/letter/t/3da27b/32.png) [@thedraketaylor](https://forum.opensearch.org/u/thedraketaylor)\
**Post date:** [April 5, 2022, 11:21pm UTC](https://forum.opensearch.org/t/issue-with-go-client-and-self-signed-certificates/9142/1 "2022-04-05T23:21:55Z")

</div>

I’ve created a cluster with self signed certs. dashboards is connecting fine, and I can use curl to connect to the cluster fine like so: `curl --cacert /path/to/cert https://user:password@node1.domain.com:9200`  
However, when I use the following code:

```auto
package main

import (
	"fmt"
	"io/ioutil"
	"log"

	"github.com/elastic/go-elasticsearch/v7"
)

func main() {
	cert, _ := ioutil.ReadFile("/path/to/cert")
	cfg := elasticsearch.Config{
		Addresses: []string{
			"https://node1.domain.com:9200",
		},
		Username: "user",
		Password: "password",
		CACert: cert,
	}
	es, err := elasticsearch.NewClient(cfg)
	if err != nil {
		log.Fatalf("Error creating the client: %s", err)
	}
	results, err := es.Info()
	if err != nil {
		log.Fatalf("Error getting response: %s", err)
	}
	fmt.Println(results.Status())
	defer results.Body.Close()

	fmt.Println(results)
}

```

I get the following error: Error getting response: x509: certificate relies on legacy Common Name field, use SANs instead

Can someone help me figure out why this isn’t working? Thanks!

---

<div class="post-metadata">

**Author:** ![kris](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/kris/32/2208_2.png) [@kris](https://forum.opensearch.org/u/kris)\
**Post date:** [February 7, 2023, 6:37pm UTC](https://forum.opensearch.org/t/issue-with-go-client-and-self-signed-certificates/9142/2 "2023-02-07T18:37:00Z")

</div>

Closed on February 7, 2023, 6:37pm UTC


