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

# Client-Zertifikat

Aktivieren Sie die Client-Zertifikat-Authentifizierung in PowerShell Universal und verwenden Sie roles.ps1, um Zertifikatsansprüche für Autorisierungsentscheidungen auszuwerten.

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 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/de/sicherheit/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.
