Mode sécurisé

Le mode sécurisé active TLS/SSL pour la communication chiffrée entre le Manta Manager, le broker Mosquitto et les nodes. Suivez ces étapes :

  1. Déployez le Manta Manager en mode sécurisé en utilisant l’option --secured :

In secured mode, Mosquitto is executed after the manta_manager. The manta_manager must be executed on a server machine.

$ manta_manager -vv --debug --secured
[09/13/24 15:45:25] INFO     2024-09-13 15:45:25,386 - manta_manager.certification_servicer - INFO - Token: 99e48b0cc48af374a5dc03a07e2b34f7 (certification_servicer.py:235)                                                                                   certification_servicer.py:235
                    INFO     2024-09-13 15:45:25,420 - manta_manager.certification_servicer - INFO - Deploy MQTT broker with: mosquitto -c .manta/certs/mosquitto.conf (certification_servicer.py:258)                                                         certification_servicer.py:258
                    INFO     2024-09-13 15:45:25,422 - manta_manager.manager - INFO - Certificates folder: .manta/certs (manager.py:195)                                                                                                                                      manager.py:195
                    INFO     2024-09-13 15:45:25,427 - manta_manager.database - INFO - Connected to MongoDB at localhost:27017 (database.py:710)                                                                                                                             database.py:710
                    INFO     2024-09-13 15:45:25,429 - manta_manager.mqtt_client - INFO - Loading SSL certificates from .manta/certs (mqtt_client.py:41)                                                                                                                   mqtt_client.py:41
                    INFO     2024-09-13 15:45:25,441 - manta_manager.manager - INFO - CertificationServicer server started on localhost:50050 (manager.py:238)                                                                                                                manager.py:238

Note

For more information on available flags, refer to the Manager CLI documentation.

  1. Déployez le broker Mosquitto avec TLS/SSL en utilisant le fichier de configuration généré.

Mosquitto must be executed with the configuration file generated by manta_manager, located at .manta/certs/mosquitto.conf.

$ mosquitto -c .manta/certs/mosquitto.conf
[22504.033687]~DLT~75210~INFO     ~FIFO /tmp/dlt cannot be opened. Retrying later...
1726235128: mosquitto version 1.6.9 starting
1726235128: Config loaded from .manta/certs/mosquitto.conf.
1726235128: Opening ipv4 listen socket on port 1883.
1726235130: New connection from 127.0.0.1 on port 1883.

Le Manta Manager devrait se connecter automatiquement au broker une fois que ce dernier a démarré.

[09/13/24 15:45:30] INFO     2024-09-13 15:45:30,447 - manta_manager.mqtt_client - INFO - Connected to MQTT broker: localhost:1883 (mqtt_client.py:149)                                                                                                                   mqtt_client.py:149
  1. Conservez le jeton unique

$ cat TOKEN
2d8c3fbce5c295eef2d9f98e9f623235

Avertissement

En mode sécurisé, le Manta Manager génère un jeton unique. Ce jeton doit être fourni aux Manta Nodes lors de leur initialisation pour établir une connexion sécurisée en TLS/SSL. Le jeton est utilisé pour échanger les certificats et lancer le processus de signature de certification afin de générer une clé privée pour chaque node.

  1. Une fois Docker configuré sur vos nodes, vous pouvez utiliser ce TOKEN pour connecter vos nodes au manager :

manta_node doit être exécuté dans des appareils embarqués.

$ manta_node -vv --debug--secured_token=2d8c3fbce5c295eef2d9f98e9f623235
[09/13/24 15:47:02] INFO     2024-09-13 15:47:02,273 - manta_node.task_runner - INFO - Connected to docker daemon ! (task_runner.py:29)                                                                                                                                    task_runner.py:29
                    INFO     2024-09-13 15:47:02,308 - manta_node.certification_builder - INFO - Private key generated and saved to .manta/32dcfe19fe164e75bd5068a5d65b74a7/certs/node.key (certification_builder.py:66)                                         certification_builder.py:66
                    INFO     2024-09-13 15:47:02,317 - manta_node.certification_builder - INFO - CA certificate saved to .manta/32dcfe19fe164e75bd5068a5d65b74a7/certs/ca.crt (certification_builder.py:83)                                                      certification_builder.py:83
                    INFO     2024-09-13 15:47:02,319 - manta_node.certification_builder - INFO - CSR generated (certification_builder.py:107)                                                                                                                   certification_builder.py:107
                    INFO     2024-09-13 15:47:02,327 - manta_node.certification_builder - INFO - Signed certificate received and saved to .manta/32dcfe19fe164e75bd5068a5d65b74a7/certs/node.crt (certification_builder.py:126)                                 certification_builder.py:126

Note

Par exemple, le node_id est généré à partir de l’adresse MAC de votre machine. Cependant la valeur de l’adresse MAC n’est pas stockée dans le serveur. Si vous voulez un alias, vous pouvez passer le flag --alias <your_alias>. Si vous voulez un ID aléatoire, vous pouvez passer le flag --random_id.

Note

Voir Node CLI pour plus d’informations sur les flags