Skip to content

Commit 1ef08e2

Browse files
committed
Authentication article improvements
1 parent 16f9a6f commit 1ef08e2

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

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

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -593,16 +593,25 @@ Authorization rules can be applied to clients using X.509 certificates with thes
593593

594594
### Enable X.509 authentication for a listener port
595595

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).
596+
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.
597597

598+
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).
599+
600+
> [!NOTE]
601+
> 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:
602+
>
603+
> - **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.
604+
> - **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.
605+
>
606+
> So, 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 this with the *client-side* CA certificate used for client authentication, which is specified in the `trustedClientCaCert` field.
598607

599608
### Connect mosquitto client to MQTT broker with X.509 client certificate
600609

601610
A client like mosquitto needs two files to be able to connect to MQTT broker with TLS and X.509 client authentication.
602611
- 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.
603612
- The `--key` parameter specifies the client private key PEM file.
604613

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.
614+
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.
606615

607616
For example:
608617

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

649658
### Create a service account
650659

651-
To create SATs, first create a service account. The following command creates a service account called `mqtt-client`.
660+
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`.
652661

653662
```bash
654663
kubectl create serviceaccount mqtt-client -n azure-iot-operations
655664
```
656665

657-
### Add attributes for authorization
666+
### Optional: Add attributes for authorization
667+
668+
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.
669+
670+
You can annotate a service account using `kubectl annotate`:
671+
672+
```bash
673+
kubectl annotate serviceaccount <SERVICE_ACCOUNT_NAME> aio-broker-auth/<ATTRIBUTE>=<VALUE> -n azure-iot-operations
674+
```
675+
676+
Or you can add the annotations to the service account manifest file:
677+
678+
```yaml
679+
apiVersion: v1
680+
kind: ServiceAccount
681+
metadata:
682+
name: <SERVICE_ACCOUNT_NAME>
683+
namespace: azure-iot-operations
684+
annotations:
685+
aio-broker-auth/<ATTRIBUTE_1>: <VALUE_1>
686+
aio-broker-auth/<ATTRIBUTE_2>: <VALUE_2>
687+
```
658688

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).
689+
To learn more, see [Authorize clients that use Kubernetes Service Account Tokens](./howto-configure-authorization.md#authorize-clients-that-use-kubernetes-service-account-tokens).
660690

661691
### Enable Service Account Token (SAT) authentication
662692

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)