Billy S Boutin
Billy S Boutin

Reputation: 11

cassandra.yaml file does not allow embedded quotes in certificate passwords

My truststore password, for example '3mDhxcIRNfmQcd, contains a single quote as its first character. When I enter this password in the cassandra.yaml file, cassandra fails to start.

Exception (org.apache.cassandra.exceptions.ConfigurationException) encountered during startup: Invalid yaml: file:/etc/cassandra/default.conf/cassandra.yaml
org.apache.cassandra.exceptions.ConfigurationException: Invalid yaml: file:/etc/cassandra/default.conf/cassandra.yaml
        at org.apache.cassandra.config.YamlConfigurationLoader.loadConfig(YamlConfigurationLoader.java:118)
        at org.apache.cassandra.config.YamlConfigurationLoader.loadConfig(YamlConfigurationLoader.java:85)
        at org.apache.cassandra.config.DatabaseDescriptor.loadConfig(DatabaseDescriptor.java:135)
        at org.apache.cassandra.config.DatabaseDescriptor.<clinit>(DatabaseDescriptor.java:119)
        at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:491)
        at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:625)
Caused by: while scanning a quoted scalar
 in 'reader', line 750, column 26:
        truststore_password: '3mDhxcIRNfmQcd
                             ^
found unexpected end of stream
 in 'reader', line 771, column 1:

    ^

This is not a problem if the quote is contained within the password or is the trailing character of the password. I have read in cassandra documentation that you can use a single quotation mark itself in a string literal by escaping it using a single quotation mark.This does not work. Is there a way to use this type of password in the cassandra.yaml file?

Upvotes: 0

Views: 376

Answers (2)

JayK
JayK

Reputation: 800

Encapsulate the entire string with single quotes. Then escape single quotes with another single quote. For example:

 keystore_password: 'pas''sword'

Upvotes: 1

phact
phact

Reputation: 7305

I believe you use '' (two sequential single quotes) to escape single quotes in a yaml file.

Upvotes: 1

Related Questions