Skip to content

Commit 90cb9ab

Browse files
f-gallandAlexRuiz7
andauthored
Setup certificates in Wazuh Indexer and Logstash containers (#166)
* Add certificate generator service * Add certificate config to docker compose file * Use secrets for certificates * Disable permission handling inside cert's generator entrypoint.sh * Back to using a bind mount for certs * Have entrypoint.sh generate certs with 1000:1000 ownership * Correct certificate permissions and bind mounting * Add security initialization variable to compose file * Fix permissions on certs generator entrypoint * Add cert generator config file * Remove old cert generator dir * Set indexer hostname right in pipeline file * Roll back commented code --------- Signed-off-by: Álex Ruiz <[email protected]> Co-authored-by: Álex Ruiz <[email protected]>
1 parent 349f634 commit 90cb9ab

File tree

4 files changed

+72
-38
lines changed

4 files changed

+72
-38
lines changed

integrations/.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ elastic
22
opensearch
33
splunk
44
common
5-
config
5+
config
6+
docker/certs
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
input {
22
opensearch {
3-
hosts => ["opensearch-node:9200"]
3+
hosts => ["wazuh.indexer:9200"]
44
user => "${INDEXER_USERNAME}"
55
password => "${INDEXER_PASSWORD}"
6-
ssl => false
6+
ssl => true
7+
ca_file => "/usr/share/logstash/root-ca.pem"
78
index => "wazuh-alerts-4.x-*"
89
query => '{
910
"query": {
@@ -20,15 +21,10 @@ input {
2021
}
2122

2223
output {
23-
24-
stdout { codec => rubydebug }
25-
26-
pipe
27-
{
28-
id => "securityLake"
29-
message_format => "%{_source}"
30-
ttl => "10"
31-
command => "/usr/bin/env python3 /usr/local/bin/stdin_to_securitylake.py -d"
32-
}
33-
24+
pipe {
25+
id => "securityLake"
26+
message_format => "%{_source}"
27+
ttl => "10"
28+
command => "/usr/bin/env python3 /usr/local/bin/stdin_to_securitylake.py -d"
29+
}
3430
}

integrations/docker/amazon-security-lake.yml

+45-24
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '3'
1+
version: "3.8"
22
name: "amazon-security-lake"
33
services:
44
events-generator:
@@ -7,22 +7,35 @@ services:
77
context: ../tools/events-generator
88
container_name: events-generator
99
depends_on:
10-
- wazuh.indexer
11-
networks:
12-
- net
13-
# TODO add healthcheck to indexer's service to avoid sending requests before API is ready.
14-
command: bash -c "sleep 10 && echo 'Ey, wake up!' && python run.py -a wazuh.indexer"
10+
wazuh.indexer:
11+
condition: service_healthy
12+
command: bash -c "python run.py -a wazuh.indexer"
1513

1614
wazuh.indexer:
17-
image: opensearchproject/opensearch:latest
15+
image: opensearchproject/opensearch:2.11.1
1816
container_name: wazuh.indexer
17+
depends_on:
18+
wazuh-certs-generator:
19+
condition: service_completed_successfully
1920
hostname: wazuh.indexer
21+
ports:
22+
- 9200:9200
2023
environment:
2124
# - cluster.name=opensearch-cluster
2225
- node.name=wazuh.indexer
2326
- discovery.type=single-node
2427
# - cluster.initial_cluster_manager_nodes=opensearch-node
2528
- bootstrap.memory_lock=true
29+
- "DISABLE_INSTALL_DEMO_CONFIG=true"
30+
- plugins.security.ssl.http.enabled=true
31+
- plugins.security.allow_default_init_securityindex=true
32+
- plugins.security.ssl.http.pemcert_filepath=/usr/share/opensearch/config/wazuh.indexer.pem
33+
- plugins.security.ssl.transport.pemcert_filepath=/usr/share/opensearch/config/wazuh.indexer.pem
34+
- plugins.security.ssl.http.pemkey_filepath=/usr/share/opensearch/config/wazuh.indexer-key.pem
35+
- plugins.security.ssl.transport.pemkey_filepath=/usr/share/opensearch/config/wazuh.indexer-key.pem
36+
- plugins.security.ssl.http.pemtrustedcas_filepath=/usr/share/opensearch/config/root-ca.pem
37+
- plugins.security.ssl.transport.pemtrustedcas_filepath=/usr/share/opensearch/config/root-ca.pem
38+
- plugins.security.authcz.admin_dn="CN=wazuh.indexer,OU=Wazuh,O=Wazuh,L=California, C=US"
2639
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
2740
ulimits:
2841
memlock:
@@ -31,29 +44,36 @@ services:
3144
nofile:
3245
soft: 65536
3346
hard: 65536
47+
healthcheck:
48+
test: curl -sku admin:admin https://localhost:9200/_cat/health | grep -q docker-cluster
49+
start_period: 10s
50+
start_interval: 3s
3451
volumes:
3552
- data:/usr/share/opensearch/data
36-
networks:
37-
- net
53+
- ./certs/wazuh.indexer.pem:/usr/share/opensearch/config/wazuh.indexer.pem
54+
- ./certs/wazuh.indexer-key.pem:/usr/share/opensearch/config/wazuh.indexer-key.pem
55+
- ./certs/root-ca.pem:/usr/share/opensearch/config/root-ca.pem
3856

3957
wazuh.dashboard:
40-
image: opensearchproject/opensearch-dashboards:latest # Make sure the version of opensearch-dashboards matches the version of opensearch installed on other nodes
58+
image: opensearchproject/opensearch-dashboards:2.11.1
4159
container_name: wazuh.dashboard
60+
depends_on:
61+
- wazuh.indexer
4262
hostname: wazuh.dashboard
4363
ports:
4464
- 5601:5601 # Map host port 5601 to container port 5601
4565
expose:
4666
- "5601" # Expose port 5601 for web access to OpenSearch Dashboards
4767
environment:
4868
OPENSEARCH_HOSTS: '["https://wazuh.indexer:9200"]' # Define the OpenSearch nodes that OpenSearch Dashboards will query
49-
networks:
50-
- net
51-
69+
5270
wazuh.integration.security.lake:
5371
image: wazuh/indexer-security-lake-integration
5472
build:
5573
context: ../amazon-security-lake
5674
container_name: wazuh.integration.security.lake
75+
depends_on:
76+
- wazuh.indexer
5777
hostname: wazuh.integration.security.lake
5878
environment:
5979
LOG_LEVEL: trace
@@ -68,12 +88,9 @@ services:
6888
- "9600:9600"
6989
volumes:
7090
- ../amazon-security-lake/logstash/pipeline:/usr/share/logstash/pipeline
71-
depends_on:
72-
- wazuh.indexer
73-
networks:
74-
- net
75-
command: tail -f /dev/null
76-
# command: /usr/share/logstash/bin/logstash -f /usr/share/logstash/pipeline/indexer-to-integrator.conf --path.settings /etc/logstash
91+
- ./certs/root-ca.pem:/usr/share/logstash/root-ca.pem
92+
# command: tail -f /dev/null
93+
command: /usr/share/logstash/bin/logstash -f /usr/share/logstash/pipeline/indexer-to-integrator.conf --path.settings /etc/logstash --config.reload.automatic
7794

7895
s3.ninja:
7996
image: scireum/s3-ninja:latest
@@ -83,12 +100,16 @@ services:
83100
- "9444:9000"
84101
volumes:
85102
- s3-data:/home/sirius/data
86-
networks:
87-
- net
103+
104+
wazuh-certs-generator:
105+
image: wazuh/wazuh-certs-generator:0.0.1
106+
hostname: wazuh-certs-generator
107+
container_name: wazuh-certs-generator
108+
entrypoint: sh -c "/entrypoint.sh; chown -R 1000:999 /certificates; chmod 740 /certificates; chmod 440 /certificates/*"
109+
volumes:
110+
- ./certs/:/certificates/
111+
- ./config/certs.yml:/config/certs.yml
88112

89113
volumes:
90114
data:
91115
s3-data:
92-
93-
networks:
94-
net:

integrations/docker/config/certs.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
nodes:
2+
# Wazuh indexer server nodes
3+
indexer:
4+
- name: wazuh.indexer
5+
ip: wazuh.indexer
6+
7+
# Wazuh server nodes
8+
# Use node_type only with more than one Wazuh manager
9+
server:
10+
- name: wazuh.manager
11+
ip: wazuh.manager
12+
13+
# Wazuh dashboard node
14+
dashboard:
15+
- name: wazuh.dashboard
16+
ip: wazuh.dashboard

0 commit comments

Comments
 (0)