Fix: Kestrel Certificate File Not Found Error

Published: May 28, 2026 · By Kumar Kunal

The Error

App start:

System.IO.FileNotFoundException: The specified certificate file could not be found

Quick Fix - 1 Min

1. Path relative to content root. Use Path.Combine(env.ContentRootPath, "cert.pfx"). 2. Copy to output: <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>. 3. Or use cert store: options.ListenAnyIP(443, o => o.UseHttps(StoreName.My, "thumbprint"))

Root Cause

Working directory different in prod. Relative path breaks.

Found this helpful?

Master C# with our complete course. Real apps, real skills, job-ready in 2 hours.

Share this fix: Twitter LinkedIn

Comments on Fix: Kestrel Certificate File Not Found Error (0)

No comments yet. Be the first to share your thoughts!