Skip to content

Instantly share code, notes, and snippets.

@sherifabdlnaby
Created May 14, 2020 12:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sherifabdlnaby/8a70e2390853d8e03d40d9c608823db8 to your computer and use it in GitHub Desktop.
Save sherifabdlnaby/8a70e2390853d8e03d40d9c608823db8 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