Skip to content

Cassandra: Fix TLS host verification #2109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* [ENHANCEMENT] Added `cortex_distributor_latest_seen_sample_timestamp_seconds` metric to see how far behind Prometheus servers are in sending data. #2371
* [ENHANCEMENT] FIFO cache to support eviction based on memory usage. The `-<prefix>.fifocache.size` CLI flag has been renamed to `-<prefix>.fifocache.max-size-items` as well as its YAML config option `size` renamed to `max_size_items`. Added `-<prefix>.fifocache.max-size-bytes` CLI flag and YAML config option `max_size_bytes` to specify memory limit of the cache. #2319
* [BUGFIX] Experimental TSDB: fixed chunk data corruption when querying back series using the experimental blocks storage. #2400
* [BUGFIX] Cassandra Storage: Fix endpoint TLS host verification. #2109

## 1.0.0 / 2020-04-02

Expand Down
19 changes: 16 additions & 3 deletions pkg/chunk/cassandra/storage_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cassandra
import (
"bytes"
"context"
"crypto/tls"
"flag"
"fmt"
"io/ioutil"
Expand Down Expand Up @@ -68,6 +69,9 @@ func (cfg *Config) Validate() error {
if cfg.Password.Value != "" && cfg.PasswordFile != "" {
return errors.Errorf("The password and password_file config options are mutually exclusive.")
}
if cfg.SSL && cfg.HostVerification && len(strings.Split(cfg.Addresses, ",")) != 1 {
return errors.Errorf("Host verification is only possible for a single host.")
}
return nil
}

Expand Down Expand Up @@ -118,9 +122,18 @@ func (cfg *Config) setClusterConfig(cluster *gocql.ClusterConfig) error {
cluster.DisableInitialHostLookup = cfg.DisableInitialHostLookup

if cfg.SSL {
cluster.SslOpts = &gocql.SslOptions{
CaPath: cfg.CAPath,
EnableHostVerification: cfg.HostVerification,
if cfg.HostVerification {
cluster.SslOpts = &gocql.SslOptions{
CaPath: cfg.CAPath,
EnableHostVerification: true,
Config: &tls.Config{
ServerName: strings.Split(cfg.Addresses, ",")[0],
},
}
} else {
cluster.SslOpts = &gocql.SslOptions{
EnableHostVerification: false,
}
}
}
if cfg.Auth {
Expand Down