Skip to content

Commit ba5831b

Browse files
authored
Adds TLS support to Cassandra State Store (dapr#3230)
Adds TLS support to Cassandra State Store
1 parent 1f12557 commit ba5831b

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

state/cassandra/cassandra.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,16 @@ type Cassandra struct {
6262
}
6363

6464
type cassandraMetadata struct {
65-
Hosts []string
66-
Port int
67-
ProtoVersion int
68-
ReplicationFactor int
69-
Username string
70-
Password string
71-
Consistency string
72-
Table string
73-
Keyspace string
65+
Hosts []string
66+
Port int
67+
ProtoVersion int
68+
ReplicationFactor int
69+
Username string
70+
Password string
71+
Consistency string
72+
Table string
73+
Keyspace string
74+
EnableHostVerification bool
7475
}
7576

7677
// NewCassandraStateStore returns a new cassandra state store.
@@ -136,6 +137,11 @@ func (c *Cassandra) createClusterConfig(metadata *cassandraMetadata) (*gocql.Clu
136137
if metadata.Username != "" && metadata.Password != "" {
137138
clusterConfig.Authenticator = gocql.PasswordAuthenticator{Username: metadata.Username, Password: metadata.Password}
138139
}
140+
if metadata.EnableHostVerification {
141+
clusterConfig.SslOpts = &gocql.SslOptions{
142+
EnableHostVerification: true,
143+
}
144+
}
139145
clusterConfig.Port = metadata.Port
140146
clusterConfig.ProtoVersion = metadata.ProtoVersion
141147
cons, err := c.getConsistency(metadata.Consistency)

state/cassandra/metadata.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ metadata:
3838
description: "Port for communication."
3939
default: "9042"
4040
example: "8080"
41+
- name: enableHostVerification
42+
type: bool
43+
description: "Enables host verification. Secures the traffic between client server with TLS."
44+
default: "false"
45+
example: "true"
4146
- name: table
4247
type: string
4348
description: "The name of the table to use."

0 commit comments

Comments
 (0)