Can't connect to CosmosDB using Cqlsh

Pushkal Sharma 1 Reputation point
2020-07-06T04:31:22.7+00:00

Following is the configuration I have

In cassandra.yml file content
client_encryption_options:
require_client_auth: false
protocol: TLSv1.2

cqlshrc.sample.ssl file content
[authentication]
username = username
password = password
[connection]
hostname = host
port = 9042
factory = cqlshlib.ssl.ssl_transport_factory
[ssl]
certfile = /cacerts.pem
validate = false
version = SSLv23

export JAVA_HOME=<java 1.8 home path>
export PATH=<add python of version 2.7.12 in the path>

Follwoing is the command I am executing
cqlsh myhost.cosmos.azure.com 10350 -u user -p passowrd --cqlshrc=<cqlshrc.sample.ssl file path> --ssl --cqlversion=3.4.4

Following is the error I am getting
Connection error: ('Unable to connect to any servers', {'ip': IndexError('list index out of range',)})

Following are the versions being used
DSE: 6.7.8
CQL: 3.4.5

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,632 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Mike Ubezzi 2,776 Reputation points
    2020-07-07T02:07:04.287+00:00

    Hi @PushkalSharma-4553 - In your specific scenario, have you added the Baltimore CyberTrust root certificate to the Java certificate store?

     # Import the Baltimore CyberTrust root certificate:
      curl https://cacert.omniroot.com/bc2025.crt > bc2025.crt
      keytool -importcert -alias bc2025ca -file bc2025.crt
    

    If it is of any help, and I am not sure if you are attempting to implement a specific solution or just looking for a csql interface but, the following can be implemented on Linux, Mac, and Windows or you can use the csql interface available in the portal. Please see: Hosted CQL shell

     # Install default-jre and default-jdk
      sudo apt install default-jre
      sudo apt-get update
      sudo apt install default-jdk
            
      # Import the Baltimore CyberTrust root certificate:
      curl https://cacert.omniroot.com/bc2025.crt > bc2025.crt
      keytool -importcert -alias bc2025ca -file bc2025.crt
            
      # Install the Cassandra libraries in order to get CQLSH:
      echo "deb http://www.apache.org/dist/cassandra/debian 311x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list
      curl https://downloads.apache.org/cassandra/KEYS | sudo apt-key add -
      sudo apt-get update
      sudo apt-get install cassandra
            
      # Export the SSL variables:
      export SSL_VERSION=TLSv1_2
      export SSL_VALIDATE=false
            
      # Connect to Azure Cosmos DB API for Cassandra:
      cqlsh <YOUR_ACCOUNT_NAME>.cassandra.cosmosdb.azure.com 10350 -u <YOUR_ACCOUNT_NAME> -p <YOUR_ACCOUNT_PASSWORD> --ssl
    

    The following is a screen capture of my bash shell session on Windows 10 (Windows sub-system support for Linux enabled) and connecting to a CosmosDB Cassandra API instance:

    11310-screenshot-111.png


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.