SlideShare ist ein Scribd-Unternehmen logo
1 von 33
Securing MQTT for IoT
Communication
SCALE x16
March 9, 2018
Anthony Chow
http://cloudn1n3.blogspot.com/
Twitter: @vCloudernBeer
Auth0 Ambassador
Intel Innovator
VMware vExpert 2015 - 2018
IoT Ecosystems
Image source: https://techcrunch.com/2013/05/25/making-sense-of-the-internet-of-things
IoT Gateway
Image source: https://medium.com/@darshipatel/internet-of-things-and-powerful-iot-gateways-a1673cba6cb9
MQTT in the OSI 7-layer
Image source: https://www.hivemq.com/blog/mqtt-essentials-part-3-client-
broker-connection-establishment
Image source: https://www.slideshare.net/aniruddha.chakrabarti/coap-web-
protocol-for-iot
What is MQTT?
Image source: https://www.hivemq.com/blog/how-to-get-started-with-mqtt
MQTT Terminologies
 Publish/Subscribe
 QoS
 Topics
 Persistent vs Clean Session
 LWT – Last Will and Testament
What is new in MQTT 5
 What happened to MQTT 4?
 https://www.hivemq.com/mqtt-5
Image source: https://www.hivemq.com/blog/mqtt-5-introduction-to-mqtt-5/
What’s new with MQTT 5?
What happen to MQTT 4?
https://www.hivemq.com/mqtt-5
MQTT Resources
 http://mqtt.org
 https://github.com/mqtt/mqtt.github.io/wiki
 https://
www.hivemq.com/blog/mqtt-essentials-wrap-up
 https://www.hivemq.com/blog/mqtt-security-fundamentals
/
 https://
auth0.com/docs/integrations/authenticating-devices-using-mqtt
MQTT Broker/Server - Mosquitto
 sudo apt-get install mosquitto
 sudo apt-get install mosquitto-client
 /etc/mosquitto/mosquitto.conf
Ways to secure MQTT
 Network: VPN
 Transport: SSL/TLS
 Application: client-id; Access Token;
Username/password
Securing MQTT broker –
Mosquitto on Ubuntu
 sudo apt-get install mosquotto
 sudo apt-get install mosquotto-client
 /etc/mosquotto
 Different option to secure Mosquotto broker:
 Password
 ACL
 SSL/TLS
 Third-party – OAuth2
SSL/TLS
 SSL – Secure Socket Layer (older standard)
o Version 2 and version 3
 TLS – Transport Layer Security (newer standard)
o Version 1.1, 1.2 and 1.3
 Asymmetric encryption
o Private Key and Public key
 Symmetric encryption
o Symmetric key
 Hashing
 Digital Certificate – e.g. X.509
SSL-Handshake
Image source: https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_7.1.0/com.ibm.mq.doc/sy10660a.gif
SSL – X.509 Digital Certificate
JWT- JSON Web Token
Image source: youtube.com
Resources for JSON Web Token
• https://auth0.com/learn/json-web-tokens/
• https://jwt.io/introduction/
• https://scotch.io/tutorials/the-anatomy-of-a-json-web-
token
• https://auth0.com/e-books/jwt-handbook
OAuth-2OAuth-2
 “Open Authentication” (?)
 Authorization delegation
 An authorization framework
 Defined by RFC 6749 and 6750
 OAuth 1 is defined by RFC 5849
 OAuth 1 and OAuth 2 are not compatible
OAuth2 ActorsOAuth2 Actors
Image source: https://www.linkedin.com/pulse/microservices-security-openid-connect-manish-singh/
OAuth2 Flows (grants)OAuth2 Flows (grants)
image source: https://www.slideshare.net/rcandidosilva/javaone-2014-securing-restful-resources-with-oauth2
OAuth2 Authorization Grants
 Different ways of getting a token
o Authorization code,
o Implicit grant,
o Resource owner password credentials and
o Client credentials
 Which OAuth 2.0 flow should I use?
OAuth2 Tokens
 Access Token
 Refresh Token
