Using cqlsh with SSL

Using a cqlshrc file is the easiest method of getting cqlshrc settings. The cqlshrc.sample provides an example that can be copied as a starting point.

Prerequisites

Prepare SSL certificates with a self-signed CA for production, or prepare SSL certificates for development. Additionally, configure client-to-node encryption.

Procedure

  1. To run cqlsh with SSL encryption, create a .cassandra/cqlshrc file in with the following settings:
[authentication]
username = fred
password = !!bang!!$

[connection]
hostname = 127.0.0.1
port = 9042
 
[ssl]
certfile = ~/keys/tclient.keystore
validate = false ;; Optional, true by default. See the paragraph below.    

[certfiles] ;; Optional section, overrides the default certfile in the [ssl] section.
127.0.0.1 = /etc/cassandra/conf/keys2/server.crt
10.209.182.160 = /etc/dse/cassandra/conf/dsenode0.cer 
10.68.65.199 = /etc/dse/cassandra/conf/dsenode1.cer

When validate is enabled, to verify that the certificate is trusted the host in the certificate is compared to the host of the machine to which it is connected. Note that the rootCa certificate and key are supplied to access the trustchain. The SSL certificate must be provided either in the configuration file or as an environment variable. The environment variables (SSL_CERTFILE and SSL_VALIDATE) override any options set in this file.Note: Additional settings in the cqlshrc file are described in Creating and using the cqlshrc file.

An optional section, [certfiles], will override the default certfile in the [ssl] section. The use of the same IP addresses in the [certfiles] section, as is used to generate the dname of the certificates, is required for two-way SSL encryption. Each node must have a line in the [certfiles] section for client-to-remote-node or node-to-node. Using certfiles] is more common for development clusters.Start cqlsh with the –ssl option for cqlsh to local node encrypted connection.

cqlsh --ssl ## Package installations
$ install_location/bin/cqlsh --ssl ## Tarball installations

A username and password can also be supplied at cqlsh startup. This example provides the username cassandra with password cassandra.

cqlsh --ssl ## Package installations
$ install_location/bin/cqlsh --ssl -u cassandra -p cassandra ## Tarball installations

Note that a username and password can be entered in the cqlshrc file so that it will be automatically read each time cqlsh is started.For a remote node encrypted connection, start cqlsh with the –ssl option and an IP address:

cqlsh --ssl ## Package installations
$ install_location/bin/cqlsh --ssl 172.31.10.22 ## Tarball installations

LEAVE A COMMENT