Skip to content

Commit 45d45d1

Browse files
committed
use create_default_context() to create context with sane defaults
1 parent 47feb82 commit 45d45d1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/publisher/mqtt_publisher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ async def connect(self) -> None:
5252
self.client.set_auth_credentials(username=self.configuration.mqtt_user)
5353

5454
if self.transport_protocol.with_tls:
55+
ssl_context = ssl.create_default_context()
5556
cert_uri = self.configuration.tls_server_cert_path
5657
LOG.debug(
5758
f"Configuring network encryption and authentication options for MQTT using {cert_uri}"
5859
)
59-
ssl_context = ssl.SSLContext()
6060
if cert_uri:
6161
ssl_context.load_verify_locations(cafile=cert_uri)
6262
ssl_context.check_hostname = False
6363
else:
6464
LOG.debug(f"Custom certificate chain not provided, using default")
65-
ssl_context = True # Use default SSL context if no cert is provided
65+
6666
else:
6767
ssl_context = None
6868
await self.client.connect(

0 commit comments

Comments
 (0)