How to connect to yugabyte instance from app using certificates? Able to connect via ycqlsh but not from golang application

137 views Asked by At

I was able to connect to the yugabyte cassandra instance through ycqlsh with the given certificates.

ycqlsh <host> --ssl

Have exported the env var SSL_CERTFILE. This works but from the golang application passing the same certificates gives me an error.

func getYugaByteConnection() *gocql.Session {
    cluster := gocql.NewCluster("<host>")
    cluster.Timeout = 12 * time.Second
    //cluster.ConnectTimeout = 12 * time.Second
    cluster.SslOpts = &gocql.SslOptions{
        EnableHostVerification: true,
        CertPath:               "path/to/cert.pem",
    }

    session, err := cluster.CreateSession()
    if err != nil {
        log.Println(err)
    }

    return session
}

This gives me an error saying

gocql: unable to create session: connectionpool: unable to load X509 key pair: open : no such file or directory

Can someone explain why it works with ycqlsh and not from the application and also what changes I'd need to make to establish the connection from the app.

0

There are 0 answers