Skip to content

Instantly share code, notes, and snippets.

@scottsbaldwin
Created August 16, 2016 20:12
Show Gist options
  • Save scottsbaldwin/9ea0b05f24ba3d7d7244da2a753c804e to your computer and use it in GitHub Desktop.
Save scottsbaldwin/9ea0b05f24ba3d7d7244da2a753c804e to your computer and use it in GitHub Desktop.
Create a self-signed certificate

Generate a self-signed certificate

mkdir -p certs && \
  openssl req -newkey rsa:4096 -nodes -sha256 \
    -keyout certs/domain.key \
    -x509 -days 365 \
    -out certs/domain.crt

You will be prompted for several values.

Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:Texas
Locality Name (eg, city) []:Austin
Organization Name (eg, company) [Internet Widgits Pty Ltd]:My Company
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:registry.example.com

If you are using the self-signed certificate for a docker registry, each docker daemon at the client side will need the domain.crt file copied to docker configuration directory.

sudo mkdir -p /etc/docker/certs.d/registry.example.com
sudo cp certs/domain.crt /etc/docker/certs.d/registry.example.com/ca.crt

You will then need to restart the docker engine on the client side:

sudo service docker restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment