Git Product home page Git Product logo

iot-x509-certificates's Introduction

x509 certificates in IoT - a deep dive

Video

You can find my video covering the steps described below on my YT channel:

https://youtu.be/aqzpRyy5E-I

Overview

This is a deep dive into x509 certificates and how they are used in IoT.

We are going to build a complete IoT system:

  • two IoT Devices
  • MQTT Broker
  • Private CA

and establish trust between devices:

We will configure the Private CA from scratch and use it to sign x509 certificates for our devices.

Device certificates are used to:

  • confirm device identity (this device is the actual devices it claims to be, not some rogue device that tries to access our system)
  • enable TLS encryption for communication between devices (so messages can not be read or modified by a potential attacker)

About tools

I am using Docker and Docker-Compose to create the environment used in this deep dive but docker knowledge is not needed to follow me.

If you want to replicate this setup on your system you need to install those tools. The installation is easy for all systems (Windows, Mac, Linux) and is described in the official documentation:

https://docs.docker.com/get-docker/

https://docs.docker.com/compose/install/

Let's start

Once you clone or download this repository you need to execute the following command:

docker-compose up --build

It will create four containers:

  • my_private_ca
  • mq_broker
  • client_a
  • client_b

These containers are emulating real devices in our system.

Once we have containers running our setup will proceed as follows:

  1. attach to the my_private_ca container
    1. generate the Private Key
    2. generate the self-signed CA Certificate
  2. attach to the mq_broker container
    1. generate the Private Key
    2. generate the CSR (Certificate Sign Request)
  3. attach to the my_private_ca container
    1. sign the CSR from MQTT Broker to create the MQTT Broker certificate
  4. attach to the mq_broker container
    1. move the certificate to the proper directory
  5. attach to the client_a container
    1. generate the Private Key
    2. generate the CSR
  6. attach to the client_b container
    1. check if the Private Key and CSR were created for you (I used a bit of Docker magic here, check the Dockerfile-client_b for details)
  7. attach to the my_private_ca container
    1. sign CSR from Client A to create the certificate for that device
    2. sign CSR from Client B to create the certificate for that device
  8. attach to the mq_broker container
    1. start the MQTT sever and leave it running
  9. attach to the client_a container
    1. subscribe to the test topic at MQTT Broker
  10. attach to the client_b container
    1. publish the MQTT message to the test topic at MQTT Broker

Note

The above process looks complex and needs many manual (error-prone) actions. In the real-world solution all of those tasks should be automated.

I decided to use the manual approach in order to guide you through the end-to-end process of system configuration. I hope that it was useful.

Let me know in case of any questions or comments!

https://www.facebook.com/lmtx.iot.7 https://twitter.com/lmtx1 https://t.me/lmtxdev

iot-x509-certificates's People

Contributors

lmtx avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.