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

> Enregistrez un certificat X.509 auto-signé ou signé par une AC sur une application Auth0 afin d’activer l’authentification client mTLS auprès du serveur d’autorisation.

# 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 l’[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 client mTLS auprès du serveur d’autorisation.

    1. Accédez à [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 **Informations d’identification**.
    4. Choisissez la **méthode d’authentification** requise, qui peut être l’une des suivantes :

       * mTLS avec un [certificat auto-signé](/docs/fr-ca/customize/custom-domains/self-managed-certificates)
       * mTLS avec un certificat signé par une autorité de certification
    5. Une fois le type de certificat souhaité sélectionné, vous pouvez :

       * Attribuer une information d’identification (certificat) existante à l’application cliente
       * Ajouter une nouvelle information d’identification en téléversant un certificat
  </Tab>

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

    <Callout icon="file-lines" color="#0EA5E9" iconType="regular">
      Les exemples suivants utilisent **\$management\_access\_token**, c’est-à-dire un [jeton d’accès à la Management API](/docs/fr-ca/secure/tokens/access-tokens/management-api-access-tokens). Il doit être remplacé par un jeton d’accès qui comprend au moins les scopes suivants :

      * `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 façon d’obtenir un jeton d’accès avec les scopes requis, consultez [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 limites suivantes :

    * Les certificats auto-signés ne sont pas acceptés par certains fournisseurs infonuagiques, comme Amazon.
    * Pour assurer la stabilité de notre plateforme, Auth0 n’autorise que deux certificats enregistrés par client.

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

    Pour vous authentifier à l'aide du 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 wrap 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"
    ```

    Comme le certificat doit être envoyé sous forme de chaîne JSON sur une seule ligne, chaque caractère de saut de ligne littéral du fichier PEM doit être échappé pour JSON avant de le transmettre à Auth0. Remplacez chaque saut de ligne par `\n` (ou par `\r\n` si le fichier utilise des fins de ligne Windows). De nombreux outils et bibliothèques HTTP n’effectuent pas cette conversion automatiquement ; vérifiez donc l’échappement avant d’envoyer la requête. Par exemple :

    ```bash wrap lines theme={null}
    -----BEGIN CERTIFICATE-----\r\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDDXAVKQo2SUMHH\r\no9ecWYNiL5\/yva5NSj8uQjKoeRAsOIOAyOBTLxgwmno13xZ8VDkcT1cHTlC+2CkE\r\noBII4OUbHPVof+dtknkL+jUBdIPX1QvlGSUbzduZE4hEEQ8zH6w4EAA2VN72Bymn\r\nT8i\/+Tz9Dx6M1nkuXPCwM7sYEuq5OrqT5yVB6KByKKElp\/tauJkHp0st04iGDgl2\r\nFJUt3QJFCFewTDDdGq62otVJxHfouXPmHBQjzf+f1CZy+N0q2z+JGRt44YZq+F9y\r\ne3RWawvv2x3TXgRBLpvIKqf99LoPVdwozHl8QODu52dyelvLQ866XLhAALuMwic\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wpwDWB3MwzUGGQ52BAPsAOGh\r\nKva70jCwwKHB5+zBniHqBO2aq1oq9fwQZCwHcvkhAoGBAIa8QMHNrX7AuCSAeR4\/\r\n\/7XrGU1a4oExz417AYgZOuGaYQAI5BMIjRZZ3JTzO\/QsmkzeS1tFuBlih8li\/t4l\r\nE2TdnKhy376A6QWfbTDkJN6gzFeaMKwe98mOHKeq0KZITGYVTSa2AYH5zaro0Yku\r\nonOH1NdyEKFFgxGLg7wveYUW\r\n-----END CERTIFICATE-----
    ```

    ##### Créer un nouveau client

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

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

    ```bash 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 en savoir plus, consultez la documentation de l'API [Créer un client](https://auth0.com/docs/api/management/v2/clients/post-clients).

    ##### Modifier 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 plus vous authentifier au moyen du Client Secret, à moins de configurer le `token_endpoint_auth_method` pour qu’il n’utilise plus mTLS. Pour en savoir plus, consultez [Rétablir l’utilisation d’un Client Secret pour un client](#revert-a-client-to-use-a-client-secret).
    </Warning>

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

    Après avoir généré un certificat, créez la ressource d'identification :

    ```bash 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 ID de credential dans la réponse, que vous devrez utiliser pour associer le credential au client.

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

    ##### Associer l'identifiant au client et désactiver `token_endpoint_auth_method`

    Les identifiants téléversés ne sont pas automatiquement activés pour l'authentification du client. Vous devez mettre à jour l'authentification du client afin d'utiliser le nouveau certificat client auto-signé.

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

    ```bash 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 demande traitée, un Client Secret ne sera plus accepté et les clients devront s'authentifier via mTLS.

    Pour en savoir plus, consultez la documentation de l'API [Update a client](https://auth0.com/docs/api/management/v2/clients/patch-clients-by-id).

    #### Certificats signés par une autorité de certification

    Contrairement aux certificats auto-signés, qui sont générés par le client et ne disposent d'aucune 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 AC sont le seul type de certificat accepté par certains fournisseurs infonuagiques, comme Amazon.

    Les certificats signés par une AC 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 DN commun. Lors de l'utilisation de certificats signés par une AC, 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 AC dépend fortement de l'infrastructure à clés publiques et ne relève pas du cadre de ce document. Nous recommandons de générer au moins une [paire de clés RSA de 2048 bits](/docs/fr-ca/secure/application-credentials/generate-rsa-key-pair).

    ##### Créer un nouveau client

    Pour créer un client, effectuez un appel POST vers le 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 du fichier PEM généré par l’autorité de certification

    ```bash 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 DN du subject. Le DN du subject doit correspondre au Distinguished Name (DN) extrait des certificats client envoyés lors du handshake mTLS.

    <Callout icon="file-lines" color="#0EA5E9" iconType="regular">
      L’extraction du DN du sujet peut varier d’un écosystème à l’autre. Le moyen le plus fiable de garantir que le serveur d’autorisation correspondra au DN du sujet consiste à téléverser le fichier PEM complet.
    </Callout>

    La requête POST suivante crée un nouveau client avec le DN du sujet :

    ```bash 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 en savoir plus, consultez la documentation de l'API [Créer un client](https://auth0.com/docs/api/management/v2/clients/post-clients).

    ##### Modifier un client existant

    Si vous ne souhaitez pas créer un nouveau client pour utiliser mTLS, vous pouvez mettre à jour un client existant afin qu'il accepte l'authentification client mTLS. Pour ce faire, supprimez toute valeur dans le champ `token_endpoint_auth_method` et ajoutez des valeurs dans le champ `client_authentication_methods`.

    <Warning>
      Une fois que vous avez configuré votre client pour mTLS, vous ne pourrez plus vous authentifier au moyen du Client Secret, à moins de configurer le `token_endpoint_auth_method` pour qu’il n’utilise plus mTLS. Pour en savoir plus, consultez [Rétablir l’utilisation d’un Client Secret pour un client](#revert-a-client-to-use-a-client-secret).
    </Warning>

    ##### Créer la ressource d'informations 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'informations d'identification. Effectuez la requête POST suivante vers le point de terminaison `/clients/$client_id/credentials` :

    ```bash 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 DN du sujet. Le DN du sujet doit correspondre au nom distinctif (DN) extrait des certificats clients envoyés lors de la poignée de main mTLS.

    L'exemple de code suivant crée la ressource d'authentification à l'aide du Subject DN :

    ```bash 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"
    }'
    ```

    Quelle que soit la méthode utilisée, n'oubliez pas que l'ID de credential renvoyé dans la réponse est nécessaire pour associer le credential au client.

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

    ##### Associer l'identifiant au client et désactiver `token_endpoint_auth_method`

    Bien que nous ayons créé le credential, nous ne l'avons pas encore associé au client.

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

    ​​

    ```bash 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 traitée, le client ne peut être authentifié qu'avec mTLS.

    Pour en savoir plus, consultez la documentation de l’API [Update a client](https://auth0.com/docs/api/management/v2/clients/patch-clients-by-id).

    #### Rétablir l’utilisation d’un Client Secret pour un client

    Pour rétablir la configuration de votre client afin de l’authentifier à l’aide d’un Secret client, désactivez `client_authentication_methods` et réactivez `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 Client Secret :

    ```bash 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 en savoir plus, consultez la documentation de l'API [Update a client](https://auth0.com/docs/api/management/v2/clients/patch-clients-by-id).
  </Tab>
</Tabs>

<div id="learn-more">
  ## En savoir plus
</div>

* [S’authentifier avec mTLS](/docs/fr-ca/get-started/authentication-and-authorization-flow/authenticate-with-mtls)
* [Configurer le Customer Edge](/docs/fr-ca/get-started/applications/configure-mtls/set-up-the-customer-edge)
* [Configurer l’authentification mTLS pour un tenant](/docs/fr-ca/get-started/applications/configure-mtls/configure-mtls-for-a-tenant)
