Issue with go client and self signed certificates

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:

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!