delete_ca_based_cert

This script will delete a private key and a certificate from a certificate authority; the key.pem and cert.pem files will also be deleted.

The following parameters are optional:

c

the common name (localhost if not given) of the certificate

d

the directory ($PWD if not given) containing the key and certificate; the directory will be also deleted if empty and not $PWD

Chrome, Docker, Firefox, and Safari need no further configuration.

This script will not delete additional copies, i.e., only the private key and certificate in the given directory (-d) and the CA will be removed.

Copy the script into your Node.js project and add it as a custom script to your package.json file:

package.json
{
...
  "scripts": {
    "cert:delete": "scripts/delete_ca_based_cert.sh -d certs"
  }
}
$ node --run cert:delete

Usage

$ scripts/cert/delete_ca_based_cert.sh
$ scripts/cert/delete_ca_based_cert.sh -d ~/.local/secrets/certs/localhost
$ scripts/cert/delete_ca_based_cert.sh -d ~/.local/secrets/certs/https.internal -c https.internal

Prerequisites