douxian6008 2016-03-13 13:05
浏览 92

gocql中的SSL选项

In my Cassandra config I have enabled user authentication and connect with cqlsh over ssl. I'm having trouble implementing the same with gocql, following is my code:

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

When I try to connect I get following error:

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

In python I can do this with something like:

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)

I checked the gocql and TLS documentation here and here but I'm unsure about how to set ssl options.

  • 写回答

1条回答 默认 最新

  • dongpalou5352 2016-03-14 15:09
    关注

    You're adding a cert without a private key, which is where the "no such file or directory" error is coming from.

    Your python code is adding a CA; you should do the same with the Go code:

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

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型