copy_ca_based_cert
This script will copy a private key key.pem
and a certificate-authority-based certificate cert.pem
.
The following parameters are optional:
c
-
the common name (
localhost
if not given) of the certificate d
-
the directory (
$PWD
if not given) the key and certificate should be copied to; will be created if it does not exit y
-
assume "yes" as answer to all prompts and run non-interactively
Ensure that the certificate authority has been created and a private key and certificate have been created before executing this script. |
Both If the given directory is inside a Git working tree, the script will offer to modify the .gitignore file:
Related Script: git-cleanup |
Copy the script into your Node.js project and add it as a custom script to your package.json
|
Usage
$ scripts/cert/copy_ca_based_cert.sh
$ scripts/cert/copy_ca_based_cert.sh -d ~/.local/secrets/certs/localhost
$ scripts/cert/copy_ca_based_cert.sh -d ~/.local/secrets/certs/https.internal -c https.internal
$ stat -f '%A %N' ~/.local/secrets/certs/https.internal/*.pem
600 /Users/example/.local/secrets/certs/https.internal/cert.pem
600 /Users/example/.local/secrets/certs/https.internal/key.pem
$ openssl x509 -ext subjectAltName -noout -in ~/.local/secrets/certs/https.internal/cert.pem
X509v3 Subject Alternative Name:
DNS:https.internal