Certificates deployment

SSL certificates secure communication between Wazuh components and verify the identity of participating nodes. The Wazuh certificates tool generates the SSL/TLS certificates of a Wazuh deployment, including the root certificate authority (CA), node certificates, and administrative certificates. The installation guide uses the Wazuh certificates tool to create certificates. You can also use any other certificate generation method, such as OpenSSL. The Wazuh dashboard issues its own certificate at installation, so the dashboard node in config.yml is optional. See The Wazuh dashboard certificate.

Download the Wazuh certificates tool and save it as wazuh-certs-tool.sh in a working directory.

There are three kinds of certificates needed for the installation:

  • root-ca: This certificate is the one in charge of signing the rest of the certificates.

  • node: The node certificates are the ones needed for every Wazuh indexer node. They must include the node IP address.

  • admin: The admin certificate is a client certificate with special privileges needed for management and security-related tasks.

The node and admin certificates are created with the following additional information. The root CA has only the L, O, and OU values:

  • C: US

  • L: California

  • O: Wazuh

  • OU: Wazuh

  • CN: Name of the node

Save the config.yml template in the same directory as wazuh-certs-tool.sh, because the tool reads config.yml from its own directory. Edit config.yml and replace the node names and IP values with the corresponding names and IP addresses to create the SSL certificates. The <indexer-node-ip>, <wazuh-manager-ip>, and <dashboard-node-ip> values can be either IP addresses or DNS names. The Wazuh config.yml template can be downloaded here.

nodes:
  # Wazuh indexer nodes
  indexer:
    - name: indexer
      ip: "<indexer-node-ip>"
    #- name: indexer-2
    #  ip: "<indexer-node-ip>"
    #- name: indexer-3
    #  ip: "<indexer-node-ip>"

  # Wazuh manager nodes
  # If there is more than one Wazuh manager
  # node, each one must have a node_type
  manager:
    - name: manager
      ip: "<wazuh-manager-ip>"
    #  node_type: master
    #- name: manager-2
    #  ip: "<wazuh-manager-ip>"
    #  node_type: worker
    #- name: manager-3
    #  ip: "<wazuh-manager-ip>"
    #  node_type: worker

  # Wazuh dashboard nodes
  dashboard:
    - name: dashboard
      ip: "<dashboard-node-ip>"

  # ip and dns both accept a list, for a node reachable at more than one address.
  # Every item reaches the certificate of the node; the first one is the address
  # the components are configured with.
  #- name: manager-2
  #  ip:
  #    - "<wazuh-manager-ip>"
  #    - "<wazuh-manager-second-ip>"
  #  dns:
  #    - "<wazuh-manager-name>"

  # Optional. Only for a proxy that TERMINATES the agents' TLS session: it issues the
  # certificate that proxy serves, from the same root-ca the agents pin. A layer 4
  # passthrough load balancer terminates nothing and needs --agent-san with its
  # address instead, so that address reaches the listener certificate of every
  # manager node.
  #load_balancer:
  #  - name: lb
  #    dns:
  #      - "<load-balancer-name>"
  #    ip:
  #      - "<load-balancer-ip>"

Run the wazuh-certs-tool.sh script with the option -A to generate all the certificates after configuring the config.yml file.

# bash wazuh-certs-tool.sh -A

After you run the script, the wazuh-certificates directory holds the following files:

wazuh-certificates/
├── admin-key.pem
├── admin.pem
├── dashboard-key.pem
├── dashboard.pem
├── indexer-key.pem
├── indexer.pem
├── manager-apid-key.pem
├── manager-apid.pem
├── manager-key.pem
├── manager-remoted-key.pem
├── manager-remoted.pem
├── manager.pem
└── root-ca.pem

The script also creates a wazuh-ca directory next to it, with the root CA certificate and its key. Back up this directory: you need it to add nodes or renew certificates.

Additionally, this script allows the use of a pre-existing rootCA certificate. To use it, place root-ca.pem and root-ca.key in the wazuh-ca directory next to the script, then run the script with option -A. The script reads the root CA from that directory, or from the directory set in WAZUH_CA_DIR:

# install -d -m 0700 -o root -g root wazuh-ca
# install -m 0644 -o root -g root /path/to/root-ca.pem wazuh-ca/root-ca.pem
# install -m 0400 -o root -g root /path/to/root-ca.key wazuh-ca/root-ca.key
# bash wazuh-certs-tool.sh -A

