> 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/de/sicherheit/enterprise-security/client-certificate.md).

# Clientzertifikat

Die Client-Zertifikat-Authentifizierung stellt sicher, dass Client-Rechner beim Verbinden mit PowerShell Universal ein bestimmtes Zertifikat besitzen. Die Zertifikatsprüfung erfolgt während der HTTP-Verhandlung, weshalb sie den gesamten Webserver betrifft und nicht pro Route konfiguriert werden kann.

Ausführliche Informationen zur Client-Zertifikat-Authentifizierung in ASP.NET Core 5.0 finden Sie in der [Microsoft-Dokumentation hier](https://docs.microsoft.com/en-us/aspnet/core/security/authentication/certauth?view=aspnetcore-5.0).

## Client-Zertifikat-Authentifizierung aktivieren

Sie müssen HTTPS-Hosting aktivieren und die Client-Zertifikat-Authentifizierung einschalten. Stellen Sie zunächst sicher, dass Sie ein HTTP-Zertifikat ausgewählt und den `ClientCertificateMode` auf `RequireCertificate` gesetzt haben. Diese Einstellungen können in der Datei appsettings.json festgelegt werden.

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

Als Nächstes müssen Sie die Client-Zertifikat-Authentifizierung aktivieren.

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

## Autorisierung

Sie können die Datei roles.ps1 verwenden, um das vom Client bereitgestellte Zertifikat auszuwerten. Damit kann bestimmt werden, welche Rollen der Benutzer beim Verbinden mit PSU erhält.

Um die während der Autorisierung verfügbaren Eigenschaften auszuwerten, können Sie die an die Rollenrichtlinien-Funktionen übergebene Variable `$user` serialisieren.

```powershell
param($User)

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

$true
```

Sie erhalten Informationen über das Zertifikat innerhalb des Benutzerobjekts, ähnlich wie unten dargestellt.

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

```

Sie können die Ansprüche mit der Methode `HasClaim` auswerten. Nachfolgend ein Beispiel für die Prüfung des Fingerabdrucks des Zertifikats.

```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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
