Skip to content

Commit

Permalink
fix: Enable ssl without certs (#63)
Browse files Browse the repository at this point in the history
* fix: support_redis_ssl_without_certs

* feat: update workflow

* fix: workflow

* chore: add note
  • Loading branch information
RonitKissis authored Apr 17, 2024
1 parent 913fd0f commit 41ba575
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 24 deletions.
8 changes: 1 addition & 7 deletions config/patch/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1256,9 +1256,6 @@ def _redis_cache(self, grid_conf, file_ext):
ttl = self.conf['cache'].get('default_ttl', 3600)
username = self.conf['cache'].get('username', None)
password = self.conf['cache'].get('password', None)
ssl_certfile = self.conf['cache'].get('ssl_certfile', None)
ssl_keyfile = self.conf['cache'].get('ssl_keyfile', None)
ssl_ca_certs = self.conf['cache'].get('ssl_ca_certs', None)

prefix = self.conf['cache'].get('prefix')
if not prefix:
Expand All @@ -1271,10 +1268,7 @@ def _redis_cache(self, grid_conf, file_ext):
username=username,
password=password,
prefix=prefix,
ttl=ttl,
ssl_certfile=ssl_certfile,
ssl_keyfile=ssl_keyfile,
ssl_ca_certs=ssl_ca_certs
ttl=ttl
)

def _compact_cache(self, grid_conf, file_ext):
Expand Down
19 changes: 6 additions & 13 deletions config/patch/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,10 @@

class RedisCache(TileCacheBase):
def __init__(
self, host, port, prefix, ttl=0, db=0, username=None, password=None,ssl_certfile=None,
ssl_keyfile=None, ssl_ca_certs=None):
self, host, port, prefix, ttl=0, db=0, username=None, password=None):
if redis is None:
raise ImportError("Redis backend requires 'redis' package.")

self.ssl_certfile = ssl_certfile
self.ssl_keyfile = ssl_keyfile
self.ssl_ca_certs = ssl_ca_certs

self.prefix = prefix
self.lock_cache_id = 'redis-' + hashlib.md5((host + str(port) + prefix + str(db)).encode('utf-8')).hexdigest()
self.ttl = ttl
Expand All @@ -57,9 +52,9 @@ def __init__(
self.socket_connection_timeout = float(os.environ.get('SOCKET_CONNECTION_TIMEOUT_SECONDS', 0.1))

ssl_enabled = get_redis_variable("REDIS_TLS")
ssl_certfile = self.ssl_certfile if ssl_enabled else None
ssl_keyfile = self.ssl_keyfile if ssl_enabled else None
ssl_ca_certs = self.ssl_ca_certs if ssl_enabled else None
# didnt add this variable in the values and config map file to let it be None on purpose for now
cert_reqs = os.environ.get("SSL_CERTS_REQS", None)

self.r = redis.StrictRedis(
host=host,
port=port,
Expand All @@ -68,10 +63,8 @@ def __init__(
password=password,
socket_timeout=self.socket_timeout,
socket_connect_timeout=self.socket_connection_timeout,
ssl_certfile=ssl_certfile,
ssl_keyfile=ssl_keyfile,
ssl_ca_certs=ssl_ca_certs,
ssl=ssl_enabled
ssl=ssl_enabled,
ssl_cert_reqs=cert_reqs
)

def _key(self, tile):
Expand Down
4 changes: 0 additions & 4 deletions config/patch/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,6 @@ def validate_options(conf_dict):
'username': str(),
'prefix': str(),
'default_ttl': int(),
'ssl_certfile': str(),
'ssl_keyfile': str(),
'ssl_ca_certs': str(),

},
'compact': {
'directory': str(),
Expand Down

0 comments on commit 41ba575

Please sign in to comment.