This is just a simple script that I use to generate self-signed certificates. It's suited for general use of course, however it also includes v3 extensions which are required for container registries like Quay. This is my "easy button" for PoCs that can use temporary self-signed certificates.
- Download the script
curl -L https://gist.githubusercontent.com/v1k0d3n/08b9a1d37a06e90ff39646e1b09417d8/raw/certgen.sh -o certgen.sh
- Make it executable
chmod +x certgen.sh
- Edit the variables at the top of the file (look for the
STOP
notation) - Run the script
./certgen.sh
NOTE: Be sure that the openssl
and tree
packages are installed on your system first.
When you run the script, your output should look like the following:
[bjozsa@testing .local]$ ./certgen.sh
Certificate request self-signature ok
subject=C = US, ST = NC, L = Charlotte, O = RedHat, OU = IT, CN = vm-ocp-node59.ztp.dfw.ocp.run
Certificate Path: /home/bjozsa/.local/opt/demos/certs/vm-ocp-node59/etc/certs
/home/bjozsa/.local/opt/demos/certs/vm-ocp-node59
├── bin
│ ├── build-certs.sh
│ └── hosts-prep.sh
└── etc
└── certs
├── ca.crt
├── ca.key
├── ca.srl
├── v3.ext
├── vm-ocp-node59.ztp.dfw.ocp.run.crt
├── vm-ocp-node59.ztp.dfw.ocp.run.csr
└── vm-ocp-node59.ztp.dfw.ocp.run.key
3 directories, 9 files
[bjozsa@testing .local]$
You can modify the extensions that you want to add by modifying the v3.ext
artifact which is generated with the createCertificates
function. By default I include the following (for hosting OCP images on a Quay registry):
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1=host01.example.com
DNS.2=host01
IP.1=192.168.1.80
IP.2=127.0.0.1
This is for demonstration purposes only! You should be using a real certificate management solution. Don't run this in productioon, and don't always trust what you find on the internet.