delete_ca_based_cert

This script will remove the private key and the certificate from the certificate authority; and delete the key key.pem and the certificate cert.pem from the given directory ($PWD if not given).

If the given directory is not $PWD and is empty after the deletion it will be deleted as well.

The optional second parameter is the common name (localhost if not given) of the certificate to be removed.

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

Additional copies will not be deleted by this script, i.e. only the private key and certificate in the given directory 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 certs"
  }
}
$ npm run cert:delete

Usage

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

Prerequisites