From ccab3b6d7e4031ce1422e8ee1adab7f03de8a428 Mon Sep 17 00:00:00 2001 From: vcerenu Date: Fri, 26 Sep 2025 12:14:09 -0300 Subject: [PATCH] Modify Wazuh cert tool generation --- indexer-certs-creator/Dockerfile | 4 +-- indexer-certs-creator/config/entrypoint.sh | 40 +++++++++++++--------- multi-node/generate-indexer-certs.yml | 4 ++- single-node/generate-indexer-certs.yml | 4 ++- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/indexer-certs-creator/Dockerfile b/indexer-certs-creator/Dockerfile index 58b2583f..b9772abf 100644 --- a/indexer-certs-creator/Dockerfile +++ b/indexer-certs-creator/Dockerfile @@ -1,7 +1,7 @@ # Wazuh Docker Copyright (C) 2017, Wazuh Inc. (License GPLv2) -FROM ubuntu:focal +FROM amazonlinux:2023 -RUN apt-get update && apt-get install openssl curl -y +RUN yum update -y && yum install openssl curl-minimal -y WORKDIR / diff --git a/indexer-certs-creator/config/entrypoint.sh b/indexer-certs-creator/config/entrypoint.sh index fa098c50..648c9f02 100644 --- a/indexer-certs-creator/config/entrypoint.sh +++ b/indexer-certs-creator/config/entrypoint.sh @@ -8,29 +8,35 @@ ## Variables CERT_TOOL=wazuh-certs-tool.sh PASSWORD_TOOL=wazuh-passwords-tool.sh -PACKAGES_URL=https://packages.wazuh.com/4.14/ -PACKAGES_DEV_URL=https://packages-dev.wazuh.com/4.14/ +PACKAGES_URL=https://packages.wazuh.com/$CERT_TOOL_VERSION/ +PACKAGES_DEV_URL=https://packages-dev.wazuh.com/$CERT_TOOL_VERSION/ -## Check if the cert tool exists in S3 buckets -CERT_TOOL_PACKAGES=$(curl --silent --head --location --output /dev/null --write-out "%{http_code}" "$PACKAGES_URL$CERT_TOOL") -CERT_TOOL_PACKAGES_DEV=$(curl --silent --head --location --output /dev/null --write-out "%{http_code}" "$PACKAGES_DEV_URL$CERT_TOOL") +OUTPUT_FILE="/$CERT_TOOL" -## If cert tool exists in some bucket, download it, if not exit 1 -if [ "$CERT_TOOL_PACKAGES" = "200" ]; then - curl -o $CERT_TOOL $PACKAGES_URL$CERT_TOOL -s - echo "The tool to create the certificates exists in the in Packages bucket" -elif [ "$CERT_TOOL_PACKAGES_DEV" = "200" ]; then - curl -o $CERT_TOOL $PACKAGES_DEV_URL$CERT_TOOL -s - echo "The tool to create the certificates exists in Packages-dev bucket" +download_package() { + local url=$1 + echo "Checking $url$CERT_TOOL ..." + if curl -fsSL "$url$CERT_TOOL" -o "$OUTPUT_FILE"; then + echo "Downloaded $CERT_TOOL from $url" + return 0 + else + return 1 + fi +} + +# Try first the prod URL, if it fails try the dev URL +if download_package "$PACKAGES_URL"; then + : +elif download_package "$PACKAGES_DEV_URL"; then + : else - echo "The tool to create the certificates does not exist in any bucket" - echo "ERROR: certificates were not created" - exit 1 + echo "The tool to create the certificates does not exist in any bucket" + echo "ERROR: certificates were not created" + exit 1 fi cp /config/certs.yml /config.yml - -chmod 700 /$CERT_TOOL +chmod 700 "$OUTPUT_FILE" ############################################################################## # Creating Cluster certificates diff --git a/multi-node/generate-indexer-certs.yml b/multi-node/generate-indexer-certs.yml index 3142ab1a..88927593 100644 --- a/multi-node/generate-indexer-certs.yml +++ b/multi-node/generate-indexer-certs.yml @@ -1,8 +1,10 @@ # Wazuh App Copyright (C) 2017, Wazuh Inc. (License GPLv2) services: generator: - image: wazuh/wazuh-certs-generator:0.0.2 + image: wazuh/wazuh-certs-generator:0.0.3 hostname: wazuh-certs-generator + environment: + - CERT_TOOL_VERSION=4.14 volumes: - ./config/wazuh_indexer_ssl_certs/:/certificates/ - ./config/certs.yml:/config/certs.yml \ No newline at end of file diff --git a/single-node/generate-indexer-certs.yml b/single-node/generate-indexer-certs.yml index b7b7efb6..a941280f 100644 --- a/single-node/generate-indexer-certs.yml +++ b/single-node/generate-indexer-certs.yml @@ -1,8 +1,10 @@ # Wazuh App Copyright (C) 2017, Wazuh Inc. (License GPLv2) services: generator: - image: wazuh/wazuh-certs-generator:0.0.2 + image: wazuh/wazuh-certs-generator:0.0.3 hostname: wazuh-certs-generator + environment: + - CERT_TOOL_VERSION=4.14 volumes: - ./config/wazuh_indexer_ssl_certs/:/certificates/ - ./config/certs.yml:/config/certs.yml