> ## Documentation Index
> Fetch the complete documentation index at: https://auth0.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Configurer l’authentification mTLS pour un client

> Décrit comment configurer l’authentification mTLS pour un client.

Apprenez à configurer l’authentification mTLS pour un client avec la [Management API](#configure-mtls-with-management-api) et [Auth0 Dashboard](#configure-mtls-with-auth0-dashboard).

<Tabs>
  <Tab title="Auth0 Dashboard">
    Vous pouvez utiliser Auth0 Dashboard pour configurer mTLS pour un client afin d’activer l’authentification du client mTLS sur le serveur d’autorisation.

    1. Naviguez vers [Auth0 Dashboard > Applications > Applications](https://manage.auth0.com/#/applications).
    2. Sélectionnez l’application que vous souhaitez utiliser avec mTLS ou [créez une nouvelle application](/docs/fr-ca/get-started/auth0-overview/create-applications).
    3. Sélectionnez l’onglet **Credentials (Identifiants)**
    4. Choisissez la **méthode d’authentification** requise, qui peut être :

       * mTLS avec un [certificat autosigné](/docs/fr-ca/customize/custom-domains/self-managed-certificates), ou
       * mTLS avec un certificat signé par l’autorité de certification
    5. Une fois que vous avez sélectionné le type de certificat que vous préférez, vous pouvez :

       * Attribuer un identifiant (certificat) existant dans l’application du client
       * Ajouter un nouvel identifiant en téléversant un certificat
  </Tab>

  <Tab title="Management API">
    Utilisez la [Management API d’Auth0](https://auth0.com/docs/api/management/v2) pour configurer l’authentification mTLS pour un client.

    <Callout icon="file-lines" color="#0EA5E9" iconType="regular">
      Les exemples suivants spécifient **\$management\_access\_token**, ou un [jeton d’accès de Management API](/docs/fr-ca/secure/tokens/access-tokens/management-api-access-tokens). Il doit être remplacé par un jeton d’accès contenant au moins les permissions suivantes :

      * `create:custom_domains`
      * `read:custom_domains`
      * `create:clients`
      * `update:clients`
      * `update:client_credentials`
      * `update:client_keys`
      * `update:tenant_settings`

      Pour en savoir plus sur la récupération d’un jeton d’accès avec les permissions requises, lisez [Obtenir des jetons d’accès](/docs/fr-ca/secure/tokens/access-tokens/get-access-tokens).
    </Callout>

    #### Certificats auto-signés

    Utilisez des certificats auto-signés pour vérifier l’identité du client lors de l’authentification mTLS. Cependant, les certificats auto-signés présentent les limitations suivantes

    * Les certificats auto-signés ne sont pas acceptés par certains fournisseurs de cloud comme Amazon.
    * Pour garantir la stabilité de notre plateforme, Auth0 limite les clients à deux certificats enregistrés.

    ##### Générer un certificat

    Pour pouvoir être authentifié à l’aide d’un certificat mTLS auto-signé, vous devez créer un nouveau certificat client auto-signé.

    L’exemple de code suivant génère un nouveau certificat auto-signé :

    ```bash lines theme={null}
    openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -sha256 -days 365 -nodes -subj "/C=XX/ST=StateName/L=CityName/O=CompanyName/OU=CompanySectionName/CN=CommonNameOrHostname"
    ```

    Si vous utilisez cURL ou wget, le certificat PEM doit être échappé en JSON avant d’être transmis à Auth0. Par exemple, remplacez une nouvelle ligne par `\r\n` :

    ```json lines theme={null}
    -----BEGIN PRIVATE KEY-----\r\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDDXAVKQo2SUMHH\r\no9ecWYNiL5\/yva5NSj8uQjKoeRAsOIOAyOBTLxgwmno13xZ8VDkcT1cHTlC+2CkE\r\noBII4OUbHPVof+dtknkL+jUBdIPX1QvlGSUbzduZE4hEEQ8zH6w4EAA2VN72Bymn\r\nT8i\/+Tz9Dx6M1nkuXPCwM7sYEuq5OrqT5yVB6KByKKElp\/tauJkHp0st04iGDgl2\r\nFJUt3QJFCFewTDDdGq62otVJxHfouXPmHBQjzf+f1CZy+N0q2z+JGRt44YZq+F9y\r\ne3RWawvv2x3TXgRBLpvIKqf99LoPVdwozHl8QODu52dyelvLQ866XLhAALuMwic\/\r\nbQbolnMpAgMBAAECggEAf6LliekFmezNTmQLgIkzP7kh5XRsJu81bEGv20aNfHbH\r\n5CJZ\/b8tLMQgyIWiqURVs9taXtmaA7YyxmTWo5pb1WUMKWQ3je0+zMaCTxsS8Lau\r\n+NV+2zWaHd8XDnGe3qX43QAHQ3gb294+JqQH4vUyFZwFN7sA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JN6gzFeaMKwe98mOHKeq0KZITGYVTSa2AYH5zaro0Yku\r\nonOH1NdyEKFFgxGLg7wveYUW\r\n-----END PRIVATE KEY-----
    ```

    ##### Créer un nouveau client

    Pour créer un nouveau client, faites un appel POST au point de terminaison [`/clients`](https://auth0.com/docs/api/management/v2/clients/post-clients) avec la charge utile suivante :

    * `$client_name`**:** le nom du nouveau client
    * `$credential_name`**:** le nom de la clé publique
    * `$credential_certificate` : le contenu de `$certificate_pem`généré à l’étape précédente

    ```json lines theme={null}
    curl --location --request POST 'https://$tenant/api/v2/clients' \
      --header 'Authorization: Bearer $management_access_token' \
      --header 'Content-Type: application/json' \
      --data-raw '{
      "name": "$client_name",
      "app_type": "non_interactive",
      "client_authentication_methods": {
        "self_signed_tls_client_auth": {
          "credentials": [{ 
            "name": "$credential_name", 
            "credential_type": "x509_cert", 
            "pem": "$credential_certificate"
          }]
        }
      },
      "jwt_configuration": {
        "alg": "RS256"
      }
    }'
    ```

    Pour plus d’information, consultez la documentation sur l’API [Créer un client](https://auth0.com/docs/api/management/v2/clients/post-clients).

    ##### Mettre à jour un client existant

    Vous pouvez mettre à jour un client existant pour qu’il accepte l’authentification client mTLS en supprimant toute valeur dans le champ `token_endpoint_auth_method` et en créant des valeurs dans le champ `client_authentication_methods`.

    <Warning>
      Une fois que vous avez configuré votre client pour mTLS, vous ne pourrez pas vous authentifier au moyen du secret client à moins de configurer `token_endpoint_auth_method` pour qu’il arrête d’utiliser mTLS. Pour en savoir plus, lisez [Revenir à un client pour utiliser un secret client](#revert-a-client-to-use-a-client-secret).
    </Warning>

    ##### Créer la ressource d’identification

    Une fois que vous avez généré un certificat, créez la ressource d’identification :

    ```json lines theme={null}
    curl --location --request POST 'https://$tenant/api/v2/clients/$client_id/credentials' \
      --header 'Authorization: Bearer $management_access_token' \
      --header 'Content-Type: application/json' \
      --data-raw '{
      "name": "$credential_name", 
      "credential_type": "x509_cert", 
      "pem": "$credential_certificate"
    }'
    ```

    Auth0 renvoie un identifiant d’identification dans la réponse dont vous aurez besoin pour associer l’identifiant au client.

    Pour plus d’information, consultez la documentation sur l’API [Créer un identifiant de client](https://auth0.com/docs/api/management/v2/clients/post-credentials).

    ##### Associer les identifiants au client et désactiver `token_endpoint_auth_method`

    Les informations d’identification téléversées ne sont pas automatiquement activées pour l’authentification du client. Vous devez mettre à jour l’authentification du client pour utiliser le nouveau certificat client auto-signé.

    La requête PATCH suivante définit le champ `token_endpoint_auth_method` sur `null`, désactivant ainsi l’authentification par secret client. Elle met également à jour `client_authentication_methods` avec l’identifiant du certificat :

    ```json lines theme={null}
    curl --location --request PATCH 'https://$tenant/api/v2/clients/$client_id' \
      --header 'Authorization: Bearer $management_access_token' \
      --header 'Content-Type: application/json' \
      --data-raw '{
      "token_endpoint_auth_method": null, 
      "client_authentication_methods": {
        "self_signed_tls_client_auth": {
          "credentials": [{ "id": $credential.id }]
        }
      }
    }'
    ```

    Une fois cette requête terminée, un Secret Client ne sera plus accepté et les clients devront s’authentifier en utilisant mTLS.

    Pour plus d’information, consultez la documentation sur l’API [Mettre à jour un client](https://auth0.com/docs/api/management/v2/clients/patch-clients-by-id).

    #### Certificats signés par l’autorité de certification

    Contrairement aux certificats auto-signés qui sont générés par le client et n’ont pas de chaîne de confiance, les certificats signés par une autorité de certification (AC) sont considérés comme plus fiables puisqu’ils sont émis par un tiers de confiance. Les certificats signés par une autorité de certification sont le seul type de certificat accepté par certains fournisseurs de cloud comme Amazon.

    Les certificats signés par une autorité de certification intègrent dans leurs informations d’identité la notion de nom distinctif (DN). Bien que chaque certificat individuel créé par une AC donnée soit unique, ils peuvent partager un nom distinctif (DN) commun. Lors de l’utilisation de certificats signés par une autorité de certification, Auth0 stocke le DN et compare les certificats clients transmis avec les DN enregistrés.

    ##### Générer un certificat

    La méthode de génération d’un certificat client signé par une autorité de certification dépend fortement de l’infrastructure de clés publiques et dépasse le cadre du présent document. Nous recommandons de générer une [paire de clés RSA d’au minimum 2048 bits](/docs/fr-ca/secure/application-credentials/generate-rsa-key-pair).

    ##### Créer un nouveau client

    Pour créer un client, faites un appel POST au point de terminaison [`/clients`](https://auth0.com/docs/api/management/v2/clients/post-clients) avec la charge utile suivante :

    * `$client_name`**:** le nom du nouveau client
    * `$credential_name`**:** le nom de la clé publique
    * `$credential_certificate` : le contenu de `$certificate_pem` généré par l’autorité de certification

    ```json lines theme={null}
    curl --location --request POST 'https://$tenant/api/v2/clients' \
      --header 'Authorization: Bearer $management_access_token' \
      --header 'Content-Type: application/json' \
      --data-raw '{
      "name": "$client_name",
      "app_type": "non_interactive",
      "client_authentication_methods": {
        "tls_client_auth": {
          "credentials": [{ 
            "name": "$credential_name", 
            "credential_type": "cert_subject_dn", 
            "pem": "$credential_certificate"
          }]
        }
      },
      "jwt_configuration": {
        "alg": "RS256"
      }
    }'
    ```

    Au lieu de transmettre le fichier PEM complet, vous pouvez également transmettre le nom distinctif (DN) du sujet. Le DN du sujet doit correspondre au nom distinctif (DN) extrait des certificats du client envoyés au cours de l’établissement de liaison mTLS.

    <Callout icon="file-lines" color="#0EA5E9" iconType="regular">
      L’extraction du DN du sujet peut varier d’un écosystème à l’autre. La manière la plus fiable de garantir que le serveur d’autorisation fera correspondre le DN du sujet est de téléverser l’intégralité du fichier PEM.
    </Callout>

    La requête POST suivante crée un nouveau client avec le ND (Nom Distinctif) du sujet :

    ```json lines theme={null}
    curl --location --request POST 'https://$tenant/api/v2/clients' \
      --header 'Authorization: Bearer $management_access_token' \
      --header 'Content-Type: application/json' \
      --data-raw '{
      "name": "$client_name",
      "app_type": "non_interactive",
      "client_authentication_methods": {
        "tls_client_auth": {
          "credentials": [{ 
            "name": "$credential_name", 
            "credential_type": "cert_subject_dn", 
            "subject_dn": "C=XX\nST=StateName\nL=CityName\nO=CompanyName\nOU=CompanySectionName\nCN=CommonNameOrHostname"
          }]
        }
      },
      "jwt_configuration": {
        "alg": "RS256"
      }
    }'
    ```

    Pour plus d’informations, consultez la documentation sur l’API [Créer un client](https://auth0.com/docs/api/management/v2/clients/post-clients).

    ##### Mettre à jour un client existant

    Si vous ne souhaitez pas créer un nouveau client pour utiliser mTLS, vous pouvez mettre à jour un client existant pour qu’il accepte l’authentification client mTLS. Cela implique de supprimer toute valeur dans le champ `token_endpoint_auth_method` et de créer des valeurs dans le champ `client_authentication_methods`.

    <Warning>
      Une fois que vous avez configuré votre client pour mTLS, vous ne pourrez pas vous authentifier au moyen du secret client à moins de configurer `token_endpoint_auth_method` pour qu’il arrête d’utiliser mTLS. Pour en savoir plus, lisez [Revenir à un client pour utiliser un secret client](#revert-a-client-to-use-a-client-secret).
    </Warning>

    ##### Créer la ressource d’identification

    Une fois que vous avez [généré une paire de clés](/docs/fr-ca/secure/application-credentials/generate-rsa-key-pair) exclusivement pour mTLS, créez la ressource d’authentification. Effectuez la requête POST suivante vers le point de terminaison `/clients` :

    ```json lines theme={null}
    curl --location --request POST 'https://$tenant/api/v2/clients/$client_id/credentials' \
      --header 'Authorization: Bearer $management_access_token' \
      --header 'Content-Type: application/json' \
      --data-raw '{
      "name": "$credential_name", 
      "credential_type": "cert_subject_dn", 
      "pem": "$credential_certificate"
    }'
    ```

    Au lieu de transmettre le fichier PEM complet, vous pouvez transmettre le nom distinctif (DN) du sujet. Le nom distinctif (DN) du sujet doit correspondre au nom distinctif (DN) extrait des certificats du client envoyés au cours de l’établissement de liaison mTLS.

    L’exemple de code suivant crée la ressource d’identification en utilisant le ND du sujet :

    ```json lines theme={null}
    curl --location --request POST 'https://$tenant/api/v2/clients/$client_id/credentials' \
      --header 'Authorization: Bearer $management_access_token' \
      --header 'Content-Type: application/json' \
      --data-raw '{
      "name": "$credential_name", 
      "credential_type": "cert_subject_dn", 
      "subject_dn": "C=XX\nST=StateName\nL=CityName\nO=CompanyName\nOU=CompanySectionName\nCN=CommonNameOrHostname"
    }'
    ```

    Que vous utilisiez l’une ou l’autre méthode, n’oubliez pas que l’ID d’identification renvoyée dans la réponse est nécessaire pour associer l’identification au client.

    Pour plus d’information, consultez la documentation sur l’API [Créer un identifiant de client](https://auth0.com/docs/api/management/v2/clients/post-credentials).

    ##### Associer les identifiants au client et désactiver `token_endpoint_auth_method`

    Bien que nous ayons créé l’identifiant, nous ne l’avons pas encore associé au client.

    Pour ce faire, mettez à jour `client_authentication_methods` en effectuant la requête PATCH suivante au point de terminaison `/clients`. Dans la même requête, définissez `token_endpoint_auth_method` à `null` :

    ​​

    ```json lines theme={null}
    curl --location --request PATCH 'https://$tenant/api/v2/clients/$client_id' \
      --header 'Authorization: Bearer $management_access_token' \
      --header 'Content-Type: application/json' \
      --data-raw '{
      "token_endpoint_auth_method": null, 
      "client_authentication_methods": {
        "tls_client_auth": {
          "credentials": [{ "id": $credential.id }]
        }
      }
    }'
    ```

    Une fois cette requête effectuée, le client ne pourra être authentifié qu’en utilisant mTLS.

    Pour plus d’information, consultez la documentation sur l’API [Mettre à jour un client](https://auth0.com/docs/api/management/v2/clients/patch-clients-by-id).

    #### Faire revenir un client à l’utilisation d’un secret client

    Pour restaurer la configuration de votre client afin qu’il s’authentifie à l’aide d’un secret client, désactivez `client_authentication_methods` et activez à nouveau `token_endpoint_auth_method` avec la méthode d’authentification souhaitée.

    Dans la requête PATCH suivante, définissez `token_endpoint_auth_method` sur `client_secret_post` pour réactiver l’authentification par secret client :

    ```json lines theme={null}
    curl --location --request PATCH 'https://$tenant/api/v2/clients/$client_id' \
      --header 'Authorization: Bearer $management_access_token' \
      --header 'Content-Type: application/json' \
      --data-raw '{
      "token_endpoint_auth_method": "client_secret_post", 
      "client_authentication_methods": null
    }'
    ```

    Pour plus d’information, consultez la documentation sur l’API [Mettre à jour un client](https://auth0.com/docs/api/management/v2/clients/patch-clients-by-id).
  </Tab>
</Tabs>

## En savoir plus

* [Authentification avec mTLS](/docs/fr-ca/get-started/authentication-and-authorization-flow/authenticate-with-mtls)
* [Configurer le réseau de périphérie client](/docs/fr-ca/get-started/applications/configure-mtls/set-up-the-customer-edge)
* [Configurer l’authentification mTLS pour un locataire](/docs/fr-ca/get-started/applications/configure-mtls/configure-mtls-for-a-tenant)
