Serve a fresh certificate on every https-private-ca re-run

just lab https-private-ca had three faults that showed up together on a re-run. The certificate named only the VM's ephemeral external address, so a runner or container reaching the VM by its internal address could not verify it. A re-run reused whatever CA was already on the VM, however stale. And after a new certificate was installed, nothing restarted nginx: gitlab-ctl reconfigure does not restart it when only certificate content changes, so the old certificate kept being served while the files on disk said otherwise.

Reproduction and control

On a 19.1.1-ee omnibus VM, the recipe as it stands on main moved the instance to https and installed a certificate whose only subject alternative name was the external address. Running it again printed "already on https ... nothing changed" and left that certificate in place. Replacing the installed certificate with one that also names the internal address and running gitlab-ctl reconfigure, which is all the old recipe does after an install, left nginx serving the previous certificate: the installed and served SHA-256 fingerprints differed.

With this change, the same recipe on the same VM noticed that nginx did not serve the installed certificate and re-applied. It minted a new CA with a different fingerprint, issued a certificate naming the internal and external addresses, restarted nginx, and checked that the served fingerprint equals the installed one before reporting success. The sign-in page answered 200 through the OS trust store. A second run printed "already ... nothing changed".

Fix

  • The certificate names the host in external_url and the VM's internal address (read from the instance, passed as SIM_HTTPS_IP). The external address is added only when external_url is itself that address.
  • Every mint starts from an empty CA directory, so a re-run never inherits a stale CA.
  • The already-on-https shortcut now also requires the installed certificate to carry the expected names and nginx to serve it; otherwise it re-applies.
  • A gitlab-ctl restart nginx step follows reconfigure, and the proof fails unless the served fingerprint matches the installed certificate.
  • gce/https-private-ca.md describes the new behaviour.

The engine self-test gains cases for the changed names, the no-reuse rule, the restart step and the served-fingerprint check. Against the previous script those cases fail.

Merge request reports

Loading
Loading