Skip to content

Add MQTT TLS and custom MQTT port support#11

Open
JeffWDH wants to merge 2 commits intoljmerza:masterfrom
JeffWDH:master
Open

Add MQTT TLS and custom MQTT port support#11
JeffWDH wants to merge 2 commits intoljmerza:masterfrom
JeffWDH:master

Conversation

@JeffWDH
Copy link

@JeffWDH JeffWDH commented Jun 17, 2024

Added MQTT TLS and custom mqtt port support.

@JeffWDH JeffWDH changed the title Add MQTT TLS and custom mqtt port support Add MQTT TLS and custom MQTT port support Jun 17, 2024
@ljmerza ljmerza requested a review from Copilot October 1, 2025 00:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds MQTT TLS support and custom port configuration to the MQTT client connection. The changes enable secure MQTT connections with certificate validation and allow users to specify non-default MQTT ports.

  • Added TLS certificate chain support for secure MQTT connections
  • Added configurable MQTT port setting (defaulting to 1883)
  • Updated configuration documentation with TLS setup instructions

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
index.py Added SSL import, TLS configuration logic, and port parameter to MQTT connection
README.md Updated configuration documentation with new MQTT TLS and port settings

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +355 to +356
if config['frigate']['mqtt_tls']:
client.tls_set(config['frigate']['mqtt_tls_cert_chain'], tls_version=ssl.PROTOCOL_TLSv1_2)
Copy link

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TLS configuration should include proper error handling and validation. Consider adding certificate verification and handling cases where the certificate file doesn't exist or is invalid.

Copilot uses AI. Check for mistakes.

client.connect(config['frigate']['mqtt_server'])
if config['frigate']['mqtt_tls']:
client.tls_set(config['frigate']['mqtt_tls_cert_chain'], tls_version=ssl.PROTOCOL_TLSv1_2)
Copy link

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ssl.PROTOCOL_TLSv1_2 is deprecated. Use ssl.PROTOCOL_TLS_CLIENT instead for better security and forward compatibility.

Suggested change
client.tls_set(config['frigate']['mqtt_tls_cert_chain'], tls_version=ssl.PROTOCOL_TLSv1_2)
client.tls_set(config['frigate']['mqtt_tls_cert_chain'], tls_version=ssl.PROTOCOL_TLS_CLIENT)

Copilot uses AI. Check for mistakes.
Comment on lines +355 to +358
if config['frigate']['mqtt_tls']:
client.tls_set(config['frigate']['mqtt_tls_cert_chain'], tls_version=ssl.PROTOCOL_TLSv1_2)

client.connect(config['frigate']['mqtt_server'], config['frigate']['mqtt_port'])
Copy link

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing error handling for configuration keys. The code will fail if 'mqtt_tls', 'mqtt_tls_cert_chain', or 'mqtt_port' keys are missing from the config. Add proper validation or default values.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants