verify_ca_based_cert

This script will verify the certificate authority based certificate cert.pem in the given directory ($PWD if not given).

On macOS, the CA root certificate will be verified in the "System" keychain also.

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

package.json
{
...
  "scripts": {
    "cert:verify": "scripts/verify_ca_based_cert.sh certs"
  }
}
$ npm run cert:verify

Usage

$ scripts/cert/verify_ca_based_cert.sh
$ scripts/cert/verify_ca_based_cert.sh ~/.local/secrets/certs/localhost
keychain: "/Library/Keychains/System.keychain"
...
    "labl"<blob>="Easy-RSA CA (2024-08-05, example-host)"
...
/Users/example/.local/secrets/certs/localhost/cert.pem
Certificate:
        Issuer: CN=Easy-RSA CA (2024-08-05, example-host)
        Validity
            Not Before: Aug  5 14:48:36 2024 GMT
            Not After : Sep  4 14:48:36 2024 GMT
        Subject: CN=localhost
...
            X509v3 Authority Key Identifier:
...
                DirName:/CN=Easy-RSA CA (2024-08-05, example-host)
...
            X509v3 Subject Alternative Name:
                DNS:localhost
...

Prerequisites