From 97cd3c980776d807b1fd0d6c8565cf2109ef7894 Mon Sep 17 00:00:00 2001 From: Nicholas Hairs Date: Fri, 18 Oct 2024 13:20:45 +1100 Subject: [PATCH] [sink.kafka] Make config more consistent with others. (#44) Our newer sinks are using `ssl: bool` and `verify_ssl: bool`, use it here. --- docs/migrating.md | 2 +- src/parsedmarc/sink/kafka.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/migrating.md b/docs/migrating.md index 1a7a751..bff88fe 100644 --- a/docs/migrating.md +++ b/docs/migrating.md @@ -215,7 +215,7 @@ Use a `.kafka:Kafka` Sink. - `user`: moved to `client.username`. - `password`: moved to `client.password`. - `ssl`: moved to `client.ssl`. -- `skip_certificate_verification`: moved to `client.skip_certificate_verification`. +- `skip_certificate_verification`: moved to `client.verify_ssl`. - `aggregate_topic`: moved to `aggregate_report_topic`. - `forensic_topic`: moved to `forensic_report_topic`. diff --git a/src/parsedmarc/sink/kafka.py b/src/parsedmarc/sink/kafka.py index 1f01b9d..accfaf1 100644 --- a/src/parsedmarc/sink/kafka.py +++ b/src/parsedmarc/sink/kafka.py @@ -33,12 +33,13 @@ def setup(self) -> None: self._state = AppState.SETTING_UP try: - if self.config.client.skip_certificate_verification: + if self.config.client.verify_ssl: + # Use default context + ssl_context = None + else: ssl_context = ssl.create_default_context() ssl_context.check_hostname = False ssl_context.verify_mode = ssl.CERT_NONE - else: - ssl_context = None self.client = kafkaclient.KafkaClient( kafka_hosts=self.config.client.hosts, @@ -77,6 +78,6 @@ class KafkaConfig(BaseConfig): class KafkaClient(BaseModel): hosts: List[str] ssl: bool = True - skip_certificate_verification: bool = False + verify_ssl: bool = True username: str | None = None password: str | None = None