Skip to content

Commit

Permalink
fix(cqlshrc): safely update cqlshrc
Browse files Browse the repository at this point in the history
Cqlshrc config can require update depending on whether client encryption is enabled/disabled
in the configuration under test. Until now the update was not safe in terms that it was
expected that 'ssl' section is present in the config by default.

The change updates how 'ssl' section is set in the cqlshrc.

Fixes #8113
  • Loading branch information
dimakr authored and fruch committed Jul 24, 2024
1 parent b77c4de commit b3885be
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sdcm/provision/scylla_yaml/certificate_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@
def update_cqlshrc(cqlshrc_file: str = CQLSHRC_FILE, client_encrypt: bool = False) -> None:
config = configparser.ConfigParser()
config.read(cqlshrc_file)
config['ssl']['validate'] = 'true' if client_encrypt else 'false'
config['ssl'] = {
'validate': 'true' if client_encrypt else 'false',
'certfile': f'{SCYLLA_SSL_CONF_DIR / CA_CERT_FILE.name}',
'userkey': f'{SCYLLA_SSL_CONF_DIR / CLIENT_FACING_KEYFILE.name}',
'usercert': f'{SCYLLA_SSL_CONF_DIR / CLIENT_FACING_CERTFILE.name}'
}
with open(cqlshrc_file, 'w', encoding='utf-8') as file:
config.write(file)

Expand Down

0 comments on commit b3885be

Please sign in to comment.