问题:Cassandra C#驱动程序:AuthenticateAsClient
抛出异常。
场景:遵循http://www.datastax.com/documentation/cassandra/2.0/cassandra/security/secureSslEncryptionTOC.html
中的所有步骤Cassandra社区服务器已成功启动,没有任何错误。
它会引发异常。如果我遗漏了任何内容,请告诉我。
抛出异常:
对SSPI的调用失败,请参阅内部异常。
内部异常:收到的消息是意外的或格式错误的
以下是代码段。
public static void RunClient(string machineName)
{
// Create a TCP/IP client socket.
// machineName is the host running the server application.
TcpClient client = new TcpClient(machineName, 7001);
Console.WriteLine("Client connected.");
// Create an SSL stream that will close the client's stream.
SslStream sslStream = new SslStream(
client.GetStream(),
false,
new RemoteCertificateValidationCallback(ValidateServerCertificate),
null
);
// The server name must match the name on the server certificate.
X509Certificate2 cert2 = new X509Certificate2("C:\\Program Files\\DataStax Community\\apache-cassandra\\conf\\DELL.cer", "xyzxyzxy");
X509Certificate2Collection xc = new X509Certificate2Collection(cert2);
try
{
//(_socketStream as SslStream).AuthenticateAsClient(targetHost, new X509CertificateCollection(), protocolOptions.SslOptions.SslProtocol, false);
sslStream.AuthenticateAsClient(machineName, xc, SslProtocols.Tls, true);
}
catch (AuthenticationException e)
{
Console.WriteLine("Exception: {0}", e.Message);
if (e.InnerException != null)
{
Console.WriteLine("Inner exception: {0}", e.InnerException.Message);
}
Console.WriteLine("Authentication failed - closing the connection.");
client.Close();
return;
}
}