Share via

How is security managed in Azure IoT Hub? — SAS tokens & X.509 authentication used

Dhruvesh Sheladiya 0 Reputation points Microsoft Employee
2026-05-14T18:24:00.4566667+00:00

Description

I am trying to understand how Azure IoT Hub manages security for device connectivity and communication, specifically how authentication mechanisms like SAS tokens and X.509 certificates are used to secure device-to-cloud interactions.


Environment Details

Azure Service: Azure IoT Hub

Device Communication: Device-to-cloud and cloud-to-device

Authentication Methods: SAS tokens, X.509 certificates

Security Layer: TLS-based secure communication

Device Identity: Managed via IoT Hub identity registry


Investigation Details / Observations

IoT Hub requires all device communication to be secured via TLS (Transport Layer Security). [azure.github.io]

Devices must authenticate using credentials stored in the IoT Hub identity registry. [docs.azure.cn]

Authentication happens before authorization (permissions validation). [learn.microsoft.com]

IoT Hub supports two primary authentication mechanisms:

SAS (Shared Access Signature) tokens

  **X.509 certificate-based authentication** [[docs.azure.cn]](https://docs.azure.cn/en-us/iot-hub/iot-concepts-and-iot-hub)
  

Security Mechanisms Observed

SAS Token Authentication

Uses symmetric keys stored per device in identity registry

  Generates time-limited tokens for each request [[learn.microsoft.com]](https://learn.microsoft.com/en-us/azure/iot-hub/authenticate-authorize-sas)
  
     Tokens are signed and validated without exposing keys over the network [[learn.microsoft.com]](https://learn.microsoft.com/en-us/azure/iot-hub/authenticate-authorize-sas)
     
     **X.509 Certificate Authentication**
     
        Uses PKI (public/private key pair) for device identity
        
           Authentication happens during TLS handshake using certificates [[learn.microsoft.com]](https://learn.microsoft.com/en-us/azure/iot-hub/authenticate-authorize-x509)
           
              Supports CA-based trust model for scaling across many devices [[oneuptime.com]](https://oneuptime.com/blog/post/2026-02-16-how-to-set-up-x509-certificate-authentication-for-devices-in-azure-iot-hub/view)
              
              **Transport Security (TLS)**
              
                 All protocols (MQTT, AMQP, HTTPS) require encrypted communication
                 
                    Supports mutual TLS where both client and IoT Hub validate each other [[docs.azure.cn]](https://docs.azure.cn/en-us/iot-hub/iot-hub-tls-support)
                    

Steps Followed / Troubleshooting Done

Reviewed IoT Hub authentication and authorization model

explored SAS token generation and validation behavior

analyzed X.509 certificate-based authentication flow

verified TLS enforcement for all device connections

observed how device identity ties to authentication method


Mitigation / Considerations Explored

Considered SAS tokens for simple device scenarios

Evaluated X.509 certificates for stronger security and scalability

Checked how TLS protects data in transit

Reviewed token expiration and rotation strategies for SAS


Challenges / Confusions

When to prefer SAS tokens vs X.509 certificates

How IoT Hub internally validates SAS tokens per request

Certificate management complexity at scale (CA, rotation, revocation)

Impact of authentication choice on security posture and operations


Ask / Clarification Needed

What is the recommended authentication mechanism for large-scale production systems?

  • How does IoT Hub handle key rotation and certificate revocation?

What are best practices for securing device credentials in edge environments?

Description

I am trying to understand how Azure IoT Hub manages security for device connectivity and communication, specifically how authentication mechanisms like SAS tokens and X.509 certificates are used to secure device-to-cloud interactions.

Environment Details

Azure Service: Azure IoT Hub

  Device Communication: Device-to-cloud and cloud-to-device
  
     Authentication Methods: SAS tokens, X.509 certificates
     
        Security Layer: TLS-based secure communication
        
           Device Identity: Managed via IoT Hub identity registry
           
           ### **Investigation Details / Observations**

              IoT Hub requires all device communication to be secured via **TLS (Transport Layer Security)**. [[azure.github.io]](https://azure.github.io/IoTTrainingPack/modules/Certificates101/04_azureiot.html)
              
                 Devices must authenticate using credentials stored in the **IoT Hub identity registry**. [[docs.azure.cn]](https://docs.azure.cn/en-us/iot-hub/iot-concepts-and-iot-hub)
                 
                    Authentication happens before authorization (permissions validation). [[learn.microsoft.com]](https://learn.microsoft.com/en-us/azure/iot-hub/authenticate-authorize-x509)
                    
                       IoT Hub supports two primary authentication mechanisms:
                       
                             **SAS (Shared Access Signature) tokens**
                             
                                   **X.509 certificate-based authentication** [[docs.azure.cn]](https://docs.azure.cn/en-us/iot-hub/iot-concepts-and-iot-hub)
                                   
                                   ### **Security Mechanisms Observed**

                                      **SAS Token Authentication**
                                      
                                            Uses symmetric keys stored per device in identity registry
                                            
                                                  Generates time-limited tokens for each request [[learn.microsoft.com]](https://learn.microsoft.com/en-us/azure/iot-hub/authenticate-authorize-sas)
                                                  
                                                        Tokens are signed and validated without exposing keys over the network [[learn.microsoft.com]](https://learn.microsoft.com/en-us/azure/iot-hub/authenticate-authorize-sas)
                                                        
                                                           **X.509 Certificate Authentication**
                                                           
                                                                 Uses PKI (public/private key pair) for device identity
                                                                 
                                                                       Authentication happens during TLS handshake using certificates [[learn.microsoft.com]](https://learn.microsoft.com/en-us/azure/iot-hub/authenticate-authorize-x509)
                                                                       
                                                                             Supports CA-based trust model for scaling across many devices [[oneuptime.com]](https://oneuptime.com/blog/post/2026-02-16-how-to-set-up-x509-certificate-authentication-for-devices-in-azure-iot-hub/view)
                                                                             
                                                                                **Transport Security (TLS)**
                                                                                
                                                                                      All protocols (MQTT, AMQP, HTTPS) require encrypted communication
                                                                                      
                                                                                            Supports mutual TLS where both client and IoT Hub validate each other [[docs.azure.cn]](https://docs.azure.cn/en-us/iot-hub/iot-hub-tls-support)
                                                                                            
                                                                                            ### **Steps Followed / Troubleshooting Done**

                                                                                               Reviewed IoT Hub authentication and authorization model
                                                                                               
                                                                                                  explored SAS token generation and validation behavior
                                                                                                  
                                                                                                     analyzed X.509 certificate-based authentication flow
                                                                                                     
                                                                                                        verified TLS enforcement for all device connections
                                                                                                        
                                                                                                           observed how device identity ties to authentication method
                                                                                                           
                                                                                                           ### **Mitigation / Considerations Explored**

                                                                                                              Considered SAS tokens for simple device scenarios
                                                                                                              
                                                                                                                 Evaluated X.509 certificates for stronger security and scalability
                                                                                                                 
                                                                                                                    Checked how TLS protects data in transit
                                                                                                                    
                                                                                                                       Reviewed token expiration and rotation strategies for SAS
                                                                                                                       
                                                                                                                       ### **Challenges / Confusions**

                                                                                                                          When to prefer SAS tokens vs X.509 certificates
                                                                                                                          
                                                                                                                             How IoT Hub internally validates SAS tokens per request
                                                                                                                             
                                                                                                                                Certificate management complexity at scale (CA, rotation, revocation)
                                                                                                                                
                                                                                                                                   Impact of authentication choice on security posture and operations
                                                                                                                                   
                                                                                                                                   ### **Ask / Clarification Needed**

                                                                                                                                      What is the recommended authentication mechanism for large-scale production systems?
                                                                                                                                      
                                                                                                                                         How does IoT Hub handle key rotation and certificate revocation?
                                                                                                                                         
                                                                                                                                            What are best practices for securing device credentials in edge environments?
                                                                                                                                            
Azure IoT Hub
Azure IoT Hub

An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.


1 answer

Sort by: Most helpful
  1. AI answer

    2026-05-14T18:24:44.15+00:00

    Azure IoT Hub secures device connectivity with a combination of strong device identity, TLS for transport security, and per-device authentication using either SAS tokens or X.509 certificates. Authorization is then enforced based on the authenticated device identity.

    How IoT Hub authenticates devices

    1. Identity registry
      Every device or module must have an entry in the IoT Hub identity registry before it can connect. The registry stores the device ID and its credentials. Authentication uses those stored credentials to validate the device or module when it connects. IoT Hub supports two authentication methods for devices and modules:
      • SAS token–based authentication (symmetric keys)
      • X.509 certificate–based authentication
      What is Azure IoT Hub?
    2. SAS token authentication (symmetric keys)
      • Each device has symmetric keys stored in the identity registry.
      • The device uses these keys to generate Shared Access Signature (SAS) tokens that are sent as part of the connection (for example, as the MQTT password).
      • SAS tokens are time-limited and signed with the symmetric key, so the key itself is never sent over the network.
      • IoT Hub validates the signature and expiry on each request that uses a SAS token.
      SAS is simple to implement and suitable for devices that can securely store a symmetric key.
    3. X.509 certificate authentication
      X.509 authentication is more secure and scalable and is recommended for higher security requirements:
      • Devices authenticate during the TLS handshake using an X.509 certificate instead of a SAS token.
      • IoT Hub supports two X.509 modes:
        • X.509 CA-signed (recommended for production):
          • A root or intermediate CA certificate is uploaded and verified in IoT Hub.
          • Devices hold leaf certificates whose chain of trust leads to that CA.
          • When a device connects, it presents its full certificate chain. IoT Hub validates the chain against the registered CA.
          • Multiple devices can authenticate via the same verified CA, which scales well for large fleets.
        • X.509 self-signed:
          • For each device, a certificate thumbprint (hash) is stored in the identity registry.
          • When the device connects, IoT Hub validates the presented certificate against the stored thumbprint.
      The device (leaf) certificate must have its CN set to the device ID (CN=deviceId). For modules, the CN must be CN=deviceId/moduleId. Authenticate identities with third-party X.509 certificates
    4. Enforcing X.509-only authentication
      For extra security, IoT Hub can be configured to disable SAS authentication for devices and modules, leaving X.509 as the only accepted method:
         az resource update -n <iothubName> -g <resourceGroupName> \
           --resource-type Microsoft.Devices/IotHubs \
           --set properties.disableDeviceSAS=true properties.disableModuleSAS=true
      
      Authenticate identities with third-party X.509 certificates
    5. TLS and protocol-level security
      • All supported device protocols (MQTT, AMQP, HTTPS) use TLS to secure data in transit.
      • Devices connecting directly with MQTT (without SDKs) must use TLS on port 8883 and include the device ID and IoT Hub hostname in the MQTT CONNECT packet.
      • When using X.509, the certificate is presented during the TLS handshake; SAS tokens are not required in that case.
      Communicate with an IoT hub using the MQTT protocol

    For large-scale, production-grade systems, the guidance is:

    • Prefer X.509 certificate–based authentication, especially CA-signed X.509:
      • Provides stronger security than symmetric keys.
      • Scales better because a single verified CA can authenticate many devices.
      • Avoids sharing symmetric keys across devices.
    • Use SAS tokens mainly for:
      • Evaluation, testing, or simpler scenarios where certificate management is not feasible and devices can securely store symmetric keys.

    Security guidance for IoT solutions explicitly recommends X.509 for production environments and advises against shared symmetric keys across devices.

    • “Use X.509 certificates to authenticate your devices to IoT Hub or IoT Central… Use X509-based authentication in production environments as it provides greater security than symmetric keys.”
    • “Avoid shared symmetric keys… Each device needs unique credentials.”

    Secure your IoT solutions

    Key rotation and certificate revocation

    1. Device credential rotation
      • Device credentials (keys or certificates) should be renewable and rotated regularly to limit the impact of compromise.
      • For X.509, IoT guidance includes rolling device certificates and managing certificate lifecycles.
      Secure your Azure IoT Hub deployment
    2. X.509 certificate lifecycle and revocation
      • With CA-signed X.509, revocation is handled by:
        • Removing or disabling the device identity in the IoT Hub identity registry, and/or
        • Managing the CA and intermediate certificates (for example, revoking a CA or not trusting a compromised CA).
      • IoT Hub requires proof of possession when registering a CA certificate: a cryptographic challenge is signed with the CA private key, ensuring only the CA owner can register it. This model underpins trust and enables revocation at the CA or device level.
      Authenticate identities with third-party X.509 certificates
    3. Revoking compromised devices
      • Implement procedures to quickly revoke access for compromised devices, preventing them from connecting and impacting other devices.
      • Device Provisioning Service (DPS) guidance includes how to revoke device access and roll certificates.
      Secure your Azure IoT Hub deployment
    4. Certificate management with Microsoft-managed PKI (preview)
      • IoT Hub introduces certificate management using Microsoft-managed PKI to issue and manage X.509 certificates for devices.
      • This feature handles certificate issuance and renewal for devices provisioned via DPS, simplifying rotation at scale.
      What is new in Azure IoT Hub? (preview)

    Best practices for securing device credentials at the edge

    1. Use X.509 certificates for device authentication
      • Use X.509 for device-to-cloud authentication in production.
      • Store private keys securely and never embed them in firmware in plain text.
      Secure your IoT solutions
    2. Use hardware-backed key storage (HSM/TPM)
      • Store credentials (keys and certificates) in hardware security modules (HSMs) or Trusted Platform Modules (TPMs) to protect against extraction and tampering.
      • TPM attestation can be used with DPS for secure provisioning.
      Secure your IoT solutions
      Secure your Azure IoT Hub deployment
    3. Avoid shared symmetric keys and enforce least privilege
      • Never share symmetric keys across devices. Each device must have unique credentials.
      • Use least-privilege access for any cloud-side identities (for example, using Microsoft Entra ID and RBAC for management operations).
      Secure your IoT solutions
      Secure your Azure IoT Hub deployment
    4. Rotate keys and certificates regularly
      • Regularly rotate device keys and certificates, especially after a breach or on expiration.
      • Ensure devices can update TLS root certificates and device certificates to avoid connectivity loss when certificates expire or are revoked.
      Secure your IoT solutions
      Secure your Azure IoT Hub deployment
    5. Use secure device provisioning and updates
      • Use Device Provisioning Service (DPS) for secure, zero-touch provisioning with appropriate authentication (X.509, TPM).
      • Use Device Update for IoT Hub or similar mechanisms to securely deliver firmware and credential updates.
      Secure your Azure IoT Hub deployment
    6. Network and connection security
      • Use TLS 1.2, strong cipher suites, and keep root CAs current.
      • Consider Azure Private Link, IP filtering, and disabling public network access where possible to reduce exposure.
      Secure your IoT solutions

    Summary

    • IoT Hub authenticates devices using credentials in the identity registry via SAS tokens or X.509 certificates, over TLS-secured connections.
    • For large-scale production, X.509 CA-signed authentication is recommended due to stronger security and better scalability.
    • Key rotation and certificate revocation are handled through renewable credentials, CA-based trust, DPS-based certificate rolling, and device revocation procedures.
    • Best practices include using X.509, hardware-backed key storage (HSM/TPM), unique per-device credentials, regular rotation, secure provisioning and updates, and strong network security controls.

    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.