【问题标题】:SSL options in gocqlgocql 中的 SSL 选项
【发布时间】:2016-06-28 11:46:11
【问题描述】:

在我的 Cassandra 配置中,我启用了用户身份验证并通过 ssl 与 cqlsh 连接。 我在用 gocql 实现相同时遇到问题,以下是我的代码:

cluster := gocql.NewCluster("127.0.0.1")
cluster.Authenticator = gocql.PasswordAuthenticator{
    Username: "myuser",
    Password: "mypassword",
}
cluster.SslOpts = &gocql.SslOptions {
    CertPath: "/path/to/cert.pem",
}

当我尝试连接时出现以下错误:

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

在 python 中,我可以这样做:

from cassandra.cluster import Cluster
from cassandra.auth import PlainTextAuthProvider
USER = 'username'
PASS = 'password'
ssl_opts = {'ca_certs': '/path/to/cert.pem',
        'ssl_version': PROTOCOL_TLSv1
}
credentials = PlainTextAuthProvider(username = USER, password = PASS)
# define host, port, cqlsh protocaol version
cluster = Cluster(contact_points= HOST, protocol_version= CQLSH_PROTOCOL_VERSION, auth_provider = credentials, port = CASSANDRA_PORT)

我检查了 gocql 和 TLS 文档 herehere,但我不确定如何设置 ssl 选项。

【问题讨论】:

    标签: ssl go cassandra cqlsh


    【解决方案1】:

    您正在添加一个没有私钥的证书,这是“没有这样的文件或目录”错误的来源。

    您的 python 代码正在添加 CA;你应该对 Go 代码做同样的事情:

    gocql.SslOptions {
        CaPath: "/path/to/cert.pem",
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-05
      • 2018-11-21
      • 1970-01-01
      相关资源
      最近更新 更多