reusing your existing Certificate Authority (CA)
. By using the same internal CA that X-Pack was using, you ensure that all clients (like Kibana and applications) which already trust this CA continue to work seamlessly.searchguard.nodes_dn in elasticsearch.yml to enumerate which cert DNs are trusted for inter-node communication. This prevents unknown certificates (even if signed by the same CA) from joining the cluster without permission. Wildcards are also supported to make the configuration easier.elastic user) using username/password. In Search Guard, searchguard.authcz.admin_dn (instead of relying on the Elastic superuser).elasticsearch.yml use different keys. X-Pack uses settings under xpack.security.* (for example, xpack.security.transport.ssl.enabled, xpack.security.transport.ssl.keystore.path, etc.), whereas Search Guard uses searchguard.ssl.* settings for transport and HTTP (REST) TLS. We will see examples of these in the configuration step. Search Guard supports similar certificate formats (PEM, JKS, PKCS#12) as X-Pack, but it often prefers PEM files for configuration. If your X-Pack certificates are in a Java Keystore or PKCS#12, you can still use them with Search Guard by configuring keystore/truststore paths, but here we will use PEM for simplicity.searchguard.ssl.http.enabled: true, similar to X-Pack’s optional HTTP TLS. Search Guard allows using the same certificate for both layers or separate certificates for transport and HTTP per node. We’ll generate certificates for both layers for completeness.elasticsearch-certutil tool). This CA is what signed your Elasticsearch node certificates under X-Pack, and we want to reuse it for Search Guard.elastic-stack-ca.p12 or similar) containing the CA. By default, running elasticsearch-certutil the first time generates a CA and stores it in a P12 file.ca.crt) and possibly a PEM for the CA key (ca.key) if you used the --pem option with certutil or otherwise extracted them. In X-Pack, you might not have needed the CA private key on disk if you only provided signed certs to Elasticsearch, but for Search Guard’s certificate generation, you'll need the CA’s private key available.elastic-stack-ca.p12 is your CA keystore and you know its password, you can run: openssl pkcs12 -in elastic-stack-ca.p12 -cacerts -nokeys -out xpack-ca.pem
openssl pkcs12 -in elastic-stack-ca.p12 -nocerts -nodes -out xpack-ca.key
-nodes flag writes it without encryption for now; you can omit -nodes to keep it encrypted, but then you'll need to supply a password in the next steps). The output files are xpack-ca.pem (CA cert) and xpack-ca.key (CA key). openssl pkcs8 -in xpack-ca.key -topk8 -nocrypt -out xpack-ca-pkcs8.key
-passout and omit -nocrypt to set a password. If you do set a password, remember it for the TLS tool config.xpack-ca.pem in a text editor or use OpenSSL to ensure it's the correct CA (look at the subject/issuer). Also verify xpack-ca.key is a valid private key (for example, openssl rsa -in xpack-ca.key -check if it's RSA, or openssl pkey command). wget https://maven.search-guard.com/search-guard-tlstool/com/floragunn/search-guard-tlstool/3.0.2/search-guard-tlstool-3.0.2.zip
unzip search-guard-tlstool-3.0.2.zip
cd search-guard-tlstool
tools/sgtlstool.sh (or .bat on Windows).tlsconfig.yml) that describes your CA and the certificates you need. We will include sections for the root CA, node certificates, and an admin certificate. Below is a template to illustrate the necessary sections:ca:
root:
dn: CN=Your X-Pack CA, O=YourOrg, L=YourCity, C=YourCountry
file: xpack-ca.pem
pkPassword: none
defaults:
validityDays: 730
pkPassword: auto
httpsEnabled: true
reuseTransportCertificatesForHttp: false
nodes:
- name: node1
dn: CN=node1.example.com,OU=IT,O=YourOrg,L=YourCity,C=YourCountry
dns:
- node1.example.com
- node1
ip:
- 10.0.0.11
- name: node2
dn: CN=node2.example.com,OU=IT,O=YourOrg,L=YourCity,C=YourCountry
dns:
- node2.example.com
- node2
ip:
- 10.0.0.12
clients:
- name: admin
dn: CN=admin,OU=IT,O=YourOrg,L=YourCity,C=YourCountry
admin: true
ca.root. The dn should match the Subject DN of your existing X-Pack CA (this is mainly for documentation; the tool will not regenerate it since we won't use the -ca flag). We specify file: xpack-ca.pem so the tool knows the filename of the CA certificate. xpack-ca.pem and xpack-ca.key files into the tool's output directory (by default, a folder named out/ in the tool directory). The tool will look for the CA cert and key when we run it in certificate generation mode. Also, set pkPassword to “none” if your CA key is unencrypted, or provide the password if it is encrypted (this tells the tool how to read the CA key).validityDays defines how long the new certificates should be valid (here 730 days = 2 years, adjust as needed).pkPassword is set to auto which means each generated certificate’s private key will be encrypted with a random password (the tool will output these passwords in a *.readme file). If you prefer to have no password on the new keys (for simpler config, at the cost of storing unencrypted keys), use none instead. Alternatively, you can specify a fixed password string if you want all keys to share a specific password.httpsEnabled: true ensures the tool will generate certificates for the HTTP/REST layer (HTTPS).reuseTransportCertificatesForHttp: false means the tool will create separate certificates for the transport layer and the HTTP layer for each node. This is the default behavior. With separate certificates, you could, for example, use a different CN or SAN for the public REST API endpoint if needed. If you prefer to use one certificate per node for both transport and REST (as X-Pack often did), set this to true to reuse the transport cert for HTTP.nodes:, list each node in your cluster. For each node:name is an identifier used for the output filenames. The tool will produce files like <name>.pem, <name>.key (for transport) and <name>_http.pem, <name>_http.key (for HTTP, if separate).dn is the Distinguished Name for the certificate’s subject. Typically you’d use the node’s fully qualified domain name (FQDN) as the CN, plus organization info. Make sure the CN or one of the SAN entries matches exactly what the node’s actual hostname is (especially if you enable hostname verification, discussed later).dns is a list of DNS names to include in the Subject Alternative Name (SAN) extension of the cert. Include any hostnames that clients or nodes will use to connect. At minimum this usually includes the node’s primary hostname. You can include multiple entries (e.g., an alias or short name).ip is a list of IP addresses to include in SAN if your nodes communicate via IP or clients might connect via IP address.clients:, we listed one entry for admin. This will produce a client certificate used for administrative tasks. We marked it with admin: true, which signals the TLS tool to indicate in the output config snippet that this certificate’s DN should be added to searchguard.authcz.admin_dn. We gave it CN=admin (you can choose another name/OU, but avoid using wildcards here – Search Guard will only accept an exact match for admin DNs). The tool will output admin.pem and admin.key.clients if you need, for example, separate certificates for Kibana or other applications. (Those would typically not have admin: true since they’re end-user clients, not administrators.)tlsconfig.yml configured and your CA files in place, we can run the TLS tool to generate the new certificates. Since we are reusing an existing CA, we will out/ directory (or the directory you plan to use as output) contains xpack-ca.pem and xpack-ca.key (named exactly as in the config file). Then run the tool in ./tools/sgtlstool.sh -c tlsconfig.yml -crt
-c tlsconfig.yml points the tool to your configuration file. Using the -crt flag without -ca tells the tool to create certificates using an xpack-ca.pem and xpack-ca.key, then generate the specified certificates.out/ directory (or the specified -t target directory if you used one). You should see files for each node and client:node1.pem – the certificate (with the node’s full certificate chain, including the CA if configured to include it).node1.key – the node’s private key (encrypted if you used a password like auto or a custom password in config; unencrypted if pkPassword: none).node1_http.pem and node1_http.key – the REST layer certificate and key (since we set reuseTransportCertificatesForHttp: false). These will have a similar subject but possibly different SAN usage (the tool often just duplicates the entries unless you specify differently).node1_elasticsearch_config_snippet.yml – a handy snippet of configuration that Search Guard generates for convenience. This YAML file contains the recommended elasticsearch.yml settings for this node’s certificates.admin.pem – the admin certificate (X.509 cert, likely with the CA chain).admin.key – the admin private key.root-ca.pem (which should be essentially the same as xpack-ca.pem you provided, possibly copied) and root-ca.key (same as your CA key) in the output if they were not already present. The tool might copy/rename them based on file: name. For example, if you set file: xpack-ca.pem, it might output xpack-ca.pem and xpack-ca.key in the directory (or simply use those as-is). Check that these exist and match your originals.root-ca.readme (containing any passwords generated for the CA if auto was used) and a client-certificates.readme containing the auto-generated passwords for each certificate's key (if you used auto for pkPassword). Open this file to retrieve the passwords for node1.key, node2.key, etc., and admin.key if any were set. Keep these passwords secure.xpack-ca.key or the password was wrong).elasticsearch.yml on each node to use Search Guard’s TLS settings.nodeN.pem, nodeN.key and nodeN_http.pem, nodeN_http.key if separate) to the respective Elasticsearch node’s configuration directory (usually the config/ folder). Protect the private keys with appropriate filesystem permissions (e.g., readable only by the Elasticsearch process owner).root-ca.pem or your xpack-ca.pem) to each node’s config directory (you might put it as config/certs/ca.pem for consistency). This will be used as the trust anchor for TLS.elasticsearch.yml changes:elasticsearch.yml and replace the X-Pack TLS settings with the Search Guard settings. Here’s an example of what to add/update:# Enable TLS for transport and HTTP:
searchguard.ssl.transport.enabled: true
searchguard.ssl.http.enabled: true
# Transport layer TLS settings:
searchguard.ssl.transport.pemcert_filepath: node1.pem
searchguard.ssl.transport.pemkey_filepath: node1.key
searchguard.ssl.transport.pemkey_password: "<password>" # if the node1.key is encrypted; omit if none
searchguard.ssl.transport.pemtrustedcas_filepath: ca.pem
# HTTP (REST) layer TLS settings:
searchguard.ssl.http.pemcert_filepath: node1_http.pem
searchguard.ssl.http.pemkey_filepath: node1_http.key
searchguard.ssl.http.pemkey_password: "<password>" # password for HTTP key if encrypted
searchguard.ssl.http.pemtrustedcas_filepath: certs/ca.pem
# Specify allowed node certificate DNs (from your generated certs):
searchguard.nodes_dn:
- CN=node1.example.com,OU=IT,O=YourOrg,L=YourCity,C=YourCountry
- CN=node2.example.com,OU=IT,O=YourOrg,L=YourCity,C=YourCountry
# Alternatice: Use wildcards in the DNs:
searchguard.nodes_dn:
- CN=*.example.com,OU=IT,O=YourOrg,L=YourCity,C=YourCountry
# Specify admin certificate DN(s) for administrative access:
searchguard.authcz.admin_dn:
- CN=admin,OU=IT,O=YourOrg,L=YourCity,C=YourCountry
searchguard.ssl.transport.enabled: true and searchguard.ssl.http.enabled: true.pemcert_filepath is the path (relative to the config/ directory) to the certificate file for this node.pemkey_filepath is the path to the private key file for this node.pemkey_password is needed if the key file is encrypted with a password. Use the password from the TLS tool (for example, from the readme or whatever you set in the config). If you left the keys unencrypted (pkPassword: none), you can omit these password settings.pemtrustedcas_filepath is the path to the CA certificate file that will be used to verify peers. Here we use the same CA for both transport and HTTP. If you had an intermediate CA in your chain, you could either include the whole chain in one PEM file or specify the appropriate trust anchors.searchguard.nodes_dn section is crucial in Search Guard. It lists the DNs of the certificates that are allowed as node certificates in the cluster. We list the subject DNs of CN=*.example.com,... to match all nodes in a domain).searchguard.authcz.admin_dn section lists the DN of the admin certificate. This should match the subject of the admin.pem we generated (in our example, “CN=admin,OU=IT,O=YourOrg,...”). This tells Search Guard which client certificate to treat as an “admin” for using sgadmin or the REST API with administrative privileges. Only exact matches are allowed here (no wildcards).xpack.security.*.ssl settings to avoid confusion, and ensure xpack.security.enabled is false or X-Pack security is disabled entirely (Search Guard replaces X-Pack security, so they cannot both be active). searchguard.ssl.transport.enforce_hostname_verification: false
searchguard.ssl.transport.resolve_hostname: false
elasticsearch.yml. This will skip these checks.CN/dns in the cert matches what the node’s hostname really is and that each node can resolve the other’s name. Generally, for production, it’s best to keep verification elasticsearch.ssl.certificateAuthorities: ["path/to/ca.pem"] configured (or you might have set elasticsearch.ssl.verificationMode to “certificate” or “full” along with providing the CA). Continue using the same CA file in Kibana’s configuration. Kibana will then trust the new node certificates since they are issued by the same CA. If you didn’t have TLS on HTTP before and are enabling it now, you will need to update Kibana’s config to use HTTPS and provide the CA so it can validate Elasticsearch’s cert.nodes_dn and admin_dn for Search Guard, and adjusted Kibana to continue trusting the same CA.

