> ## 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.

> Explique comment configurer l’authentification mTLS pour une application.

# Configurer l’authentification mTLS pour une application

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

<Tabs>
  <Tab title="Auth0 Dashboard">
    Vous pouvez utiliser l’Auth0 Dashboard pour configurer mTLS pour une application afin d’activer l’authentification mTLS de l’application 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](/fr-CA/docs/get-started/auth0-overview/create-applications).
    3. Sélectionnez l’onglet **Credentials**.
    4. Choisissez la **méthode d’authentification** requise, qui peut être l’une des suivantes :

       * mTLS avec un [certificat autosigné](/fr-CA/docs/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 un certificat existant à l’application
       * Ajouter un nouveau certificat en le téléversant
  </Tab>

  <Tab title="Management API">
    Utilisez la [Management API Auth0](https://auth0.com/docs/api/management/v2) pour configurer mTLS pour une application.

    <Callout icon="file-lines" color="#0EA5E9" iconType="regular">
      Les exemples suivants utilisent **\$management\_access\_token**, ou un [jeton d’accès de la Management API](/fr-CA/docs/secure/tokens/access-tokens/management-api-access-tokens). Ce jeton 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](/fr-CA/docs/secure/tokens/access-tokens/get-access-tokens).
    </Callout>

    #### Certificats auto-signés

    Utilisez des certificats auto-signés pour vérifier l'identité de l'application lors de l'authentification mTLS. Toutefois, les certificats auto-signés présentent les limitations suivantes

    * Les certificats autosignés ne sont pas acceptés par certains fournisseurs de services 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 de mTLS auto-signé, vous devez créer un nouveau certificat d'application 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"
    ```

    Si vous utilisez curl ou Wget, le certificat PEM doit être échappé en JSON avant de le transmettre à Auth0. Par exemple, remplacez les sauts de ligne par `\r\n` :

    ```bash wrap 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+JqQH4vUyFZwFN7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DkJN6gzFeaMKwe98mOHKeq0KZITGYVTSa2AYH5zaro0Yku\r\nonOH1NdyEKFFgxGLg7wveYUW\r\n-----END PRIVATE KEY-----
    ```

    ##### Créer une nouvelle application

    Pour créer une nouvelle application, 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 de la nouvelle application
    * `$credential_name`**:** le nom de la clé publique
    * `$credential_certificate`: le contenu de `$certificate_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 une application](https://auth0.com/docs/api/management/v2/clients/post-clients).

    ##### Mettre à jour une application existante

    Vous pouvez mettre à jour une application existante pour qu'elle accepte l'authentification d'application mTLS en supprimant toute valeur dans le champ `token_endpoint_auth_method` et en ajoutant des valeurs dans le champ `client_authentication_methods`.

    <Warning>
      Une fois que vous avez configuré votre application pour mTLS, vous ne pourrez plus vous authentifier à l’aide du Secret client tant que vous n’aurez pas configuré `token_endpoint_auth_method` de façon à ne plus utiliser mTLS. Pour en savoir plus, consultez [Rétablir l’utilisation d’un Secret client pour une application](#revert-a-client-to-use-a-client-secret).
    </Warning>

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

    Après avoir généré un certificat, créez la ressource d'informations 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 d'accréditation dans la réponse, que vous devrez associer à l'application.

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

    ##### Associer les informations d'identification à l'application et désactiver `token_endpoint_auth_method`

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

    La requête PATCH suivante définit `token_endpoint_auth_method` à `null`, désactivant ainsi l'authentification par Secret client. Elle met également à jour `client_authentication_methods` avec l'ID des informations d'identification :

    ```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, le Secret client ne sera plus accepté et les applications devront s'authentifier via mTLS.

    Pour en savoir plus, consultez la documentation de l'API [Mettre à jour une application](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 générés par l'application et sans 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 tels qu'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 d'application transmis aux DN enregistrés.

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

    La méthode de génération d'un certificat d'application signé par une AC dépend fortement de l'infrastructure à clé publique et n'entre pas dans le cadre de ce document. Nous recommandons de générer au moins une [paire de clés RSA de 2048 bits](/fr-CA/docs/secure/application-credentials/generate-rsa-key-pair).

    ##### Créer une nouvelle application

    Pour créer une application, effectuez 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 de la nouvelle application
    * `$credential_name`**:** le nom de la clé publique
    * `$credential_certificate` : le contenu de `$certificate_pem` produit 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 sujet. Le DN du sujet doit correspondre au Distinguished Name (DN) extrait des certificats d'application envoyés lors de la négociation 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 pourra faire correspondre le DN du sujet est de téléverser le fichier PEM complet.
    </Callout>

    La requête POST suivante crée une nouvelle application 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 une application](https://auth0.com/docs/api/management/v2/clients/post-clients).

    ##### Mettre à jour une application existante

    Si vous ne souhaitez pas créer une nouvelle application pour utiliser mTLS, vous pouvez mettre à jour une application existante afin qu'elle accepte l'authentification d'application 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 application pour mTLS, vous ne pourrez plus vous authentifier à l’aide du Secret client, à moins de configurer `token_endpoint_auth_method` afin de ne plus utiliser mTLS. Pour en savoir plus, consultez [Reconfigurer une application pour utiliser un Secret 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](/fr-CA/docs/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` :

    ```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 Distinguished Name (DN) extrait des certificats d'application envoyés lors de la négociation mTLS.

    L'exemple de code suivant crée la ressource d'informations d'identification à l'aide du DN du sujet :

    ```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 d'accréditation renvoyé dans la réponse est nécessaire pour associer l'accréditation à l'application.

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

    ##### Associer les informations d'identification à l'application et désactiver `token_endpoint_auth_method`

    Bien que nous ayons créé les informations d'identification, nous ne les avons pas encore associées à l'application.

    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 terminée, l'application ne pourra être authentifiée qu'avec mTLS.

    Pour en savoir plus, consultez la documentation de l'API [Mettre à jour une application](https://auth0.com/docs/api/management/v2/clients/patch-clients-by-id).

    #### Rétablir une application pour utiliser un Secret client

    Pour rétablir la configuration de votre application afin qu'elle s'authentifie à 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 Secret client :

    ```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 [Mettre à jour une application](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](/fr-CA/docs/get-started/authentication-and-authorization-flow/authenticate-with-mtls)
* [Mettre en place le Customer Edge](/fr-CA/docs/get-started/applications/configure-mtls/set-up-the-customer-edge)
* [Configurer l’authentification mTLS pour un locataire](/fr-CA/docs/get-started/applications/configure-mtls/configure-mtls-for-a-tenant)
