Aller au contenu
Mehdi Kababfrontend / auteur
⁠Le carnet

Trust the mkcert CA in Flatpak Chromium

Flatpak Chromium keeps its own NSS database, so mkcert CA trust set up on the host never reaches it. Import the CA there and local HTTPS stops failing.

Traduction non disponible — cet article est affiché dans sa version anglaise d’origine.

⁠mkcert makes locally trusted HyperText Transfer Protocol Secure (HTTPS) certificates. mkcert -install adds its Certificate Authority (CA) to the system store and to the Network Security Services (NSS) database at ~/.pki/nssdb. Flatpak Chromium (org.chromium.Chromium) reads neither. Every local HTTPS page shows net::ERR_CERT_AUTHORITY_INVALID, even with a valid certificate.

Check the certificate first

Make sure the CA that signed the served certificate is the one mkcert knows. The certificate’s Authority Key Identifier must match the CA’s Subject Key Identifier:

shell
echo | openssl s_client -connect app.dev.example:443 -servername app.dev.example 2>/dev/null \
  | openssl x509 -noout -ext authorityKeyIdentifier,subjectAltName
openssl x509 -in "$(mkcert -CAROOT)/rootCA.pem" -noout -ext subjectKeyIdentifier

Also check the Subject Alternative Names (SANs): *.dev.example doesn’t cover app.infra.dev.example. A wildcard matches a single label.

Import the CA into the sandbox’s NSS database

The Flathub build keeps its NSS database under its own XDG_DATA_HOME: ~/.var/app/org.chromium.Chromium/data/pki/nssdb.

Wrong path

~/.var/app/org.chromium.Chromium/.pki/nssdb looks right, but Chromium ignores it.

Close Chromium, then import the CA with certutil (package nss-tools on Fedora):

shell
flatpak kill org.chromium.Chromium
db=~/.var/app/org.chromium.Chromium/data/pki/nssdb
certutil -d sql:"$db" -A -t "C,," -n "mkcert development CA" -i "$(mkcert -CAROOT)/rootCA.pem"
certutil -d sql:"$db" -L | grep mkcert

The last command prints mkcert development CA C,,. C,, trusts the CA to issue Transport Layer Security (TLS) server certificates only.

Restart Chromium: the padlock is back. If you added a security exception before, remove it from the site info popup.

Tip

Run the import again only when the mkcert CA changes. New leaf certificates from mkcert don’t need it.