Warning
This is a work in progress, this README.md
and script content can change at any time for testing purposes.
When working with containers
(e.g. Docker) we sometimes find ourself in need of serving a local development server over https
on a custom domain (other than https://localhost
).
For a browser to see a connection as "secure" we will need a rootCA
and a leaf
certificate to sign the transfer between the browser and container properly.
localcert
strive to be a convenience script for the procedure of installing a rootCA
and generating a leaf
certificate for your local development domain.
-
Open a terminal.
Windows users should use
WSL2
(Windows Subsystem for Linux) forlocalcert
script to function properly. -
Change directory to your project directory:
cd /path/to/project/directory
-
Download
localcert
script:curl -fsSL "https://raw.githubusercontent.com/johanwestling/localcert/main/localcert" -o localcert
-
Add
.localcert
to your project.gitignore
file.The
.localcert
directory holds themkcert
binary and generated certificates. -
Change
localcert
to be executable:chmod +x localcert
-
Generate project certificates:
./localcert project-name project-name.dev "*.project-name.dev"
Important
The localcert
script will prompt for sudo
(account credentials) only when needed. The steps that requires sudo
at the moment is:
- Adding
rootCA
toMacOS
keychain. - Running
update-ca-certificates
onLinux
. - Copying
rootCA
from system directory.
When you have certificates generated for your project you will need to include or volume them in to your project container(s) and configure your development server to use them.