Skip to content

feat: add TLS support for MQTT datastore (#340)#441

Open
HrishikeshUchake wants to merge 1 commit intoteslamotors:mainfrom
HrishikeshUchake:main
Open

feat: add TLS support for MQTT datastore (#340)#441
HrishikeshUchake wants to merge 1 commit intoteslamotors:mainfrom
HrishikeshUchake:main

Conversation

@HrishikeshUchake
Copy link

  • Added TLS configuration to MQTT producer
  • Updated config loader to support MQTT TLS fields
  • Added unit tests for MQTT TLS configuration
  • Updated README and examples with MQTT TLS configuration example

Description

I have implemented the fix for issue [#340], which requested support and examples for connecting to an MQTT broker over SSL/TLS (e.g., port 8883).

Summary of Changes

  1. MQTT Datastore Enhancements
    TLS Configuration: Added a TLSConfig struct to the MQTT [Config] in [mqtt.go] to support enabled and ca (path to CA certificate) fields.
    TLS Implementation: Updated [NewProducer] in [mqtt.go] to initialize a [tls.Config] when enabled. It now correctly loads the CA certificate from the specified path and applies it to the Paho MQTT client options.
  2. Configuration & Validation
    Config Loading: Updated the configuration initialization tests in [config_initializer_test.go] and [test_configs_test.go] to ensure the new MQTT TLS fields are correctly parsed from JSON.
    Unit Testing: Added comprehensive tests in [mqtt_test.go] to verify that TLS is correctly configured when enabled and that CA certificates are properly loaded.
  3. Documentation & Examples
    Example Config: Updated [server_config.json] with a complete MQTT over SSL configuration example.
    README Update: Added the new MQTT TLS configuration parameters to the [README.md] documentation

Fixes #340

Type of change

Please select all options that apply to this change:

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Bug fix (non-breaking change which fixes an issue)
  • Documentation update

Checklist:

Confirm you have completed the following steps:

  • My code follows the style of this project.
  • I have performed a self-review of my code.
  • I have made corresponding updates to the documentation.
  • I have added/updated unit tests to cover my changes.
  • I have added/updated integration tests to cover my changes.

- Added TLS configuration to MQTT producer
- Updated config loader to support MQTT TLS fields
- Added unit tests for MQTT TLS configuration
- Updated README and examples with MQTT TLS configuration example
@HrishikeshUchake
Copy link
Author

Hi @patrickdemers6, @agbpatro, could you please review this? I'd love to hear your opinions and suggestions on this. Thank you so much!

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.

Example configuration for MQTT over SSL

1 participant