Commit
·
ee5adc7
1
Parent(s):
cef2a2c
- rabbit_base.py +7 -7
rabbit_base.py
CHANGED
|
@@ -2,7 +2,7 @@ from typing import Callable, Dict, List, Optional
|
|
| 2 |
import aio_pika
|
| 3 |
from urllib.parse import urlsplit, unquote
|
| 4 |
from config import settings
|
| 5 |
-
import ssl
|
| 6 |
|
| 7 |
ExchangeResolver = Callable[[str], str] # exchangeName -> exchangeType
|
| 8 |
|
|
@@ -19,7 +19,7 @@ def _parse_amqp_url(url: str) -> dict:
|
|
| 19 |
"login": parts.username or "guest",
|
| 20 |
"password": parts.password or "guest",
|
| 21 |
"virtualhost": unquote(parts.path[1:] or "/"),
|
| 22 |
-
"ssl": parts.scheme == "amqps",
|
| 23 |
}
|
| 24 |
|
| 25 |
|
|
@@ -38,12 +38,12 @@ class RabbitBase:
|
|
| 38 |
|
| 39 |
conn_kwargs = _parse_amqp_url(str(settings.AMQP_URL))
|
| 40 |
|
| 41 |
-
#
|
| 42 |
if conn_kwargs.get("ssl"):
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
conn_kwargs["
|
| 47 |
|
| 48 |
self._conn = await aio_pika.connect_robust(**conn_kwargs)
|
| 49 |
self._chan = await self._conn.channel()
|
|
|
|
| 2 |
import aio_pika
|
| 3 |
from urllib.parse import urlsplit, unquote
|
| 4 |
from config import settings
|
| 5 |
+
import ssl
|
| 6 |
|
| 7 |
ExchangeResolver = Callable[[str], str] # exchangeName -> exchangeType
|
| 8 |
|
|
|
|
| 19 |
"login": parts.username or "guest",
|
| 20 |
"password": parts.password or "guest",
|
| 21 |
"virtualhost": unquote(parts.path[1:] or "/"),
|
| 22 |
+
"ssl": parts.scheme == "amqps", # bool for now; we may override with SSLContext
|
| 23 |
}
|
| 24 |
|
| 25 |
|
|
|
|
| 38 |
|
| 39 |
conn_kwargs = _parse_amqp_url(str(settings.AMQP_URL))
|
| 40 |
|
| 41 |
+
# Proper way: override the boolean with an SSLContext to disable verification
|
| 42 |
if conn_kwargs.get("ssl"):
|
| 43 |
+
ctx = ssl.create_default_context()
|
| 44 |
+
ctx.check_hostname = False
|
| 45 |
+
ctx.verify_mode = ssl.CERT_NONE
|
| 46 |
+
conn_kwargs["ssl"] = ctx # <-- pass the context here, not via ssl_options
|
| 47 |
|
| 48 |
self._conn = await aio_pika.connect_robust(**conn_kwargs)
|
| 49 |
self._chan = await self._conn.channel()
|