简体   繁体   中英

Authentication Exception when trying to connect to Amazon Keyspaces using .net core and cassandra csharp driver from linux

I created a keyspace(table) in amazon keyspace and was trying to get the records from it to my .net core application which was running in ubuntu.I have provided every thing required such as ".pem" file username,password and awsEndpoint as mentioned in the aws documentation Using a Cassandra .NET Core Client Driver to Access Amazon Keyspaces Programmatically

But when I ran the code and tried to connect with amazon keyspace, it raises an exception " All hosts tried for query failed (tried 3.6.70.143:9142: AuthenticationException 'Authentication failed, see inner exception.') ".

But the same code executes properly and brings back desired result when executed from an windows environment.

X509Certificate2Collection certCollection = new X509Certificate2Collection();
        X509Certificate2 amazoncert = new X509Certificate2(@"./Security/AmazonRootCA1.pem","");
        var userName = "username";
        var pwd = "password";
       
        certCollection.Add(amazoncert);

        var awsEndpoint =  "cassandra.ap-south-1.amazonaws.com" ;  
        try
        {
            var cluster = Cluster.Builder()
                 .AddContactPoints(awsEndpoint)
                 .WithPort(9142)
                 .WithAuthProvider(new PlainTextAuthProvider(userName, pwd))
                 .WithSSL(new SSLOptions().SetCertificateCollection(certCollection))
                 .Build();

        var session = cluster.Connect();
        var rs = session.Execute("select * from tutorialkeyspace.tutorialtable;");

尝试将证书添加到 linux 信任库。

keytool -import -alias cassandra -keystore cassandra_truststore.jks -file temp_file.der```

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM