【发布时间】:2020-09-13 12:15:33
【问题描述】:
我正在尝试使用此代码连接到 AWS Cassandra:
var pathToCAFile = $"{Directory.GetCurrentDirectory()}/AmazonRootCA1.pem";
X509Certificate2[] certs = new X509Certificate2[] { new X509Certificate2(pathToCAFile, "amazon") };
X509Certificate2Collection certificateCollection = new X509Certificate2Collection(certs);
var options = new Cassandra.SSLOptions(SslProtocols.Tls11, true, ValidateServerCertificate);
options.SetCertificateCollection(certificateCollection);
Cluster cluster = Cluster
.Builder()
.WithCredentials("username", "password")
.WithPort(9142)
.AddContactPoint("cassandra.us-east-1.amazonaws.com")
.WithSSL()
.WithLoadBalancingPolicy(new DefaultLoadBalancingPolicy("us-east-1"))
.Build();
// Connect to the nodes using a keyspace
var session = cluster.Connect("system_distributed");
// Execute a query on a connection synchronously
var rs = session.Execute("select * from system.peers");
这是我得到的错误:
"Cassandra.NoHostAvailableException: '所有主机尝试查询失败 (试过 3.83.169.143:9142: AuthenticationException '远程 根据验证程序,证书无效。')'
这个异常最初是在这个调用栈中抛出的:
Cassandra.Connections.Control.ControlConnection.Connect(bool) System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task) System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() Cassandra.Connections.Control.ControlConnection.InitAsync() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task) System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() ... [调用堆栈被截断]
【问题讨论】:
标签: c# amazon-web-services cassandra