func newHttpsClient(addr string) (*http.Client, error) {
	var tlsConfig = *TLSConfig
	host := strings.SplitN(addr, ":", 2)[0]
	if strings.HasSuffix(host, ".cloud.splunk.com") {
		tlsConfig.ServerName = strings.TrimPrefix(host, "input-")
	}
	httpsClient := &http.Client{Transport: &http.Transport{TLSClientConfig: &tlsConfig}}
	return httpsClient, nil
}
newHttpsClient returns a http.Client using the CACerts cert pool.
Additionally, if the address is a Splunk cloud address, it strips the "input-" prefix from the address when doing certificate validation. This is because Splunk cloud uses the cert for the web dashboard on the API address (which uses a different host name).
package splunk
import (
	"crypto/tls"
	"crypto/x509"
	"net/http"
	"strings"
)
const splunkCloudCACert = `
-----BEGIN CERTIFICATE-----
MIIB/DCCAaGgAwIBAgIBADAKBggqhkjOPQQDAjB+MSswKQYDVQQDEyJTcGx1bmsg
Q2xvdWQgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MRYwFAYDVQQHEw1TYW4gRnJhbmNp
c2NvMRMwEQYDVQQKEwpTcGx1bmsgSW5jMQswCQYDVQQIEwJDQTEVMBMGA1UECxMM
U3BsdW5rIENsb3VkMB4XDTE0MTExMDA3MDAxOFoXDTM0MTEwNTA3MDAxOFowfjEr
MCkGA1UEAxMiU3BsdW5rIENsb3VkIENlcnRpZmljYXRlIEF1dGhvcml0eTEWMBQG
A1UEBxMNU2FuIEZyYW5jaXNjbzETMBEGA1UEChMKU3BsdW5rIEluYzELMAkGA1UE
CBMCQ0ExFTATBgNVBAsTDFNwbHVuayBDbG91ZDBZMBMGByqGSM49AgEGCCqGSM49
AwEHA0IABPRRy9i3yQcxgMpvCSsI7Qe6YZMimUHOecPZWaGz5jEfB4+p5wT7dF3e
QrgjDWshVJZvK6KGO7nDh97GnbVXrTCjEDAOMAwGA1UdEwQFMAMBAf8wCgYIKoZI
zj0EAwIDSQAwRgIhALMUgLYPtICN9ci/ZOoXeZxUhn3i4wIo2mPKEWX0IcfpAiEA
8Jid6bzwUqAdDZPSOtaEBXV9uRIrNua0Qxl1S55TlWY=
-----END CERTIFICATE-----
`
var CACerts = x509.NewCertPool()
var TLSConfig = &tls.Config{RootCAs: CACerts}
func init() {
	CACerts.AppendCertsFromPEM([]byte(splunkCloudCACert))
}
func getHttpsClient(addr string) (*http.Client, error) {
	conn, err := tls.Dial("tcp", addr, nil)
	if err == nil {
		conn.Close()
		return http.DefaultClient, nil
	}
	return newHttpsClient(addr)
}