client cert SSL / TLS Origin: Network OSI layer 6 · Presentation Last updated 18 Nov 2026

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

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

Exact message you may see curl: (58) unable to set private key filecurl: (58) could not load PEM client certificateunable to set private key file: 'client.key' type PEMcurl: (58) NSS: client certificate not foundcould not load PEM client certificate, OpenSSL error
Seen on: curl SSL OpenSSL

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?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Network. Errors that are often confused with or caused by this one (click to open):

496 — nginx 496 SSL Certificate Required (HTTP)496bad certificate — sslv3 alert bad certificate — server rejected the client certificate (mutual TLS) (SSL / TLS)bad certificatebad decrypt — openssl: bad decrypt / Could not read private key — wrong passphrase or cipher (SSL / TLS)bad decryptclient auth — Apache AH01895: Unable to configure verify locations for client authentication (SSLCACertificateFile) (SSL / TLS)client authCRYPT_E_NO_REVOCATION_CHECK — curl (Windows Schannel): schannel: next InitializeSecurityContext failed: CRYPT_E_NO_REVOCATION_CHECK (0x80092012) - The revocation function was unable to check revocation for the certificate (SSL / TLS)CRYPT_E_NO_REVOCATION…curl 56 — curl: (56) OpenSSL SSL_read: Connection reset by peer, errno 104 (TLS connection dropped mid-transfer) (SSL / TLS)curl 56curl: (60) SSL certificate problem — curl: (60) SSL certificate problem: unable to get local issuer certificate (SSL / TLS)curl: (60) SSL certif…Django — Django send_mail: ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] (EMAIL_USE_SSL vs EMAIL_USE_TLS on the wrong port) (Email / SMTP)Djangoclient ce…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.