# Windows: private key access denied — application pool/service account can't read the certificate's key

**Code:** `private key` · **Category:** SSL / TLS · **Seen on:** Windows, IIS, .NET

The certificate is in the store, but the app's identity has no permission on its private key, so TLS fails.

## Meaning

In `certlm.msc`, open Manage Private Keys on the certificate and grant Read to the app pool identity (`IIS AppPool\SiteName`) or service account. Machine-store keys live in `%ProgramData%\Microsoft\Crypto\RSA\MachineKeys`. For CNG keys use the corresponding folder.

## Common causes

- App pool identity lacks key permissions
- Certificate imported without private key
- Key stored in a user store, not machine store
- Service account changed
- CNG key permission missing

## Quick fix

1. Grant Read on the private key to the app pool/service identity
2. Import to LocalMachine\My with the private key
3. Use `icacls` on the key file

## Detailed fix by platform

### PowerShell

1. 

```bash
$cert = Get-ChildItem Cert:\LocalMachine\My | Where Thumbprint -eq "THUMB"
$key = $cert.PrivateKey.CspKeyContainerInfo.UniqueKeyContainerName
icacls "$env:ProgramData\Microsoft\Crypto\RSA\MachineKeys\$key" /grant "IIS AppPool\MySite:R"
```


## How to diagnose

1. **Identity** — Has key access?
2. **Store** — LocalMachine?
3. **Key** — Present?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/ssl/windows-private-key-access-denied-app-pool)
