Skip to content

Simple python code that simulates an IoT device capable of connecting using x509 (SSL/TLS) or SAS Authentication (Connection String)

Notifications You must be signed in to change notification settings

pradorodriguez/azureiotpyauth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Welcome to this Github Repo azureiotpyauth

In this repo you will find a Simple Python code that simulates an IoT Temperature device capable of connecting to Azure Iothub using x509 (SSL/TLS certificates) or SAS (device Connection String) authentication method. The idea is to be able to easily and quickly test multiple authentication options in your IoT application with Azure Iothub

Along with the python code, in this repo you will find the links to deploy the Azure Components needed successfully execute the application. At this point, this is no a step by step guide, the main point is for you to understand the Python code used to develop the solution

Guide information

Local Environment requirements

Azure requirements

Environment set up - You might use the following links in case you want to recreate the solution

Application Code

Python Libraries

Application Notes

  • If you want to test x509 authentication, make sure you follow the steps mentioned in the "If you chose x509 as your authentication method, follow this link to create required certificates" link. At the end you will need to create the following SSL/TLS objects:
    • Self Signed Certificate Authority files
      • Certificate
      • Private Key
      • Configuration File
      • Certificate Sign Request
    • Intermediate Certificate Authority files (this is OPTIONAL)
      • Certificate
      • Private Key
      • Configuration File
      • Certificate Sign Request
    • IoT Device Certificates
      • Certificate
      • Private Key
      • Certificate Sign Request

Application main functions and methods

  • Functions

    • Uncomment your preferred Authentication Method. Only one option must be uncommented
      • x509 Authentication
        • Save the device .CRT and .KEY files in the same folder as the "app-temperature.py" code
      • SaS Authentication
        • Get the connection string from the "SAS - Follow the Register a new device instructions" link.
    • Establish connectivity to Iothub
    • Create a random integer for the temperature
    • Create a dictionaru with the temperature value
    • Create a JSON object from the dictionary
    • Create a formatted message
    • Send messsage to Iothub
    • Repeat the code Infinitely
  • Execute the code in a bash CLI

    • python3 app-temperature.py

If you have any question, suggestion or comment about this repo or code, feel free to post it in this [discussion] (#1) section. I will make sure to address all your concerns

About

Simple python code that simulates an IoT device capable of connecting using x509 (SSL/TLS) or SAS Authentication (Connection String)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages