Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
stripe: Verify Stripe's TLS certificate using certifi's CA bundle.
Sahil Batra2ae00f823d2c
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.pyindex 49408e13ee4..1aa0140d1d7 100644--- a/corporate/lib/stripe.py+++ b/corporate/lib/stripe.py@@ -12,6 +12,7 @@ from functools import wrapsfrom typing import Any, Literal, TypedDict, TypeVarfrom urllib.parse import urlencode, urljoin+import certifiimport stripefrom django import formsfrom django.conf import settings@@ -74,6 +75,9 @@ from zilencer.models import (from zproject.config import get_secretstripe.api_key = get_secret("stripe_secret_key")+# Stripe's bundled CA file lags behind root store changes, such as+# removals of compromised CAs; certifi is updated more promptly.+stripe.ca_bundle_path = certifi.where()BILLING_LOG_PATH = os.path.join("/var/log/zulip" if not settings.DEVELOPMENT else settings.DEVELOPMENT_LOG_DIRECTORY,diff --git a/corporate/tests/test_billing_lib.py b/corporate/tests/test_billing_lib.pyindex 8415b5aac36..61154a5cb05 100644--- a/corporate/tests/test_billing_lib.py+++ b/corporate/tests/test_billing_lib.py@@ -8,6 +8,7 @@ from typing import castfrom unittest import mockfrom unittest.mock import Mock, patch+import certifiimport stripeimport time_machinefrom django.conf import settings@@ -78,6 +79,9 @@ from zilencer.models import (class BillingHelpersTest(ZulipTestCase):+ def test_stripe_ca_bundle_path(self) -> None:+ self.assertEqual(stripe.ca_bundle_path, certifi.where())+def test_next_month(self) -> None:anchor = datetime(2019, 12, 31, 1, 2, 3, tzinfo=timezone.utc)period_boundaries = [diff --git a/pyproject.toml b/pyproject.tomlindex 360fec0af47..4c0a3cc7ac1 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -121,6 +121,9 @@ prod = [# Needed for processing payments (in corporate)"stripe",+ # CA certificates for verifying Stripe's API (in corporate)+ "certifi",+# For checking whether email of the user is from a disposable email provider."disposable-email-domains",diff --git a/uv.lock b/uv.lockindex 13a40c739db..eeb01bd96cb 100644--- a/uv.lock+++ b/uv.lock@@ -7116,6 +7116,7 @@ dev = [{ name = "black" },{ name = "boto3" },{ name = "boto3-stubs", extra = ["s3", "ses", "sns", "sqs"] },+ { name = "certifi" },{ name = "chardet" },{ name = "codespell" },{ name = "coverage" },@@ -7269,6 +7270,7 @@ prod = [{ name = "backports-datetime-fromisoformat", marker = "python_full_version < '3.11'" },{ name = "beautifulsoup4" },{ name = "boto3" },+ { name = "certifi" },{ name = "chardet" },{ name = "cryptography" },{ name = "css-inline" },@@ -7372,6 +7374,7 @@ dev = [{ name = "black" },{ name = "boto3" },{ name = "boto3-stubs", extras = ["s3", "ses", "sns", "sqs"] },+ { name = "certifi" },{ name = "chardet" },{ name = "codespell" },{ name = "coverage" },@@ -7526,6 +7529,7 @@ prod = [{ name = "backports-datetime-fromisoformat", marker = "python_full_version < '3.11'" },{ name = "beautifulsoup4" },{ name = "boto3" },+ { name = "certifi" },{ name = "chardet" },{ name = "cryptography" },{ name = "css-inline" },