OAuth2 Tokens
• Access Token
• Refresh Token
OAuth2 simplified viewOAuth2 simplified view
Image source: https://www.hivemq.com/wp-content/uploads/oauth-simple.png
Resource for OAuth2Resource for OAuth2
• RFC 6749 - https://tools.ietf.org/html/rfc6749
• RFC 6750 - https://tools.ietf.org/html/rfc6750
• https://auth0.com/docs/protocols/oauth2
• https://developers.google.com/oauthplayground/
Authenticating & Authorizing Devices
using MQTT with Auth0
Username and PasswordUsername and Password
 mosquitto_passwd –U <password-file>
 mosquitto_passwd –c <password-file> <user>
{password}
 Edit /etc/mosquitto.conf:
 allow_anonymous false
 password_file /etc/mosquitto/<password-file>
ACL – Access Control ListACL – Access Control List
 /etc/mosquitto/mosquitto.conf
 /etc/mosquitto/conf.d/default.conf
 Add this line:
 acl_file /etc/mosquitto/<acl-file>
Sample ACL file forSample ACL file for
MosquittoMosquitto
Source: https://jaimyn.com.au/mqtt-use-acls-multiple-user-accounts/
# Give Home user1 full access to everything
user user1
topic readwrite #
# Allow the user2 to read/write to test/# and stat/#
user user2
topic readwrite test/#
topic readwrite stat/#
# Allows user3 to read/write to the sensor topics
user user3
topic cmnd/sensor/#
topic stat/sensor/#
SSL/TLSSSL/TLS
 openssl genrsa -out ca.key 2048
 openssl req -new -x509 -days365 -key ca.key -out ca.crt
 openssl genrsa -out serv.key 2048
 openssl req -new -key serv.key -out serv.csr
 openssl x509 -req -in serv.csr -CA mosq-ca.crt -CAkey ca.key -CAcreateserial
-out serv.crt -days 365 -sha256
 Add this line:
 Listener 8883
 cafile /home/mosquitto/ca.crt
 certfile /home/mosquitto/serv.crt
 keyfile /home/mosquitto/serv.key
33rdrd
Party – OAuth2/Auth0Party – OAuth2/Auth0
 https://auth0.com/docs/integrations/authenticating-devices-using-mqtt
 openssl genrsa -out serv.key 204
 openssl req -new -key serv.key -out serv.csr
 openssl x509 -req -in serv.csr -CA mosq-ca.crt -CAkey ca.key -CAcreateserial
-out serv.crt -days 365 -sha256
 Add this line:
 Listener 8883
 cafile /home/mosquitto/ca.crt
 certfile /home/mosquitto/serv.crt
 keyfile /home/mosquitto/serv.key
How can I start?

Let’s secure a MQTT server now.
Thanks for coming and enjoy the rest of
SCALE.
Have a nice day!

Weitere ähnliche Inhalte

Was ist angesagt?

Understanding the European Self-Sovereign Identity Framework (ESSIF)
Understanding the European Self-Sovereign Identity Framework (ESSIF)Understanding the European Self-Sovereign Identity Framework (ESSIF)
Understanding the European Self-Sovereign Identity Framework (ESSIF)
SSIMeetup
 
Deploying IP/MPLS VPN - Cisco Networkers 2010
Deploying IP/MPLS VPN - Cisco Networkers 2010Deploying IP/MPLS VPN - Cisco Networkers 2010
Deploying IP/MPLS VPN - Cisco Networkers 2010
Febrian ‎
 

Was ist angesagt? (20)

CCNA 2 Routing and Switching v5.0 Chapter 5
CCNA 2 Routing and Switching v5.0 Chapter 5CCNA 2 Routing and Switching v5.0 Chapter 5
CCNA 2 Routing and Switching v5.0 Chapter 5
 
Cisco Live Milan 2015 - BGP advance
Cisco Live Milan 2015 - BGP advanceCisco Live Milan 2015 - BGP advance
Cisco Live Milan 2015 - BGP advance
 
CCNA 2 Routing and Switching v5.0 Chapter 1
CCNA 2 Routing and Switching v5.0 Chapter 1CCNA 2 Routing and Switching v5.0 Chapter 1
CCNA 2 Routing and Switching v5.0 Chapter 1
 
