> 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

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 durant la négociation HTTP, ce qui affecte l'ensemble du serveur web et ne peut pas être configurée 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 devez activer l'hébergement HTTPS et activer l'authentification par certificat client. Assurez-vous d'abord qu'un certificat HTTP est sélectionné et que vous avez défini `ClientCertificateMode` sur `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 devez 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 lors de l'autorisation, vous pouvez sérialiser la variable `$user` fournie aux fonctions de politique 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, similaires à 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`. L'exemple suivant illustre la vérification de l'empreinte numérique 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
