Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(console): Added component with mqtt command #502

Conversation

espressif-abhikroy
Copy link
Collaborator

@espressif-abhikroy espressif-abhikroy commented Jan 31, 2024

mqtt  [-CsD] [-h <host>] [-u <username>] [-P <password>] [--cert] [--key] [--cafile]
  mqtt command
  -C, --connect  Connect to a broker (flag, no argument)
  -h, --host=<host>  Specify the host uri to connect to
  -s, --status  Displays the status of the mqtt client (flag, no argument)
  -u, --username=<username>  Provide a username to be used for authenticating with the broker
  -P, --password=<password>  Provide a password to be used for authenticating with the broker
      --cert  Define the PEM encoded certificate for this client, if required by the broker (flag, no argument)
      --key  Define the PEM encoded private key for this client, if required by the broker (flag, no argument)
      --cafile  Define the PEM encoded CA certificates that are trusted (flag, no argument)
      --use-internal-bundle  Use the internal certificate bundle for TLS (flag, no argument)
  -D, --disconnect  Disconnect from the broker (flag, no argument)

mqtt_pub  [-t <topic>] [-m <message>]
  mqtt publish command
  -t, --topic=<topic>  Topic to Subscribe/Publish
  -m, --message=<message>  Message to Publish

mqtt_sub  [-U] [-t <topic>]
  mqtt subscribe command
  -t, --topic=<topic>  Topic to Subscribe/Publish
  -U, --unsubscribe  Unsubscribe from a topic

components/console_cmd_mqtt/console_mqtt.c Show resolved Hide resolved
components/console_cmd_mqtt/console_mqtt.c Outdated Show resolved Hide resolved
components/console_cmd_mqtt/console_mqtt.c Outdated Show resolved Hide resolved
components/console_cmd_mqtt/console_mqtt.c Outdated Show resolved Hide resolved
components/console_cmd_mqtt/README.md Show resolved Hide resolved
Copy link
Collaborator

@david-cermak david-cermak left a comment

Choose a reason for hiding this comment

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

Nice a simple implementation of the mqtt client's CLI, just left few nitpicks, LGTM otherwise

@gabsuren
Copy link
Contributor

Probably it's because of draft, just missing CI *yml files updates

extern const uint8_t g_client_cert_pem_end[] asm("_binary_client_crt_end");
extern const uint8_t g_client_key_pem_start[] asm("_binary_client_key_start");
extern const uint8_t g_client_key_pem_end[] asm("_binary_client_key_end");
extern const uint8_t g_server_cert_pem_start[] asm("_binary_mosquitto_org_crt_start");
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could switch to use certificate bundle here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added Certificate bundle option.
Now a broker verification can be performed with certificate bundle.
But I was not able to make ssl mutual authentication work with certificate bundle.
I have added a restriction for that.

components/console_cmd_mqtt/console_mqtt.h Outdated Show resolved Hide resolved
components/console_cmd_mqtt/console_mqtt.h Show resolved Hide resolved
@espressif-abhikroy espressif-abhikroy force-pushed the component/console_cmd_mqtt branch 2 times, most recently from fb2622b to 74ad20a Compare September 16, 2024 03:18
Copy link
Collaborator

@euripedesrocha euripedesrocha left a comment

Choose a reason for hiding this comment

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

One last comment, we have client cert and keys added as empty files. Is that correct?

@espressif-abhikroy
Copy link
Collaborator Author

espressif-abhikroy commented Sep 23, 2024

One last comment, we have client cert and keys added as empty files. Is that correct?

Yes, the client cert and keys are empty. I am only providing the mosquitto.org.crt same as idf example.

@espressif-abhikroy espressif-abhikroy force-pushed the component/console_cmd_mqtt branch 2 times, most recently from 6b67fde to dcc9e61 Compare September 23, 2024 10:15
@espressif-abhikroy espressif-abhikroy force-pushed the component/console_cmd_mqtt branch from dcc9e61 to bffb74b Compare October 9, 2024 10:00
@espressif-abhikroy espressif-abhikroy force-pushed the component/console_cmd_mqtt branch 5 times, most recently from c98d9bb to 232d21e Compare November 22, 2024 12:09
Note: Auto-registration of a specific plugin command can be disabled from menuconfig.

### Certificate Integration for Mutual Authentication
To enhance security and enable secure communication over MQTT, three functions have been added to the API, allowing users to set client certificates, client keys, and broker certificates separately.
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the idf examples, we have the mutual authentication example that explain how to generate certificates for testing. We could add similar explanation or a pointer here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have added the steps for certificate generation in the README file of the example.

components/console_cmd_mqtt/console_mqtt.c Outdated Show resolved Hide resolved
@espressif-abhikroy espressif-abhikroy force-pushed the component/console_cmd_mqtt branch from 7ec4f76 to 2be9f71 Compare November 22, 2024 13:08
@espressif-abhikroy espressif-abhikroy force-pushed the component/console_cmd_mqtt branch from 2be9f71 to 6894db6 Compare November 28, 2024 13:51
1.0.0
Features
- Added component with mqtt command (1fcc5b1)
@espressif-abhikroy espressif-abhikroy force-pushed the component/console_cmd_mqtt branch from 8ef6cbb to 2e9bb6e Compare November 29, 2024 10:49
@espressif-abhikroy espressif-abhikroy merged commit c5b49de into espressif:master Nov 29, 2024
54 checks passed
@espressif-abhikroy espressif-abhikroy deleted the component/console_cmd_mqtt branch November 29, 2024 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants