I have multiple IoT devices that will be connected to a cloud based platform in order to control these devices (IoT node running baremetal arm SoC).

I would like to know how to configure each IoT node to generate a self-signed certificate and how can this element improve the overall system security.

This certificate will only be used during IoT device deployment and will be used to avoid possible ManInTheMiddle attacks. Is it really useful for this specific case?