Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/configuration/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ def __parse_mqtt_transport(args: Namespace, config: Configuration) -> None:
config.mqtt_transport_protocol = TransportProtocol.TLS
if args.tls_server_cert_path:
config.tls_server_cert_path = args.tls_server_cert_path
else:
msg = f"No server certificate authority file provided for TLS MQTT URI {args.mqtt_uri}"
raise SystemExit(msg)
else:
msg = f"Invalid MQTT URI scheme: {parse_result.scheme}, use tcp or ws"
raise SystemExit(msg)
Expand Down
14 changes: 8 additions & 6 deletions src/publisher/mqtt_publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,16 @@ async def connect(self) -> None:
)
else:
self.client.set_auth_credentials(username=self.configuration.mqtt_user)

if self.transport_protocol.with_tls:
ssl_context = ssl.create_default_context()
cert_uri = self.configuration.tls_server_cert_path
LOG.debug(
f"Configuring network encryption and authentication options for MQTT using {cert_uri}"
)
ssl_context = ssl.SSLContext()
ssl_context.load_verify_locations(cafile=cert_uri)
ssl_context.check_hostname = False
if cert_uri:
LOG.debug(
f"Using custom CA file {cert_uri}"
)
ssl_context.load_verify_locations(cafile=cert_uri)
ssl_context.check_hostname = False
else:
ssl_context = None
await self.client.connect(
Expand Down