OAuth 2.0 Security Reinforced
OAuth 2.0 Security ReinforcedOAuth 2.0 Security Reinforced
OAuth 2.0 Security Reinforced
 
MQTT - A practical protocol for the Internet of Things
MQTT - A practical protocol for the Internet of ThingsMQTT - A practical protocol for the Internet of Things
MQTT - A practical protocol for the Internet of Things
 
Mit 2014 introduction to open id connect and o-auth 2
Mit 2014   introduction to open id connect and o-auth 2Mit 2014   introduction to open id connect and o-auth 2
Mit 2014 introduction to open id connect and o-auth 2
 
CCNAv5 - S4: Chapter3 Point to-point Connections
CCNAv5 - S4: Chapter3 Point to-point ConnectionsCCNAv5 - S4: Chapter3 Point to-point Connections
CCNAv5 - S4: Chapter3 Point to-point Connections
 
Understanding the European Self-Sovereign Identity Framework (ESSIF)
Understanding the European Self-Sovereign Identity Framework (ESSIF)Understanding the European Self-Sovereign Identity Framework (ESSIF)
Understanding the European Self-Sovereign Identity Framework (ESSIF)
 
OAuth
OAuthOAuth
OAuth
 
Introduction to MQTT
Introduction to MQTTIntroduction to MQTT
Introduction to MQTT
 
OAuth2 - Introduction
OAuth2 - IntroductionOAuth2 - Introduction
OAuth2 - Introduction
 
OAuth 2.0
OAuth 2.0OAuth 2.0
OAuth 2.0
 
An Introduction to OAuth 2
An Introduction to OAuth 2An Introduction to OAuth 2
An Introduction to OAuth 2
 
Introduction MQTT in English
Introduction MQTT in EnglishIntroduction MQTT in English
Introduction MQTT in English
 
IBM APIc API security protection mechanism
IBM APIc API security protection mechanismIBM APIc API security protection mechanism
IBM APIc API security protection mechanism
 
OpenID for Verifiable Credentials
OpenID for Verifiable CredentialsOpenID for Verifiable Credentials
OpenID for Verifiable Credentials
 
Segment Routing Advanced Use Cases - Cisco Live 2016 USA
Segment Routing Advanced Use Cases - Cisco Live 2016 USASegment Routing Advanced Use Cases - Cisco Live 2016 USA
Segment Routing Advanced Use Cases - Cisco Live 2016 USA
 
Deploying IP/MPLS VPN - Cisco Networkers 2010
Deploying IP/MPLS VPN - Cisco Networkers 2010Deploying IP/MPLS VPN - Cisco Networkers 2010
Deploying IP/MPLS VPN - Cisco Networkers 2010
 
IoT Networking
IoT NetworkingIoT Networking
IoT Networking
 
Introduction To Webrtc
Introduction To WebrtcIntroduction To Webrtc
Introduction To Webrtc
 

Ähnlich wie MQTT security

OAuth based reference architecture for API Management
OAuth based reference architecture for API ManagementOAuth based reference architecture for API Management
OAuth based reference architecture for API Management
WSO2
 

Ähnlich wie MQTT security (20)

AllTheTalks.Online 2020: "Basics of OAuth 2.0 and OpenID Connect"
AllTheTalks.Online 2020: "Basics of OAuth 2.0 and OpenID Connect"AllTheTalks.Online 2020: "Basics of OAuth 2.0 and OpenID Connect"
AllTheTalks.Online 2020: "Basics of OAuth 2.0 and OpenID Connect"
 
