mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-02 20:59:56 -05:00
Generating nginx certs on first startup.
This commit is contained in:
parent
4823a63773
commit
f375e4c955
5 changed files with 38 additions and 7 deletions
19
scripts/generate_certificates.sh
Executable file
19
scripts/generate_certificates.sh
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env bash
|
||||
# Generate self-signed SSL certificates for nginx if they don't exist.
|
||||
|
||||
set -e
|
||||
|
||||
CERT_FILE="/etc/nginx/cert.crt"
|
||||
KEY_FILE="/etc/nginx/cert.key"
|
||||
|
||||
if [[ -f "${CERT_FILE}" && -f "${KEY_FILE}" ]]; then
|
||||
echo "Certificates already exist at ${CERT_FILE} and ${KEY_FILE}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Generating nginx certificates..."
|
||||
openssl genrsa -out "${KEY_FILE}" 2048
|
||||
openssl req -new -x509 -nodes -key "${KEY_FILE}" -out "${CERT_FILE}" -days 3650 \
|
||||
-subj "/C=US/ST=State/L=City/O=Org/OU=WROLPi/CN=$(hostname).local"
|
||||
chmod 640 "${KEY_FILE}" "${CERT_FILE}"
|
||||
echo "Certificates generated successfully."
|
||||
Loading…
Add table
Add a link
Reference in a new issue