copy_ca_based_cert
This script will copy the private key key.pem
and the certificate cert.pem
from the certificate authority to the given directory ($PWD
if not given).
The given directory will be created if it does not exit yet.
The optional second parameter is the common name (localhost
if not given) of the certificate to be copied.
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 ~/.local/secrets/certs/localhost
$ scripts/cert/copy_ca_based_cert.sh ~/.local/secrets/certs/https.internal 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