Logo

dev-resources.site

for different kinds of informations.

No more self signed certificate warnings: HTTPS local development using Caddy 2 on macOS

Published at
1/25/2024
Categories
webdev
caddy
https
Author
tommygeorge
Categories
3 categories in total
webdev
open
caddy
open
https
open
Author
11 person written this
tommygeorge
open
No more self signed certificate warnings: HTTPS local development using Caddy 2 on macOS

Cross posted from my blog (from January 1). Hopefully useful in this wider community. =)


Relatively recently, I saw Wes Bos' YouTube Short about local https with Caddy.

I tried exactly that, but kept getting the self-signed certificate warnings in browsers. Boo! I figured there must be an extra step on my machine.

TL;DR: This is how I got it working: Install certutil

# Install `certutil`:
brew install nss
Enter fullscreen mode Exit fullscreen mode

So, brew install nss, and then caddy file-server --domain tg.localhost, or even stuff like caddy reverse-proxy --from tg.localhost --to http://localhost:1313.

The first time you run Caddy, it will prompt for your system password to install a trusted root cert. After that, no more "self signed certificate" warnings.

And yes: Change tg.localhost to just about anything you want. Open it in your browser, and it should "just work"!

How I figured it out

When running things like caddy file-server --domain tg.localhost, I noticed warnings in the output. This was while Caddy was trying to create/install the root certificate, and suggesting to install certutil:

WARN    pki.ca.local    installing root certificate (you might be prompted for password)    {"path": "storage:pki/authorities/local/root.crt"}
INFO    warning: "certutil" is not available, install "certutil" with "brew install nss" and try again
Enter fullscreen mode Exit fullscreen mode

It did prompt for local machine password a couple times, so I figured whatever fallback mechanism it was using would be working. But apparently not. Because I was still seeing "self signed" certificate warnings.

I've never used certutil, so wasn't familiar. But I decided to try it and ran brew install nss per the recommendation from Caddy output.

To be sure, I ran caddy trust, (while caddy run was running in another terminal!) and it worked flawlessly.

In subsequent tests, I haven't had to untrust/trust. It "Just Works", as long as certutil is already installed.

Hope that's helpful!

caddy Article's
30 articles in total
Favicon
Building and Deploying a New API (Part 3)
Favicon
I Built a CaddyFile Generator Tool in Just 8 Hours – Here’s How It Went
Favicon
Caddy
Favicon
Caddy
Favicon
How to Set Up n8n on DigitalOcean with Docker and Caddy
Favicon
Step-by-Step Guide to Hosting Your Website on a VPS Using Caddy Server and Cloudflare
Favicon
How to manage SSL Certs with Caddy
Favicon
Effortless Web Hosting with Caddy: A Beginner’s Guide
Favicon
Path-Based Reverse Proxying with Caddy
Favicon
Deploy firefox as container
Favicon
Switch from NGINX to Caddy
Favicon
Self Hosting with Tailscale and Caddy
Favicon
How to Dockerize an Angular App for Production
Favicon
Compute Caddy payload using Jinja2 with Ansible
Favicon
Using the same Caddyfile for both development and production
Favicon
Configuring Wildcard Subdomains: A Comparison of Nginx and Caddy
Favicon
No more self signed certificate warnings: HTTPS local development using Caddy 2 on macOS
Favicon
Prevent Caddy's automatic http-to-https redirect
Favicon
Routing multiple paths to a reverse proxy using Caddy
Favicon
Generating SSL certificates for SaaS customers without the hefty price tag
Favicon
Caddy Server - Basic Configuration
Favicon
Using Caddy for automatic SSL certificates with Cloudflare
Favicon
From ALB to Caddy - Our Wandering Path to Supporting Thousands of Domain Names
Favicon
Use hex.docs locally
Favicon
AWS Lightsail Container Services with Reverse Proxy
Favicon
TOP 5 Design-to-Code, Figma-to-Code Tools: FUNCTION12, Anima, and More
Favicon
Install Snipe-IT on Ubuntu 22.04 - HostnExtra
Favicon
Install Caddy on Ubuntu 22.04 - HostnExtra
Favicon
Caddy in Docker with common_log
Favicon
How to deploy Caddy on Tencent Cloud CVM

Featured ones: