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

# Klientcertifikat

Aktivér godkendelse med klientcertifikat i PowerShell Universal, og brug roles.ps1 til at evaluere certifikatclaims til autorisationsbeslutninger.

Godkendelse med klientcertifikat sikrer, at klientmaskiner har et bestemt certifikat, når de opretter forbindelse til PowerShell Universal. Certifikatkontrollen håndteres under HTTP-forhandlingen, så den påvirker hele webserveren og kan ikke konfigureres pr. rute.

For at få detaljerede oplysninger om godkendelse med klientcertifikat i ASP.NET Core 5.0 kan De besøge [Microsoft-dokumentationen her](https://docs.microsoft.com/en-us/aspnet/core/security/authentication/certauth?view=aspnetcore-5.0).

## Aktivér godkendelse med klientcertifikat

De skal aktivere HTTPS-hosting og slå godkendelse med klientcertifikat til. Sørg først for, at De har valgt et HTTP-certifikat, og at De har angivet `ClientCertificateMode` til `RequireCertificate`. Disse indstillinger kan angives i filen appsettings.json.

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

Derefter skal De aktivere godkendelse med klientcertifikat.

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

## Autorisation

De kan bruge filen roles.ps1 til at evaluere det certifikat, som klienten leverer. Dette kan bruges til at afgøre, hvilke roller brugeren modtager, når der oprettes forbindelse til PSU.

For at evaluere de egenskaber, der er tilgængelige under autorisation, kan De serialisere variablen `$user`, der leveres til rollepolitikfunktionerne.

```powershell
param($User)

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

$true
```

De vil modtage oplysninger om certifikatet i brugerobjektet svarende til nedenstående.

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

```

De kan evaluere claims ved hjælp af metoden `HasClaim`. Følgende er et eksempel på kontrol af certifikatets tommelfingeraftryk.

```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/da/sikkerhed/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.
