Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update suggestion: Connecting to amazon keyspaces #8

Open
DanielF93Dev opened this issue Oct 18, 2020 · 0 comments
Open

Update suggestion: Connecting to amazon keyspaces #8

DanielF93Dev opened this issue Oct 18, 2020 · 0 comments

Comments

@DanielF93Dev
Copy link

DanielF93Dev commented Oct 18, 2020

I was killing my head since the last two days trying to connect my laravel app to amazon keyspaces.

After reading the documentation at datastax, I found the way to load the amazon PEM certificate and finally I could connect.

Would be great if the following changes are made on connection.php

protected function createConnection(array $config)
    {
       $ssl = Cassandra::ssl()
               ->withVerifyFlags(Cassandra::VERIFY_PEER_CERT)
               ->withTrustedCerts($config['cert_path'])
               ->build();     
        
        $cluster   = Cassandra::cluster()
        ->withContactPoints($config['host'])
        ->withPort((int) $config['port'])
        ->withCredentials($config['username'],$config['password'])
        ->withSSL($ssl)
        ->withDefaultConsistency(Cassandra::CONSISTENCY_LOCAL_QUORUM)
        ->build();

        $keyspace  = $config['keyspace'];
        $connection   = $cluster->connect($keyspace);
        return $connection;

    }

It is required to set the certificate path variable as well.

For some reason I found that even if the environmental variables were configured, the connection was being always made to localhost, that is why I loaded the environmental variables using the $config array.

The queries return a Cassandra/Rows Object , I have to convert them to string or reading them in loops but that is not a problem.

Thanks for your library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant