Skip to content

Commit b34ae13

Browse files
author
Jill Grant
authored
Merge pull request #290848 from jlian/main
Add X.509 tutorial
2 parents dc8d3ac + f065dd9 commit b34ae13

13 files changed

+555
-22
lines changed

articles/iot-operations/connect-to-cloud/tutorial-mqtt-bridge.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Bi-directional MQTT bridge to Azure Event Grid
2+
title: "Tutorial: Bi-directional MQTT bridge to Azure Event Grid"
33
description: Learn how to create a bi-directional MQTT bridge to Azure Event Grid using Azure IoT Operations dataflows.
44
author: PatAltimore
55
ms.author: patricka

articles/iot-operations/manage-mqtt-broker/howto-configure-authentication.md

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Azure IoT Operations deploys a default *BrokerAuthentication* resource named `de
3939
# [Portal](#tab/portal)
4040

4141
1. In the Azure portal, navigate to your IoT Operations instance.
42-
1. Under **Azure IoT Operations resources**, select **MQTT Broker**.
42+
1. Under **Components**, select **MQTT Broker**.
4343
1. Select the **Authentication** tab.
4444
1. From authentication policy list, select the **default** policy name.
4545

@@ -176,7 +176,7 @@ To add an authentication method to a policy:
176176
# [Portal](#tab/portal)
177177

178178
1. In the Azure portal, navigate to your IoT Operations instance.
179-
1. Under **Azure IoT Operations resources**, select **MQTT Broker**.
179+
1. Under **Components**, select **MQTT Broker**.
180180
1. Select the **Authentication** tab.
181181
1. Choose an existing authentication policy or create a new one.
182182
1. Add a new method by selecting **Add method**.
@@ -331,6 +331,9 @@ For more information about enabling secure settings by configuring an Azure Key
331331

332332
## X.509
333333

334+
> [!TIP]
335+
> For an end-to-end example of how to configure X.509 authentication, see [Tutorial: TLS, X.509 client authentication, and attribute-based access control (ABAC) authorization](./tutorial-tls-x509.md).
336+
334337
With X.509 authentication, the MQTT broker uses a **trusted CA certificate** to validate client certificates. This trusted CA can be a root or intermediate CA. The broker checks the client certificate chain against the trusted CA certificate. If the chain is valid, the client is authenticated.
335338

336339
To use X.509 authentication with a trusted CA certificate, the following requirements must be met:
@@ -404,7 +407,7 @@ Once the trusted CA certificate is imported, enable X.509 client authentication
404407
# [Portal](#tab/portal)
405408

406409
1. In the Azure portal, navigate to your IoT Operations instance.
407-
1. Under **Azure IoT Operations resources**, select **MQTT Broker**.
410+
1. Under **Components**, select **MQTT Broker**.
408411
1. Select the **Authentication** tab.
409412
1. Choose an existing authentication policy or create a new one.
410413
1. Add a new method by selecting **Add method**.
@@ -593,16 +596,27 @@ Authorization rules can be applied to clients using X.509 certificates with thes
593596

594597
### Enable X.509 authentication for a listener port
595598

596-
After importing the trusted CA certificate and configuring the *BrokerAuthentication* resource, link it to a TLS-enabled listener port. For more details, see [Enable TLS manual certificate management for a port](./howto-configure-brokerlistener.md#enable-tls-manual-certificate-management-for-a-port) and [Enable TLS automatic certificate management for a port](./howto-configure-brokerlistener.md#enable-tls-automatic-certificate-management-for-a-port).
599+
After importing the trusted CA certificate and configuring the *BrokerAuthentication* resource, link it to a TLS-enabled listener port. This step is important because X.509 authentication relies on TLS for client certificate validation.
597600

601+
To get a TLS-enabled listener port, see [Enable TLS manual certificate management for a port](./howto-configure-brokerlistener.md#enable-tls-manual-certificate-management-for-a-port) and [Enable TLS automatic certificate management for a port](./howto-configure-brokerlistener.md#enable-tls-automatic-certificate-management-for-a-port).
602+
603+
> [!NOTE]
604+
> Enabling TLS on a broker listener port means the broker uses a server certificate for TLS encryption. When clients connect to this port, they must trust the server certificate by having the CA certificate that signed it in their trust store. This process is known as *trust distribution* or *trust bundling*. It's important to understand the difference between server validation and client validation:
605+
>
606+
> - **Client validation**: The MQTT broker (server) checks the client certificate against the trusted CA certificate specified in the `trustedClientCaCert` field for X.509 client authentication.
607+
> - **Server validation**: Clients (like mosquitto or MQTTX) check the MQTT broker's server certificate against the trusted CA certificate in their trust store. For mosquitto clients, use the `--cafile` parameter to specify the CA certificate file. For MQTTX, add the CA certificate to the trust store in the settings.
608+
>
609+
> After enabling X.509 authentication, ensure that clients trust the broker's server certificate by having the *server-side* CA certificate in their trust store. Don't confuse trusting the *server-side* CA certificate with the *client-side* CA certificate used for client authentication that is specified in the `trustedClientCaCert` field.
610+
>
611+
> For a full example, see [Tutorial: TLS, X.509 client authentication, and attribute-based access control (ABAC) authorization](./tutorial-tls-x509.md).
598612

599613
### Connect mosquitto client to MQTT broker with X.509 client certificate
600614

601615
A client like mosquitto needs two files to be able to connect to MQTT broker with TLS and X.509 client authentication.
602616
- The `--cert` parameter specifies the client certificate PEM file. This file should also include any intermediate certificates to help the MQTT broker build the complete certificate chain.
603617
- The `--key` parameter specifies the client private key PEM file.
604618

605-
In cases where MQTT broker is using a self-signed CA certificate to issue its TLS server certificate, the `--cafile` parameter is needed. This file contains the CA certificate which the mosquitto client uses to validate the broker's server certificate when connecting over TLS. If the issuer of MQTT broker's server certificate is part of the system root store (such as well-known public CAs), the `--cafile` parameter can be omitted.
619+
In cases where MQTT broker is using a self-signed CA certificate to issue its TLS server certificate, the `--cafile` parameter is needed. This file contains the CA certificate (also known as *trust bundle*) which the mosquitto client uses to validate the broker's server certificate when connecting over TLS. If the issuer of MQTT broker's server certificate is part of the system root store (such as well-known public CAs), the `--cafile` parameter can be omitted.
606620

607621
For example:
608622

@@ -648,15 +662,36 @@ The broker verifies tokens using the [Kubernetes Token Review API](https://kuber
648662

649663
### Create a service account
650664

651-
To create SATs, first create a service account. The following command creates a service account called `mqtt-client`.
665+
To create SATs, first [create a service account](https://kubernetes.io/docs/concepts/security/service-accounts/). The following command creates a service account called `mqtt-client`.
652666

653667
```bash
654668
kubectl create serviceaccount mqtt-client -n azure-iot-operations
655669
```
656670

657-
### Add attributes for authorization
671+
### Optional: Add attributes for authorization
672+
673+
Clients authenticating via SAT can optionally have their service accounts annotated with attributes to be used with authorization policies. To distinguish these annotations from others, they begin with `aio-broker-auth/` prefix.
674+
675+
You can annotate a service account using `kubectl annotate`:
676+
677+
```bash
678+
kubectl annotate serviceaccount <SERVICE_ACCOUNT_NAME> aio-broker-auth/<ATTRIBUTE>=<VALUE> -n azure-iot-operations
679+
```
680+
681+
Or you can add the annotations to the service account manifest file:
682+
683+
```yaml
684+
apiVersion: v1
685+
kind: ServiceAccount
686+
metadata:
687+
name: <SERVICE_ACCOUNT_NAME>
688+
namespace: azure-iot-operations
689+
annotations:
690+
aio-broker-auth/<ATTRIBUTE_1>: <VALUE_1>
691+
aio-broker-auth/<ATTRIBUTE_2>: <VALUE_2>
692+
```
658693

659-
Clients authenticating via SAT can optionally have their service accounts annotated with attributes to be used with authorization policies. To learn more, see [Authorize clients that use Kubernetes Service Account Tokens](./howto-configure-authentication.md).
694+
To learn more, see [Authorize clients that use Kubernetes Service Account Tokens](./howto-configure-authorization.md#authorize-clients-that-use-kubernetes-service-account-tokens).
660695

661696
### Enable Service Account Token (SAT) authentication
662697

@@ -665,7 +700,7 @@ Modify the `authenticationMethods` setting in a *BrokerAuthentication* resource
665700
# [Portal](#tab/portal)
666701

667702
1. In the Azure portal, navigate to your IoT Operations instance.
668-
1. Under **Azure IoT Operations resources**, select **MQTT Broker**.
703+
1. Under **Components**, select **MQTT Broker**.
669704
1. Select the **Authentication** tab.
670705
1. Choose an existing authentication policy or create a new one.
671706
1. Add a new method by selecting **Add method**.
@@ -822,7 +857,7 @@ For testing, you can disable authentication for a broker listener port. Disablin
822857
# [Portal](#tab/portal)
823858

824859
1. In the Azure portal, navigate to your IoT Operations instance.
825-
1. Under **Azure IoT Operations resources**, select **MQTT Broker**.
860+
1. Under **Components**, select **MQTT Broker**.
826861
1. Select the broker listener you want to edit from the list.
827862
1. On the port you want to disable authentication, select **None** in the authentication dropdown.
828863

@@ -859,3 +894,4 @@ Successful reauthentication updates the client's credential expiry with the expi
859894

860895
- About [BrokerListener resource](howto-configure-brokerlistener.md)
861896
- [Configure authorization for a BrokerListener](./howto-configure-authorization.md)
897+
- [Tutorial: TLS, X.509 client authentication, and attribute-based access control (ABAC) authorization](./tutorial-tls-x509.md)

articles/iot-operations/manage-mqtt-broker/howto-configure-authorization.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ The following example shows how to create a *BrokerAuthorization* resource using
3737
# [Portal](#tab/portal)
3838

3939
1. In the Azure portal, navigate to your IoT Operations instance.
40-
1. Under **Azure IoT Operations resources**, select **MQTT Broker**.
40+
1. Under **Components**, select **MQTT Broker**.
4141
1. Select the **Authorization** tab.
4242
1. Choose an existing authentication policy or create a new one by selecting **Create authorization policy**.
4343

@@ -333,7 +333,7 @@ For example, if a client has a certificate with subject `CN = smart-lock`, its u
333333

334334
## Authorize clients that use Kubernetes Service Account Tokens
335335

336-
Authorization attributes for SATs are set as part of the Service Account annotations. For example, to add an authorization attribute named `group` with value `authz-sat`, run the command:
336+
Authorization attributes for SATs are set as part of the [Service Account annotations](./howto-configure-authentication.md#kubernetes-service-account-tokens). For example, to add an authorization attribute named `group` with value `authz-sat`, run the command:
337337

338338
```bash
339339
kubectl annotate serviceaccount mqtt-client aio-broker-auth/group=authz-sat
@@ -764,7 +764,7 @@ kubectl edit brokerauthorization my-authz-policies
764764
# [Portal](#tab/portal)
765765

766766
1. In the Azure portal, navigate to your IoT Operations instance.
767-
1. Under **Azure IoT Operations resources**, select **MQTT Broker**.
767+
1. Under **Components**, select **MQTT Broker**.
768768
1. Select the broker listener you want to edit from the list.
769769
1. On the port you want to disable authorization, select **None** in the authorization dropdown.
770770

@@ -786,3 +786,4 @@ With MQTT 3.1.1, when a publish is denied, the client receives the PUBACK with n
786786

787787
- About [BrokerListener resource](howto-configure-brokerlistener.md)
788788
- [Configure authentication for a BrokerListener](./howto-configure-authentication.md)
789+
- [Tutorial: TLS, X.509 client authentication, and attribute-based access control (ABAC) authorization](./tutorial-tls-x509.md)

articles/iot-operations/manage-mqtt-broker/howto-configure-brokerlistener.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ To view or edit the default listener:
5151
# [Portal](#tab/portal)
5252

5353
1. In the Azure portal, navigate to your IoT Operations instance.
54-
1. Under **Azure IoT Operations resources**, select **MQTT Broker**.
54+
1. Under **Components**, select **MQTT Broker**.
5555

5656
:::image type="content" source="media/howto-configure-brokerlistener/configure-broker-listener.png" alt-text="Screenshot using Azure portal to view Azure IoT Operations MQTT configuration.":::
5757

@@ -202,7 +202,7 @@ This example shows how to create a new listener with load balancer service type.
202202
# [Portal](#tab/portal)
203203

204204
1. In the Azure portal, navigate to your IoT Operations instance.
205-
1. Under **Azure IoT Operations resources**, select **MQTT Broker**.
205+
1. Under **Components**, select **MQTT Broker**.
206206
1. Select **MQTT broker listener for LoadBalancer** > **Create**.
207207

208208
Enter the following settings:
@@ -537,7 +537,7 @@ The following is an example of a BrokerListener resource that enables TLS on por
537537
# [Portal](#tab/portal)
538538

539539
1. In the Azure portal, go to your IoT Operations instance.
540-
1. Under **Azure IoT Operations resources**, select **MQTT Broker**.
540+
1. Under **Components**, select **MQTT Broker**.
541541
1. Select or create a listener. You can only create one listener per service type. If you already have a listener of the same service type, you can add more ports to the existing listener.
542542
1. You can add TLS settings to the listener by selecting the **TLS** on an existing port or by adding a new port.
543543

@@ -751,7 +751,7 @@ The following is an example of a BrokerListener resource that enables TLS on por
751751
# [Portal](#tab/portal)
752752

753753
1. In the Azure portal, navigate to your IoT Operations instance.
754-
1. Under **Azure IoT Operations resources**, select **MQTT Broker**.
754+
1. Under **Components**, select **MQTT Broker**.
755755
1. Select or create a listener. You can only create one listener per service type. If you already have a listener of the same service type, you can add more ports to the existing listener. To follow the example, specify the listener service name as `mqtts-endpoint`.
756756
1. You can add TLS settings to the listener by selecting the **TLS** on an existing port or by adding a new port.
757757

