diff --git a/trustgraph-flow/trustgraph/direct/cassandra.py b/trustgraph-flow/trustgraph/direct/cassandra.py index d06b270f..73f1f33a 100644 --- a/trustgraph-flow/trustgraph/direct/cassandra.py +++ b/trustgraph-flow/trustgraph/direct/cassandra.py @@ -1,6 +1,7 @@ from cassandra.cluster import Cluster from cassandra.auth import PlainTextAuthProvider +from ssl import SSLContext, PROTOCOL_TLSv1_2 class TrustGraph: @@ -17,8 +18,9 @@ class TrustGraph: self.username = username if username and password: + ssl_context = SSLContext(PROTOCOL_TLSv1_2) auth_provider = PlainTextAuthProvider(username=username, password=password) - self.cluster = Cluster(hosts, auth_provider=auth_provider) + self.cluster = Cluster(hosts, auth_provider=auth_provider, ssl_context=ssl_context) else: self.cluster = Cluster(hosts) self.session = self.cluster.connect() diff --git a/trustgraph-flow/trustgraph/librarian/table_store.py b/trustgraph-flow/trustgraph/librarian/table_store.py index ca10a05e..1fe47fcf 100644 --- a/trustgraph-flow/trustgraph/librarian/table_store.py +++ b/trustgraph-flow/trustgraph/librarian/table_store.py @@ -6,6 +6,7 @@ from .. exceptions import RequestError from cassandra.cluster import Cluster from cassandra.auth import PlainTextAuthProvider from cassandra.query import BatchStatement +from ssl import SSLContext, PROTOCOL_TLSv1_2 import uuid import time @@ -21,12 +22,14 @@ class TableStore: print("Connecting to Cassandra...", flush=True) if cassandra_user and cassandra_password: + ssl_context = SSLContext(PROTOCOL_TLSv1_2) auth_provider = PlainTextAuthProvider( username=cassandra_user, password=cassandra_password ) self.cluster = Cluster( cassandra_host, - auth_provider=auth_provider + auth_provider=auth_provider, + ssl_context=ssl_context ) else: self.cluster = Cluster(cassandra_host) diff --git a/trustgraph-flow/trustgraph/storage/rows/cassandra/write.py b/trustgraph-flow/trustgraph/storage/rows/cassandra/write.py index c8f3b9e1..e6536e6c 100755 --- a/trustgraph-flow/trustgraph/storage/rows/cassandra/write.py +++ b/trustgraph-flow/trustgraph/storage/rows/cassandra/write.py @@ -10,6 +10,7 @@ import argparse import time from cassandra.cluster import Cluster from cassandra.auth import PlainTextAuthProvider +from ssl import SSLContext, PROTOCOL_TLSv1_2 from .... schema import Rows from .... schema import rows_store_queue @@ -17,6 +18,7 @@ from .... log_level import LogLevel from .... base import Consumer module = ".".join(__name__.split(".")[1:-1]) +ssl_context = SSLContext(PROTOCOL_TLSv1_2) default_input_queue = rows_store_queue default_subscriber = module @@ -45,7 +47,7 @@ class Processor(Consumer): if graph_username and graph_password: auth_provider = PlainTextAuthProvider(username=graph_username, password=graph_password) - self.cluster = Cluster(graph_host.split(","), auth_provider=auth_provider) + self.cluster = Cluster(graph_host.split(","), auth_provider=auth_provider, ssl_context=ssl_context) else: self.cluster = Cluster(graph_host.split(",")) self.session = self.cluster.connect()