Skip to content

Conversation

@digiserg
Copy link
Contributor

@digiserg digiserg commented Feb 6, 2026

Summary

  • Add expandPath helper function that expands ~ to the user's home directory
  • Apply path expansion to CertPath, KeyPath, and CAPath before loading SSL certificates
  • Use $HOME environment variable with fallback to os.UserHomeDir() for robustness

Test plan

  • Verify SSL connection works with paths using ~ (e.g., ~/.cassandra/cqlsh.crt)
  • Verify SSL connection still works with absolute paths
  • Verify behavior when $HOME is not set (uses os.UserHomeDir() fallback)

Fixes #72

Add expandPath helper function to expand ~ to the user's home directory
when loading SSL certificates. This fixes the issue where relative paths
like ~/.cassandra/cqlsh.crt were not being found because the tilde was
not expanded to the actual home directory path.

Fixes #72
@digiserg digiserg linked an issue Feb 6, 2026 that may be closed by this pull request
@digiserg digiserg requested a review from hshimizu February 6, 2026 15:34
The G304 warning is suppressed because the CA certificate path comes
from trusted user configuration, not untrusted input.
@digiserg digiserg requested review from millerjp and rgooding February 9, 2026 09:57

// expandPath expands ~ to the user's home directory
func expandPath(path string) string {
if strings.HasPrefix(path, "~") {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For safety is it maybe worth checking that the path starts with ~/ rather than just ~?

@digiserg digiserg merged commit 6421cfb into main Feb 9, 2026
15 checks passed
@digiserg digiserg deleted the 72-cannot-use-relative-paths-for-ssl-certs branch February 9, 2026 17:47
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

Successfully merging this pull request may close these issues.

Cannot use relative paths for SSL certs

2 participants