verify_self_signed_cert

This script will verify the self-signed certificate cert.pem in the given directory ($PWD if not given).

On macOS, the certificate will be verified in the "login" 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_self_signed_cert.sh certs"
  }
}
$ npm run cert:verify

Usage

$ scripts/cert/verify_self_signed_cert.sh
$ scripts/cert/verify_self_signed_cert.sh ~/.local/secrets/certs/localhost
keychain: "/Users/example/Library/Keychains/login.keychain-db"
...
    "labl"<blob>="localhost"
...
/Users/example/.local/secrets/certs/localhost/cert.pem
Certificate:
...
        Issuer: CN=localhost
        Validity
            Not Before: Feb 28 11:54:32 2024 GMT
            Not After : Mar 29 11:54:32 2024 GMT
        Subject: CN=localhost
...
            X509v3 Subject Alternative Name:
                DNS:localhost
...

Prerequisites