# curl: (58) unable to set private key file / could not load PEM client certificate

**Code:** `client cert` · **Category:** SSL / TLS · **Seen on:** curl, SSL, OpenSSL

curl couldn't load the client certificate or its private key for mutual TLS.

## Meaning

The cert and key must match, be PEM (or use `--cert-type`), and the key password (if encrypted) must be supplied (`--pass`). Use `--cert file.pem --key key.pem`, avoid combining files in the wrong order, and check permissions.

## Common causes

- Cert and key don't match
- Wrong file format/type
- Encrypted key without `--pass`
- File not readable
- PKCS#12 used without `--cert-type P12`

## Quick fix

1. Verify the pair: compare `openssl x509 -modulus` and `openssl rsa -modulus`
2. Pass `--cert-type P12` for PFX
3. Use `--pass` for encrypted keys

## Detailed fix by platform

### Shell

1. 

```bash
curl --cert client.pem --key client.key --cacert ca.pem https://mtls.example.com/
curl --cert-type P12 --cert client.p12:password https://mtls.example.com/
```


## How to diagnose

1. **Pair** — Matches?
2. **Type** — PEM/P12?
3. **Passphrase** — Supplied?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/ssl/curl-58-unable-to-set-private-key-file)
