> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/powershell-universal/fr/securite/enterprise-security/client-certificate.md).

# Certificat client

Activez l'authentification par certificat client dans PowerShell Universal et utilisez roles.ps1 pour évaluer les revendications de certificat afin de prendre des décisions d'autorisation.

L'authentification par certificat client garantit que les machines clientes détiennent un certificat particulier lors de la connexion à PowerShell Universal. La vérification du certificat est effectuée pendant la négociation HTTP, ce qui affecte donc l'ensemble du serveur Web et ne peut pas être configuré par route.

Pour des informations détaillées sur l'authentification par certificat client dans ASP.NET Core 5.0, vous pouvez consulter la [documentation Microsoft ici](https://docs.microsoft.com/en-us/aspnet/core/security/authentication/certauth?view=aspnetcore-5.0).

## Activer l'authentification par certificat client

Vous devrez activer l'hébergement HTTPS et activer l'authentification par certificat client. Tout d'abord, assurez-vous d'avoir sélectionné un certificat HTTP et d'avoir défini le `ClientCertificateMode` à `RequireCertificate`. Ces paramètres peuvent être définis dans le fichier appsettings.json.

```json
"Kestrel": {
  "Endpoints": {
    "HTTPS": {
      "Url": "https://*:5000",
      "ClientCertificateMode": "RequireCertificate",
      "Certificate": {
        "Subject": "localhost",
        "Store": "My",
        "Location": "LocalMachine",
        "AllowInvalid": "true"
      }
    }
  },
  "RedirectToHttps": "false"
},
```

Ensuite, vous devrez activer l'authentification par certificat client.

```json
"ClientCertificate": {
  "Enabled": "true"
},
```

## Autorisation

Vous pouvez utiliser le fichier roles.ps1 pour évaluer le certificat fourni par le client. Cela peut être utilisé pour déterminer quels rôles l'utilisateur recevra lors de la connexion à PSU.

Pour évaluer les propriétés disponibles pendant l'autorisation, vous pouvez sérialiser la variable `$user` fournie aux fonctions de stratégie de rôle.

```powershell
param($User)

$User | ConvertTo-Json | Out-File .\user.txt

$true
```

Vous recevrez des informations sur le certificat dans l'objet utilisateur, semblables à ce qui suit.

```json
{
  "Claims": [
    {
      "Type": "issuer",
      "Value": "CN=Cert1, OU=Cert2, O=Org, L=Scottsdale, S=Arizona, C=US",
      "ValueType": "http://www.w3.org/2001/XMLSchema#string",
      "Issuer": "LOCAL AUTHORITY",
      "Properties": "System.Collections.Generic.Dictionary`2[System.String,System.String]"
    },
    {
      "Type": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/thumbprint",
      "Value": "8D2212B6EA170A33055A5",
      "ValueType": "http://www.w3.org/2001/XMLSchema#base64Binary",
      "Issuer": "LOCAL AUTHORITY",
      "Properties": "System.Collections.Generic.Dictionary`2[System.String,System.String]"
    },
    {
      "Type": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/x500distinguishedname",
      "Value": "CN=*.cert.com, OU=Domain Control Validated",
      "ValueType": "http://www.w3.org/2001/XMLSchema#string",
      "Issuer": "LOCAL AUTHORITY",
      "Properties": "System.Collections.Generic.Dictionary`2[System.String,System.String]"
    },
    {
      "Type": "http://schemas.microsoft.com/ws/2008/06/identity/claims/serialnumber",
      "Value": "009D21369",
      "ValueType": "http://www.w3.org/2001/XMLSchema#string",
      "Issuer": "LOCAL AUTHORITY",
      "Properties": "System.Collections.Generic.Dictionary`2[System.String,System.String]"
    },
    {
      "Type": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/dns",
      "Value": "*.cert.com",
      "ValueType": "http://www.w3.org/2001/XMLSchema#string",
      "Issuer": "LOCAL AUTHORITY",
      "Properties": "System.Collections.Generic.Dictionary`2[System.String,System.String]"
    },
    {
      "Type": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name",
      "Value": "*.cert.com",
      "ValueType": "http://www.w3.org/2001/XMLSchema#string",
      "Issuer": "LOCAL AUTHORITY",
      "Properties": "System.Collections.Generic.Dictionary`2[System.String,System.String]"
    }
  ],
  "Identity": {
    "Name": "*.cert.com"
  }
}

```

Vous pouvez évaluer les revendications à l'aide de la méthode `HasClaim`. Voici un exemple de vérification de l'empreinte du certificat.

```powershell
param($User)

$User.HasClaim('http://schemas.xmlsoap.org/ws/2005/05/identity/claims/thumbprint', '8D2212B6EA170A33055A5')
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.devolutions.net/powershell-universal/fr/securite/enterprise-security/client-certificate.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
