Skip to content

Instantly share code, notes, and snippets.

@lifeblood
Forked from sherifabdlnaby/setup-certs.sh
Last active January 29, 2024 04:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lifeblood/ed54acb4821ea34c4647d3d5b7d40a6b to your computer and use it in GitHub Desktop.
Save lifeblood/ed54acb4821ea34c4647d3d5b7d40a6b to your computer and use it in GitHub Desktop.
# Exit on Error
set -e
OUTPUT_DIR=/secrets
CA_FILE=$OUTPUT_DIR/elastic-stack-ca.p12
CERT_FILE=$OUTPUT_DIR/elastic-certificates.p12
printf "====== Generating Elasticsearch Certifications ======\n"
printf "=====================================================\n"
if [ -f "$CA_FILE" ]; then
echo "Removing current Certificate Authority (CA)..."
rm $CA_FILE
fi
if [ -f "$CERT_FILE" ]; then
echo "Removing current Certificate (P12)..."
rm $CERT_FILE
fi
elasticsearch-certutil ca -s --pass "" --out $CA_FILE
elasticsearch-certutil cert -s --ca $CA_FILE --ca-pass "" --out $CERT_FILE --pass ""
chmod 0644 $CA_FILE
chmod 0644 $CERT_FILE
printf "Certificate Authority created at $CA_FILE\n"
printf "Certificate created at $CERT_FILE\n"
printf "=====================================================\n"
printf "SSL Certifications generation completed successfully.\n"
printf "=====================================================\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment