Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Commit 1d161ec

Browse files
authored
Merge pull request #29 from Worth-NL/feature/sec/e2e-ssl
Client-side SSL
2 parents 8f769b2 + f1bc29d commit 1d161ec

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

app/celery/service_callback_tasks.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,28 @@ def send_complaint_to_service(self, complaint_data):
5858
def _send_data_to_service_callback_api(self, data, service_callback_url, token, function_name):
5959
notification_id = data["notification_id"] if "notification_id" in data else data["id"]
6060
try:
61-
response = request(
62-
method="POST",
63-
url=service_callback_url,
64-
data=json.dumps(data),
65-
headers={"Content-Type": "application/json", "Authorization": "Bearer {}".format(token)},
66-
timeout=5,
67-
)
61+
ssl_crt = current_app.config["SSL_CLIENT_OVERRIDE_CERT"]
62+
63+
if ssl_crt:
64+
current_app.logger.warning("!!! USING CLIENT CERT !!!")
65+
response = request(
66+
method="POST",
67+
url=service_callback_url,
68+
data=json.dumps(data),
69+
headers={"Content-Type": "application/json", "Authorization": "Bearer {}".format(token)},
70+
cert=ssl_crt,
71+
timeout=5,
72+
)
73+
else:
74+
current_app.logger.warning("!!! NOT USING CLIENT CERT !!!")
75+
response = request(
76+
method="POST",
77+
url=service_callback_url,
78+
data=json.dumps(data),
79+
headers={"Content-Type": "application/json", "Authorization": "Bearer {}".format(token)},
80+
timeout=5,
81+
)
82+
6883
current_app.logger.info(
6984
"%s sending %s to %s, response %s",
7085
function_name,
@@ -108,9 +123,9 @@ def create_delivery_status_callback_data(notification, service_callback_api):
108123
"notification_to": notification.to,
109124
"notification_status": notification.status,
110125
"notification_created_at": notification.created_at.strftime(DATETIME_FORMAT),
111-
"notification_updated_at": notification.updated_at.strftime(DATETIME_FORMAT)
112-
if notification.updated_at
113-
else None,
126+
"notification_updated_at": (
127+
notification.updated_at.strftime(DATETIME_FORMAT) if notification.updated_at else None
128+
),
114129
"notification_sent_at": notification.sent_at.strftime(DATETIME_FORMAT) if notification.sent_at else None,
115130
"notification_type": notification.notification_type,
116131
"service_callback_api_url": service_callback_api.url,

app/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,10 @@ class Development(Config):
495495

496496
CBC_PROXY_ENABLED = False
497497

498+
SSL_CLIENT_OVERRIDE_CERT = os.getenv("SSL_CLIENT_OVERRIDE_CERT")
499+
SSL_CLIENT_OVERRIDE_KEY = os.getenv("SSL_CLIENT_OVERRIDE_KEY")
500+
SSL_VERIFY_OVERRIDE = os.getenv("SSL_CERT_FILE")
501+
498502

499503
class Test(Development):
500504
NOTIFY_EMAIL_DOMAIN = "test.notify.com"

0 commit comments

Comments
 (0)