Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

neerajk22 avatar image
neerajk22 asked Erick Ramirez action

How do I connect to a SSL-enabled cluster using C# driver?

How to connect to SSL enabled Cassandra cluster using c# driver ?

I am using Cassandra hosted by different vendor and that is enabled with SSL

Tried below configuration but getting different errors

Note - In the zip bundle we have "cluster-ca-certificate.der" and "cluster-ca-certificate.pem" and "truststore.jks" only.

Kindly provide way to connect using above certificates.

Cluster.Builder()

//.AddContactPoints("")

//.WithPort(9042)

.WithCloudSecureConnectionBundle(@"filename.zip")

.WithLoadBalancingPolicy(new DCAwareRoundRobinPolicy(""))

.WithAuthProvider(new PlainTextAuthProvider("user", "password"))

.Build();

csharp driverencryption
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered neerajk22 commented

The Builder.WithCloudSecureConnectionBundle() method only works with Astra.

In your application, you need to use the Builder.WithSSL() method to configure the SSL options:

var cluster = Cluster.Builder()
    .AddContactPoints(...)
    .WithSSL()
    .Build();

In your previous questions, I've referred you to consult the C# driver documentation to familiarise yourself with how to develop apps. See the TLS/SSL section of the C# driver docs for more information.

There are also SSL code examples on the C# driver repository on GitHub you can use as reference. Cheers!

3 comments Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

yes already gone through this & tried couple of SSL opts

note-we have ca-cert.der, ca-cert.pem and truststore.jks

var cluster Cluster.Builder

AddContactPoints

WithPort 9042

WithLoadBalancingPolicy new DCAwareRoundRobinPolicy

WithAuthProvider new PlainTextAuthProvider superusr pass

WithCredentials user pass

WithSSL new SSLOptions SetCertificateCollection new X509Certificate2Collection


new X509Certificate2("path to .PEM or .DER cert"

WithSSL(new SSLOptions().SetRemoteCertValidationCallback(

(sender, certificate, chain, errors) serverCertificateValidator.Validate(certificate, chain, errors)))

WithSSL(new SSLOptions().SetCertificateRevocationCheck(true))

Build();

Error on - cluster.Connect(kespace name);

All hosts tried for query failed (tried host ip here:9042: AuthenticationException Authentication failed, see inner exception.'; host ip here:9042: IOException 'Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host

0 Likes 0 ·

If you're having issues, please contact your vendor to find out how to connect to their databases. Cheers!

0 Likes 0 ·
neerajk22 avatar image neerajk22 Erick Ramirez ♦♦ ·

sure, thanks.

0 Likes 0 ·