Internet of Things - protocols review (MeetUp Wireless & Networks, Poznań 21....
Internet of Things - protocols review (MeetUp Wireless & Networks, Poznań 21....Internet of Things - protocols review (MeetUp Wireless & Networks, Poznań 21....
Internet of Things - protocols review (MeetUp Wireless & Networks, Poznań 21....
 
FIWARE Wednesday Webinars - How to Secure IoT Devices
FIWARE Wednesday Webinars - How to Secure IoT DevicesFIWARE Wednesday Webinars - How to Secure IoT Devices
FIWARE Wednesday Webinars - How to Secure IoT Devices
 
Authorization for Internet of Things using OAuth 2.0
Authorization for Internet of Things using OAuth 2.0Authorization for Internet of Things using OAuth 2.0
Authorization for Internet of Things using OAuth 2.0
 
IRJET- Proof of Document using Multichain and Ethereum
IRJET- Proof of Document using Multichain and EthereumIRJET- Proof of Document using Multichain and Ethereum
IRJET- Proof of Document using Multichain and Ethereum
 
Veer's Container Security
Veer's Container SecurityVeer's Container Security
Veer's Container Security
 
Some OAuth love
Some OAuth loveSome OAuth love
Some OAuth love
 
OAuth2 for IoT Security: Why OpenID Connect & UMA Are They Key
OAuth2 for IoT Security: Why OpenID Connect & UMA Are They KeyOAuth2 for IoT Security: Why OpenID Connect & UMA Are They Key
OAuth2 for IoT Security: Why OpenID Connect & UMA Are They Key
 
MQTT with Eclipse Paho: A protocol for IoT and M2M communication
MQTT with Eclipse Paho: A protocol for IoT and M2M communicationMQTT with Eclipse Paho: A protocol for IoT and M2M communication
MQTT with Eclipse Paho: A protocol for IoT and M2M communication
 
SFScon 2020 - Alex Lanz Martin Malfertheiner - OAuth2 OpenID
 SFScon 2020 - Alex Lanz Martin Malfertheiner - OAuth2 OpenID SFScon 2020 - Alex Lanz Martin Malfertheiner - OAuth2 OpenID
SFScon 2020 - Alex Lanz Martin Malfertheiner - OAuth2 OpenID
 
Hacking IoT with EXPLIoT Framework
Hacking IoT with EXPLIoT FrameworkHacking IoT with EXPLIoT Framework
Hacking IoT with EXPLIoT Framework
 
iMasters Intercon 2016 - Identity within Microservices
iMasters Intercon 2016 - Identity within MicroservicesiMasters Intercon 2016 - Identity within Microservices
iMasters Intercon 2016 - Identity within Microservices
 
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
 
OAuth based reference architecture for API Management
OAuth based reference architecture for API ManagementOAuth based reference architecture for API Management
OAuth based reference architecture for API Management
 
Securing the Internet of Things
Securing the Internet of ThingsSecuring the Internet of Things
Securing the Internet of Things
 
CCICI CIP 1.0 Testbed - Security access implementation and reference - v1.0
CCICI CIP 1.0 Testbed - Security access implementation and reference - v1.0CCICI CIP 1.0 Testbed - Security access implementation and reference - v1.0
CCICI CIP 1.0 Testbed - Security access implementation and reference - v1.0
 
Protocol
ProtocolProtocol
Protocol
 
[WSO2Con EU 2017] Building Smart, Connected Products with WSO2 IoT Platform
[WSO2Con EU 2017] Building Smart, Connected Products with WSO2 IoT Platform[WSO2Con EU 2017] Building Smart, Connected Products with WSO2 IoT Platform
[WSO2Con EU 2017] Building Smart, Connected Products with WSO2 IoT Platform
 
Authentication in microservice systems - fsto 2017
Authentication in microservice systems - fsto 2017Authentication in microservice systems - fsto 2017
Authentication in microservice systems - fsto 2017
 
[workshop] The Revolutionary WebRTC
[workshop] The Revolutionary WebRTC[workshop] The Revolutionary WebRTC
[workshop] The Revolutionary WebRTC
 

Mehr von Anthony Chow

Mehr von Anthony Chow (14)

Build your own Blockchain with the right tool for your application
Build your own Blockchain with the right tool for your applicationBuild your own Blockchain with the right tool for your application
Build your own Blockchain with the right tool for your application
 
Container security
Container securityContainer security
Container security
 
Understanding gRPC Authentication Methods
Understanding gRPC Authentication MethodsUnderstanding gRPC Authentication Methods
Understanding gRPC Authentication Methods
 
Api security with o auth2
Api security with o auth2Api security with o auth2
Api security with o auth2
 
Container security
Container securityContainer security
Container security
 
Container security
Container securityContainer security
Container security
 
V brownbag sept-14-2016
V brownbag sept-14-2016V brownbag sept-14-2016
V brownbag sept-14-2016
 
Understanding the container landscape and it associated projects
Understanding the container landscape and it associated projectsUnderstanding the container landscape and it associated projects
Understanding the container landscape and it associated projects
 
Getting over the barrier and start contributing to OpenStack
Getting over the barrier and start contributing to OpenStackGetting over the barrier and start contributing to OpenStack
Getting over the barrier and start contributing to OpenStack
 
Introduction to go
Introduction to goIntroduction to go
Introduction to go
 
Micro segmentation – a perfect fit for microservices
Micro segmentation – a perfect fit for microservicesMicro segmentation – a perfect fit for microservices
Micro segmentation – a perfect fit for microservices
 
An overview of OpenStack for the VMware community
An overview of OpenStack for the VMware communityAn overview of OpenStack for the VMware community
An overview of OpenStack for the VMware community
 
VXLAN in the contemporary data center
VXLAN in the contemporary data centerVXLAN in the contemporary data center
VXLAN in the contemporary data center
 
What a Beginner Should Know About OpenStack
What a Beginner Should Know About OpenStackWhat a Beginner Should Know About OpenStack
What a Beginner Should Know About OpenStack
 

Kürzlich hochgeladen

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

MQTT security

  • 1. Securing MQTT for IoT Communication SCALE x16 March 9, 2018 Anthony Chow http://cloudn1n3.blogspot.com/ Twitter: @vCloudernBeer Auth0 Ambassador Intel Innovator VMware vExpert 2015 - 2018
  • 2. IoT Ecosystems Image source: https://techcrunch.com/2013/05/25/making-sense-of-the-internet-of-things
  • 3. IoT Gateway Image source: https://medium.com/@darshipatel/internet-of-things-and-powerful-iot-gateways-a1673cba6cb9
  • 4. MQTT in the OSI 7-layer Image source: https://www.hivemq.com/blog/mqtt-essentials-part-3-client- broker-connection-establishment Image source: https://www.slideshare.net/aniruddha.chakrabarti/coap-web- protocol-for-iot
  • 5. What is MQTT? Image source: https://www.hivemq.com/blog/how-to-get-started-with-mqtt
  • 6. MQTT Terminologies  Publish/Subscribe  QoS  Topics  Persistent vs Clean Session  LWT – Last Will and Testament
  • 7. What is new in MQTT 5  What happened to MQTT 4?  https://www.hivemq.com/mqtt-5 Image source: https://www.hivemq.com/blog/mqtt-5-introduction-to-mqtt-5/
  • 8. What’s new with MQTT 5? What happen to MQTT 4? https://www.hivemq.com/mqtt-5
  • 9. MQTT Resources  http://mqtt.org  https://github.com/mqtt/mqtt.github.io/wiki  https:// www.hivemq.com/blog/mqtt-essentials-wrap-up  https://www.hivemq.com/blog/mqtt-security-fundamentals /  https:// auth0.com/docs/integrations/authenticating-devices-using-mqtt
  • 10. MQTT Broker/Server - Mosquitto  sudo apt-get install mosquitto  sudo apt-get install mosquitto-client  /etc/mosquitto/mosquitto.conf
  • 11. Ways to secure MQTT  Network: VPN  Transport: SSL/TLS  Application: client-id; Access Token; Username/password
  • 12. Securing MQTT broker – Mosquitto on Ubuntu  sudo apt-get install mosquotto  sudo apt-get install mosquotto-client  /etc/mosquotto  Different option to secure Mosquotto broker:  Password  ACL  SSL/TLS  Third-party – OAuth2
  • 13. SSL/TLS  SSL – Secure Socket Layer (older standard) o Version 2 and version 3  TLS – Transport Layer Security (newer standard) o Version 1.1, 1.2 and 1.3  Asymmetric encryption o Private Key and Public key  Symmetric encryption o Symmetric key  Hashing  Digital Certificate – e.g. X.509
  • 15. SSL – X.509 Digital Certificate
  • 16. JWT- JSON Web Token Image source: youtube.com
  • 17. Resources for JSON Web Token • https://auth0.com/learn/json-web-tokens/ • https://jwt.io/introduction/ • https://scotch.io/tutorials/the-anatomy-of-a-json-web- token • https://auth0.com/e-books/jwt-handbook
  • 18. OAuth-2OAuth-2  “Open Authentication” (?)  Authorization delegation  An authorization framework  Defined by RFC 6749 and 6750  OAuth 1 is defined by RFC 5849  OAuth 1 and OAuth 2 are not compatible
  • 19. OAuth2 ActorsOAuth2 Actors Image source: https://www.linkedin.com/pulse/microservices-security-openid-connect-manish-singh/
  • 20. OAuth2 Flows (grants)OAuth2 Flows (grants) image source: https://www.slideshare.net/rcandidosilva/javaone-2014-securing-restful-resources-with-oauth2
  • 21. OAuth2 Authorization Grants  Different ways of getting a token o Authorization code, o Implicit grant, o Resource owner password credentials and o Client credentials  Which OAuth 2.0 flow should I use?
  • 22. OAuth2 Tokens  Access Token  Refresh Token
  • 23. OAuth2 Tokens • Access Token • Refresh Token
  • 24. OAuth2 simplified viewOAuth2 simplified view Image source: https://www.hivemq.com/wp-content/uploads/oauth-simple.png
  • 25. Resource for OAuth2Resource for OAuth2 • RFC 6749 - https://tools.ietf.org/html/rfc6749 • RFC 6750 - https://tools.ietf.org/html/rfc6750 • https://auth0.com/docs/protocols/oauth2 • https://developers.google.com/oauthplayground/
  • 26. Authenticating & Authorizing Devices using MQTT with Auth0
  • 27. Username and PasswordUsername and Password  mosquitto_passwd –U <password-file>  mosquitto_passwd –c <password-file> <user> {password}  Edit /etc/mosquitto.conf:  allow_anonymous false  password_file /etc/mosquitto/<password-file>
  • 28. ACL – Access Control ListACL – Access Control List  /etc/mosquitto/mosquitto.conf  /etc/mosquitto/conf.d/default.conf  Add this line:  acl_file /etc/mosquitto/<acl-file>
  • 29. Sample ACL file forSample ACL file for MosquittoMosquitto Source: https://jaimyn.com.au/mqtt-use-acls-multiple-user-accounts/ # Give Home user1 full access to everything user user1 topic readwrite # # Allow the user2 to read/write to test/# and stat/# user user2 topic readwrite test/# topic readwrite stat/# # Allows user3 to read/write to the sensor topics user user3 topic cmnd/sensor/# topic stat/sensor/#
  • 30. SSL/TLSSSL/TLS  openssl genrsa -out ca.key 2048  openssl req -new -x509 -days365 -key ca.key -out ca.crt  openssl genrsa -out serv.key 2048  openssl req -new -key serv.key -out serv.csr  openssl x509 -req -in serv.csr -CA mosq-ca.crt -CAkey ca.key -CAcreateserial -out serv.crt -days 365 -sha256  Add this line:  Listener 8883  cafile /home/mosquitto/ca.crt  certfile /home/mosquitto/serv.crt  keyfile /home/mosquitto/serv.key
  • 31. 33rdrd Party – OAuth2/Auth0Party – OAuth2/Auth0  https://auth0.com/docs/integrations/authenticating-devices-using-mqtt  openssl genrsa -out serv.key 204  openssl req -new -key serv.key -out serv.csr  openssl x509 -req -in serv.csr -CA mosq-ca.crt -CAkey ca.key -CAcreateserial -out serv.crt -days 365 -sha256  Add this line:  Listener 8883  cafile /home/mosquitto/ca.crt  certfile /home/mosquitto/serv.crt  keyfile /home/mosquitto/serv.key
  • 32. How can I start?  Let’s secure a MQTT server now.
  • 33. Thanks for coming and enjoy the rest of SCALE. Have a nice day!