The script creates the wazuh-certificates directory with the same files as in the previous example.

The Wazuh dashboard certificate

The Wazuh dashboard does not need the Wazuh certificates tool. At installation, it creates its own certificate authority (CA) and issues the certificate it serves to browsers. The files are in /etc/wazuh-dashboard:

  • ca/root-ca.pem and ca/root-ca.key: the Wazuh dashboard CA. Only root can read this directory.

  • export/ca.pem: a copy of the Wazuh dashboard CA certificate. Import it into your browsers to trust the Wazuh dashboard.

  • certs/dashboard.pem and certs/dashboard-key.pem: the certificate and key that the Wazuh dashboard serves.

  • certs/indexer-ca.pem and certs/manager-ca.pem: the CA certificates that the Wazuh dashboard uses to verify the Wazuh indexer and the Wazuh manager API.

Every file that the Wazuh dashboard reads must be owned by root, must not be writable by group or others, and must not be a symbolic link. The certs directory and its files belong to the wazuh-dashboard group, with modes 0750 and 0640. Otherwise, the Wazuh dashboard does not start.

Issuing a new Wazuh dashboard certificate

The certificate includes the host name and the IP addresses of the host, plus localhost, 127.0.0.1, and ::1. To set other names or addresses, add the following line to /etc/wazuh-dashboard/local.env. The list replaces the host name and the IP addresses, so include every name and address in use. The certificate always keeps localhost, 127.0.0.1, and ::1. If the file does not exist, create it owned by root with mode 0600.

WAZUH_DASHBOARD_CERT_SANS=<DNS_NAME>,<IP_ADDRESS>

Replace <DNS_NAME> and <IP_ADDRESS> with the names and addresses that users reach the Wazuh dashboard at, separated by commas. Then remove the current certificate, issue a new one, and restart the Wazuh dashboard:

# rm /etc/wazuh-dashboard/certs/dashboard.pem /etc/wazuh-dashboard/certs/dashboard-key.pem
# /usr/share/wazuh-dashboard/bin/resolve-credentials --install
# systemctl restart wazuh-dashboard

Using your own certificate authority

To issue the Wazuh dashboard certificate from your own CA, place its certificate and RSA private key in /etc/wazuh-dashboard/ca before you install the Wazuh dashboard. Replace <CA_CERTIFICATE> and <CA_KEY> with the full paths of your CA files:

# install -d -m 0750 -o root -g root /etc/wazuh-dashboard
# install -d -m 0700 -o root -g root /etc/wazuh-dashboard/ca
# install -m 0644 -o root -g root <CA_CERTIFICATE> /etc/wazuh-dashboard/ca/root-ca.pem
# install -m 0400 -o root -g root <CA_KEY> /etc/wazuh-dashboard/ca/root-ca.key

The installation issues the Wazuh dashboard certificate from this CA and publishes the CA certificate as /etc/wazuh-dashboard/export/ca.pem. The Wazuh dashboard keeps the CA files you placed.

On an installed Wazuh dashboard, replace the two files in /etc/wazuh-dashboard/ca the same way and remove /etc/wazuh-dashboard/ca/.wazuh-dashboard-bootstrap-ca. Then follow Issuing a new Wazuh dashboard certificate.

Removing the Wazuh dashboard RPM package deletes /etc/wazuh-dashboard/ca, including the private key. Back up the directory first.

Using a certificate issued elsewhere

You can serve a certificate from the Wazuh certificates tool or from your own public key infrastructure (PKI) instead of the issued one. Copy the certificate and its key over the issued pair, then restart the Wazuh dashboard. Replace <CERTIFICATE> and <KEY> with the full paths of your files:

# install -m 0640 -o root -g wazuh-dashboard <CERTIFICATE> /etc/wazuh-dashboard/certs/dashboard.pem
# install -m 0640 -o root -g wazuh-dashboard <KEY> /etc/wazuh-dashboard/certs/dashboard-key.pem
# systemctl restart wazuh-dashboard

For a pair from the Wazuh certificates tool, use dashboard.pem and dashboard-key.pem from the wazuh-certificates directory. Browsers then trust the CA that issued the pair, such as root-ca.pem from the same directory, instead of /etc/wazuh-dashboard/export/ca.pem. The Wazuh dashboard keeps this pair across restarts and upgrades.