Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
queue: Allow enabling TLS for the RabbitMQ connection.
Alex Vandiverbf532de8bb2b
diff --git a/zerver/lib/queue.py b/zerver/lib/queue.pyindex 106ad64f593..9532fbc6b89 100644--- a/zerver/lib/queue.py+++ b/zerver/lib/queue.py@@ -1,10 +1,11 @@import loggingimport random+import sslimport threadingimport timefrom abc import ABCMeta, abstractmethodfrom collections import defaultdict-from typing import Any, Callable, Dict, Generic, List, Mapping, Optional, Set, TypeVar, Union+from typing import Any, Callable, Dict, Generic, List, Mapping, Optional, Set, Type, TypeVar, Unionimport orjsonimport pika@@ -77,11 +78,18 @@ class QueueClient(Generic[ChannelT], metaclass=ABCMeta):if self.rabbitmq_heartbeat == 0:tcp_options = dict(TCP_KEEPIDLE=60 * 5)+ ssl_options: Union[+ Type[pika.ConnectionParameters._DEFAULT], pika.SSLOptions+ ] = pika.ConnectionParameters._DEFAULT+ if settings.RABBITMQ_USE_TLS:+ ssl_options = pika.SSLOptions(context=ssl.create_default_context())+return pika.ConnectionParameters(settings.RABBITMQ_HOST,port=settings.RABBITMQ_PORT,heartbeat=self.rabbitmq_heartbeat,tcp_options=tcp_options,+ ssl_options=ssl_options,credentials=credentials,)diff --git a/zproject/default_settings.py b/zproject/default_settings.pyindex c0a11e1890a..e27a82e80f8 100644--- a/zproject/default_settings.py+++ b/zproject/default_settings.py@@ -173,6 +173,7 @@ MEMCACHED_USERNAME = None if get_secret("memcached_password") is None else "zuliRABBITMQ_HOST = "127.0.0.1"RABBITMQ_PORT = 5672RABBITMQ_USERNAME = "zulip"+RABBITMQ_USE_TLS = FalseREDIS_HOST = "127.0.0.1"REDIS_PORT = 6379REMOTE_POSTGRES_HOST = ""diff --git a/zproject/prod_settings_template.py b/zproject/prod_settings_template.pyindex 2175b6a0c16..cce35745ccf 100644--- a/zproject/prod_settings_template.py+++ b/zproject/prod_settings_template.py@@ -584,6 +584,10 @@ SOCIAL_AUTH_SAML_SUPPORT_CONTACT = {# RABBITMQ_PORT = 5672## To use another RabbitMQ user than the default "zulip", set RABBITMQ_USERNAME here.# RABBITMQ_USERNAME = "zulip"+## To access the RabbitMQ server over TLS, set this to True; this is+## generally only necessary if RabbitMQ is running on a separate,+## cloud-managed, host.+# RABBITMQ_USE_TLS = False########## Redis configuration.