@@ -921,3 +921,4 @@ From here, follow the same steps as previously to create a server certificate wi
921921

922922
- [Configure MQTT broker authorization](howto-configure-authorization.md)
923923
- [Configure MQTT broker authentication](howto-configure-authentication.md)
924+
- [Tutorial: TLS, X.509 client authentication, and attribute-based access control (ABAC) authorization](./tutorial-tls-x509.md)

articles/iot-operations/manage-mqtt-broker/howto-test-connection.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ For example, to create a new broker listener with node port service type, servic
154154
# [Portal](#tab/portal)
155155

156156
1. In the Azure portal, go to your IoT Operations instance.
157-
1. Under **Azure IoT Operations resources**, select **MQTT Broker**.
157+
1. Under **Components**, select **MQTT Broker**.
158158
1. Select **MQTT broker listener for NodePort** > **Create**. You can only create one listener per service type. If you already have a listener of the same service type, you can add more ports to the existing listener.
159159

160160
> [!CAUTION]
@@ -314,7 +314,7 @@ For example, to create a new broker listener with load balancer service type, se
314314
# [Portal](#tab/portal)
315315

316316
1. In the Azure portal, go to your IoT Operations instance.
317-
1. Under **Azure IoT Operations resources**, select **MQTT Broker**.
317+
1. Under **Components**, select **MQTT Broker**.
318318
1. Select **MQTT broker listener for NodePort** > **Create**. You can only create one listener per service type. If you already have a listener of the same service type, you can add more ports to the existing listener.
319319

320320
> [!CAUTION]
@@ -521,7 +521,7 @@ The reason that MQTT broker uses TLS and service accounts authentication by defa
521521
# [Portal](#tab/portal)
522522

523523
1. In the Azure portal, go to your IoT Operations instance.
524-
1. Under **Azure IoT Operations resources**, select **MQTT Broker**.
524+
1. Under **Components**, select **MQTT Broker**.
525525
1. Select **MQTT broker listener for NodePort** or **MQTT broker listener for LoadBalancer** > **Create**. You can only create one listener per service type. If you already have a listener of the same service type, you can add more ports to the existing listener.
526526

527527
> [!CAUTION]
@@ -615,3 +615,4 @@ spec:
615615

616616
- [Configure TLS with manual certificate management to secure MQTT communication](howto-configure-tls-manual.md)
617617
- [Configure authentication](howto-configure-authentication.md)
618+
- [Tutorial: TLS, X.509 client authentication, and attribute-based access control (ABAC) authorization](./tutorial-tls-x509.md)
114 KB
Loading
69.8 KB
Loading
136 KB
Loading
58.9 KB
Loading

articles/iot-operations/manage-mqtt-broker/media/tutorial-tls-and-x509/server-vs-client-roots.svg

Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)