Install and Setup ELK Stack<\/a><\/p>\n\n\n\nGenerate Elasticsearch Certificate Authority<\/h3>\n\n\n\n
So, you can use existing CA files generated automatically during install or create your own. <\/p>\n\n\n\n
Use Existing CA Files<\/h4>\n\n\n\n
When Elasticsearch 8.x is installed, it automatically enables and configures SSL\/TLS on both the HTTP and Transport layer. In the process, it generates CA and associated certificate files.<\/p>\n\n\n\n
The certificate files are stored in the \/etc\/elasticsearch\/certs\/<\/code><\/strong> directory.<\/p>\n\n\n\nls -1 \/etc\/elasticsearch\/certs\/<\/code><\/pre>\n\n\n\nhttp_ca.crt\nhttp.p12\ntransport.p12<\/code><\/pre>\n\n\n\n\n- http_ca.crt<\/strong>: This file contains the CA certificate for the Elasticsearch cluster. The CA certificate is used to verify the authenticity of the server certificates that are used by Elasticsearch nodes.<\/li>\n\n\n\n
- http.p12<\/strong>: The PKCS#12 file contains the server certificate and private key for the HTTP REST interface as well as the CA key.<\/li>\n\n\n\n
- transport.p12<\/strong>: The PKCS#12 file contains the client certificate and private key for the Transport client interface.<\/li>\n<\/ul>\n\n\n\n
Similarly, you can confirm the Elasticsearch configuration;<\/p>\n\n\n\n
less \/etc\/elasticsearch\/elasticsearch.yml<\/code><\/pre>\n\n\n\n...xpack.security.enabled: true\nxpack.security.enrollment.enabled: true\nxpack.security.http.ssl:\n enabled: true\n keystore.path: certs\/http.p12\nxpack.security.transport.ssl:\n enabled: true\n verification_mode: certificate\n keystore.path: certs\/transport.p12\n truststore.path: certs\/transport.p12\n...\n<\/code><\/pre>\n\n\n\nCreate Own Elasticsearch Certificate Authority<\/h4>\n\n\n\n
You can also create your own Elasticsearch CA. Hence, create a directory to store the certificates if you don\u2019t have one already.<\/p>\n\n\n\n
[[ -d \/etc\/elasticsearch\/es-certs ]] || mkdir \/etc\/elasticsearch\/es-certs<\/code><\/pre>\n\n\n\nGenerate the Certificate Authority (CA). By default, the CA is generated in PKCS#12 format. To generate them in the usual PEM format, pass --pem<\/code><\/strong> option.<\/p>\n\n\n\n\/usr\/share\/elasticsearch\/bin\/elasticsearch-certutil ca \\\n\t--pem \\\n\t--days 3650 \\\n\t--out \/etc\/elasticsearch\/es-certs\/elkstack-ca.zip\n<\/code><\/pre>\n\n\n\nYou can as well run the command as below and go through the prompts to generate the CA.<\/p>\n\n\n\n
\/usr\/share\/elasticsearch\/bin\/elasticsearch-certutil ca<\/code><\/pre>\n\n\n\nThe output zip file will contain individual files for the CA certificate and private key<\/p>\n\n\n\n
unzip -l \/etc\/elasticsearch\/es-certs\/elkstack-ca.zip<\/code><\/pre>\n\n\n\nArchive: \/etc\/elasticsearch\/es-certs\/elkstack-ca.zip\n Length Date Time Name\n--------- ---------- ----- ----\n 0 2023-11-24 16:38 ca\/\n 1200 2023-11-24 16:38 ca\/ca.crt\n 1675 2023-11-24 16:38 ca\/ca.key\n--------- -------\n 2875 3 files\n<\/code><\/pre>\n\n\n\nUnzip the file to get the CA required to generate the TLS certs.<\/p>\n\n\n\n
unzip -d \/etc\/elasticsearch\/es-certs \/etc\/elasticsearch\/es-certs\/elkstack-ca.zip<\/code><\/pre>\n\n\n\nArchive: \/etc\/elasticsearch\/es-certs\/elkstack-ca.zip\n creating: \/etc\/elasticsearch\/es-certs\/ca\/\n inflating: \/etc\/elasticsearch\/es-certs\/ca\/ca.crt \n inflating: \/etc\/elasticsearch\/es-certs\/ca\/ca.key \n<\/code><\/pre>\n\n\n\nYou should now have the ca\/ca.crt<\/strong> and ca\/ca.key<\/strong> in PEM format in the certs directory as shown above.<\/p>\n\n\n\nGenerating Wildcard SSL Certificates for Elasticsearch<\/h3>\n\n\n\n
Now that you have the CA certificates, you can generate and sign your HTTP certificates for the Elasticseach cluster.<\/p>\n\n\n\n
Using Existing CA to Generate Wildcard Certificates<\/h4>\n\n\n\n
If you want to use the CA certificates generated automatically during the installation of Elasticsearch to generate wildcard SSL\/TLS certificates for Elasticsearch HTTP interface, then proceed as follows.<\/p>\n\n\n\n
The \/etc\/elasticsearch\/certs\/http.p12<\/code><\/strong> file contains the server certificate and private key for the HTTP REST interface as well as the CA key.<\/p>\n\n\n\nHowever, this certificate will have its common name tied to the FQDN of the Elasticsearch node. This means that, if you have a cluster of nodes, it becomes a challenge on how to define Elasticsearch host name on the clients side if you want to sent logs to other nodes in the cluster.<\/p>\n\n\n\n
Example error when you try to connect to ES using Filebeat with the ES host not matching the exact ES node;<\/p>\n\n\n\n
\"message\":\"Failed to connect to backoff(elasticsearch(https:\/\/elk.kifarunix-demo.com:9200)): Get \\\"https:\/\/elk.kifarunix-demo.com:9200\\\": x509: certificate is valid for localhost, es-node01.kifarunix-demo.com, not elk.kifarunix-demo.com\"<\/strong><\/code><\/pre>\n\n\n\nTo generate wildcard SSL certificates from the existing CA, then you need to have the CA key.<\/p>\n\n\n\n
To get the CA key, you first need to retrieve the password that was used to protect it by executing the command below;<\/p>\n\n\n\n
\/usr\/share\/elasticsearch\/bin\/elasticsearch-keystore show xpack.security.http.ssl.keystore.secure_password<\/code><\/pre>\n\n\n\nThe command will print the Keystore password to standard output.<\/p>\n\n\n\n
Once you have the Keystore password, extract the CA key;<\/p>\n\n\n\n
openssl pkcs12 -in \/etc\/elasticsearch\/certs\/http.p12 -nodes<\/code><\/pre>\n\n\n\nYou will be prompted to enter the keystore password. Use the one retrieved above.<\/p>\n\n\n\n
The command will print keys each with a friendlyName, e.g, friendlyName: http_ca<\/code><\/strong> and friendlyName: http<\/code><\/strong>. <\/p>\n\n\n\nMAC: sha256, Iteration 10000\nMAC length: 32, salt length: 20\nPKCS7 Data\nShrouded Keybag: PBES2, PBKDF2, AES-256-CBC, Iteration 10000, PRF hmacWithSHA256\nBag Attributes\n friendlyName: http_ca\n localKeyID: 54 69 6D 65 20 31 37 30 30 37 35 38 35 31 39 32 33 39 \nKey Attributes: \n-----BEGIN PRIVATE KEY-----\nMIIJQQIBADANBgkqhkiG9w0BAQEFAASCCSswggknAgEAAoICAQC4y7ivLZ2UJJqp\n9xKj2q5yWO6RFSXoJo92fNtaVdfu4QULNLSn540Z4nGE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PBKDF2, AES-256-CBC, Iteration 10000, PRF hmacWithSHA256\nBag Attributes\n friendlyName: http\n localKeyID: 54 69 6D 65 20 31 37 30 30 37 35 38 35 31 39 32 36 32 \nKey Attributes: \n-----BEGIN PRIVATE KEY-----\nMIIJQwIBADANBgkqhkiG9w0BAQEFAASCCS0wggkpAgEAAoICAQC8kJYcWvgzcjRd\nqzMagpo3Op94hNDJ2AX2gKP3V5B1kX4tlbjZxWwGLknfBA\/Sz5fTkle8z\/P0dVCf\nSXuRM9e92RyQoP1gwrPXJ+McFmmgH\/NwETN5aOaTThGmNN756xdyZt9qnxI3pdMs\n\/KUJcBM428YqlY6xFxkFWNQvkNSgC+fujwwmSGUEJ2+WdLO1UUkW2PcanRGrFj5y\nVBu7KaQG9PZ6DFDcdclJQGFnxkJC6eEvWgUxA2vJQUxsfw3+NUdZeXoh3vZ+Nsvw\n0Qw2DP6lZQN3IULw4kgk\/Sf1tPwVVN93QfTtZK899QYwAywKjJQmkCj9oTXQuZMb\nSZgf0ZMgLNpWlluRhUXxXf9GQcVbtL6kFWxxa22wGrWEmmDsd\/\/kn4b47rPKpmu4\niSGqS035xLXV+mutjWzDtZFRvzvI4a4\/va9Q4XCr3oACUDcgpHdOMpEreuaVt6o7\nJdF+W4Sn80FHpsLenfh36meQ4G5LjASF1pdzpMgPJRmz2PtO30afVAQivT3jOPuJ\nv\/szAdIwekTLCuFEPJ3nbCQ7osxIcKUB3z3Zbin7Rr8njeev6WlvWiR3uKso29xG\n80sOLzmYhLGiv6xVR2ESR\/BJ+1TJXUiLn9GNBt1x8xZ3bzZGzFxIHub6nmx+7K9S\nFxJ1i8Y2sjN5bE1+2LBjKRLqhQuOjwIDAQABAoICAEzTJ6WD1q23MOic0KRTY5tu\n0fwbOKmTztIglS03ys5rqZnO71IiYiGeiFBJalz8YSI89Gwj2YPWrDNJkAOXuKVL\nqJywSqs6iGT3hksyQnSPr\/IPwAYOHCsV2pD554KxKotcqFfbWWO8tu4UPPU8aUh4\nGiP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RLhV6JNCaUZAr8jxnShyz2y4N5ZJYToOp20QT5BB5z2uRdtb9Q\nLrXnUNXS07bOVrBhYoi7pNbrvfiGrbrZ5aInn+NVSKy7Mkav7VaiwfhxMBwhD0kj\nesbwv62ZEoAziXeW95iQxvprroZgEAgUsyZJ\/cHilJ4c5YIkv2en21pGcGEtoWpv\nLc00BYUVRYhNU3H1h6CRQkbnHsNB5X4=\n-----END PRIVATE KEY-----\nPKCS7 Encrypted data: PBES2, PBKDF2, AES-256-CBC, Iteration 10000, PRF hmacWithSHA256\nCertificate bag\nBag Attributes\n friendlyName: http_ca\n localKeyID: 54 69 6D 65 20 31 37 30 30 37 35 38 35 31 39 32 33 39 \nsubject=CN = Elasticsearch security auto-configuration HTTP CA\nissuer=CN = Elasticsearch security auto-configuration HTTP CA\n-----BEGIN CERTIFICATE-----\nMIIFWjCCA0KgAwIBAgIVAO1DvGHBpzPO5OFYO\/ofbzwF\/j0VMA0GCSqGSIb3DQEB\nCwUAMDwxOjA4BgNVBAMTMUVsYXN0aWNzZWFyY2ggc2VjdXJpdHkgYXV0by1jb25m\naWd1cmF0aW9uIEhUVFAgQ0EwHhcNMjMxMTIzMTY1NTE4WhcNMjYxMTIyMTY1NTE4\nWjA8MTowOAYDVQQDEzFFbGFzdGljc2VhcmNoIHNlY3VyaXR5IGF1dG8tY29uZmln\ndXJhdGlvbiBIVFRQIENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA\nuMu4ry2dlCSaqfcSo9qucljukRUl6CaPdnzbWlXX7uEFCzS0p+eNGeJxhPqY5D9b\ntefx+Zhc0C0ENKzb6GVMRoM5ji5qPHl7GN4soeUN7LlTX2GN7\/s05hWw+gO3\/OzC\niy0lOnntqI3RZTik+o9NA4Jqmj2LqnegmGOxT9v92rAIkmQvaOPEaZb5EkQceB3W\nu0qTgM5TwxoHJr51kKn9DXfkx+2PDNgp\/v\/\/eWFbjTi9N5Gl3qGYsYzyt81qWAnO\np1UUJEeXvYoW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DilcGLbKyCzhSAqvmrA7wSQOGgtlnDaSygNf2HK5nI2ieaHpB\neD6RLuQG2KsRkwaZqCBAHmT2MJgygFnPWz+AJ3CTPJdeEoP9Bm9iJtksdDLk7nRz\n1JTCcSXXSYpa43Xaxt8UaBocuU8KKZbwiKWy7b\/LyBML5fWY91QXDeet7iVhtb5U\nACF5KnFSKyPDtqZ6bRfdPJkNltjsefipnWUl5RC7\n-----END CERTIFICATE-----\nCertificate bag\nBag Attributes\n friendlyName: http\n localKeyID: 54 69 6D 65 20 31 37 30 30 37 35 38 35 31 39 32 36 32 \nsubject=CN = es-node01.kifarunix-demo.com\nissuer=CN = Elasticsearch security auto-configuration HTTP CA\n-----BEGIN CERTIFICATE-----\nMIIFuTCCA6GgAwIBAgIUOhxStWo2WwpeI1a+BX\/kXwF74cIwDQYJKoZIhvcNAQEL\nBQAwPDE6MDgGA1UEAxMxRWxhc3RpY3NlYXJjaCBzZWN1cml0eSBhdXRvLWNvbmZp\nZ3VyYXRpb24gSFRUUCBDQTAeFw0yMzExMjMxNjU1MTlaFw0yNTExMjIxNjU1MTla\nMCcxJTAjBgNVBAMTHGVzLW5vZGUwMS5raWZhcnVuaXgtZGVtby5jb20wggIiMA0G\nCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC8kJYcWvgzcjRdqzMagpo3Op94hNDJ\n2AX2gKP3V5B1kX4tlbjZxWwGLknfBA\/Sz5fTkle8z\/P0dVCfSXuRM9e92RyQoP1g\nwrPXJ+McFmmgH\/NwETN5aOaTThGmNN756xdyZt9qnxI3pdMs\/KUJcBM428YqlY6x\nFxkFWNQvkNSgC+fujwwmSGUEJ2+WdLO1UUkW2PcanRGrFj5yVBu7KaQG9PZ6DFDc\ndclJQGFnxkJC6eEvWgUxA2vJQUxsfw3+NUdZeXoh3vZ+Nsvw0Qw2DP6lZQN3IULw\n4kgk\/Sf1tPwVVN93QfTtZK899QYwAywKjJQmkCj9oTXQuZMbSZgf0ZMgLNpWlluR\nhUXxXf9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ESaATqfvh60xvpsY7QuZAhhj9BqKS1TKU6M9\nuoks7GTrgBMPKxN9eAOxG\/ed0K+\/J5abJAZr3SZ1YJEAMaLZE8jOGndl0x0XjzN8\n4qj7Lv303mMAxbqZbsI1IiaoQceuRr8JEfWBcbtNwoQhOjVM5n7H4qD\/AVUtHpR5\nms7GqsKZjI0zU11sQ2hN81vv1wkKHnWt8OrtHddhv3zyMGxqkXEAFnlPxy\/g2IAf\nurYWFXIwESQJ9+PoNXkZl1UFndjCXaduJgl5PlY=\n-----END CERTIFICATE-----\nCertificate bag\nBag Attributes\n friendlyName: CN=Elasticsearch security auto-configuration HTTP CA\nsubject=CN = Elasticsearch security auto-configuration HTTP CA\nissuer=CN = Elasticsearch security auto-configuration HTTP CA\n-----BEGIN CERTIFICATE-----\nMIIFWjCCA0KgAwIBAgIVAO1DvGHBpzPO5OFYO\/ofbzwF\/j0VMA0GCSqGSIb3DQEB\nCwUAMDwxOjA4BgNVBAMTMUVsYXN0aWNzZWFyY2ggc2VjdXJpdHkgYXV0by1jb25m\naWd1cmF0aW9uIEhUVFAgQ0EwHhcNMjMxMTIzMTY1NTE4WhcNMjYxMTIyMTY1NTE4\nWjA8MTowOAYDVQQDEzFFbGFzdGljc2VhcmNoIHNlY3VyaXR5IGF1dG8tY29uZmln\ndXJhdGlvbiBIVFRQIENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA\nuMu4ry2dlCSaqfcSo9qucljukRUl6CaPdnzbWlXX7uEFCzS0p+eNGeJxhPqY5D9b\ntefx+Zhc0C0ENKzb6GVMRoM5ji5qPHl7GN4soeUN7LlTX2GN7\/s05hWw+gO3\/OzC\niy0lOnntqI3RZTik+o9NA4Jqmj2LqnegmGOxT9v92rAIkmQvaOPEaZb5EkQceB3W\nu0qTgM5TwxoHJr51kKn9DXfkx+2PDNgp\/v\/\/eWFbjTi9N5Gl3qGYsYzyt81qWAnO\np1UUJEeXvYoW31lggT7SaupykZGV1gqRPFbBMCND3f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tlnDaSygNf2HK5nI2ieaHpB\neD6RLuQG2KsRkwaZqCBAHmT2MJgygFnPWz+AJ3CTPJdeEoP9Bm9iJtksdDLk7nRz\n1JTCcSXXSYpa43Xaxt8UaBocuU8KKZbwiKWy7b\/LyBML5fWY91QXDeet7iVhtb5U\nACF5KnFSKyPDtqZ6bRfdPJkNltjsefipnWUl5RC7\n-----END CERTIFICATE-----\n<\/code><\/pre>\n\n\n\nThe CA key will be the one under the friendlyName: http_ca<\/code><\/strong>. By the way, you can also confirm the common name of the certificate from the output above.<\/p>\n\n\n\nYou can copy the CA key (under the friendlyName: http_ca<\/code><\/strong>), anything between -----BEGIN PRIVATE KEY-----<\/strong><\/code> and -----END PRIVATE KEY-----<\/code><\/strong> and store it in a file of your choice, e.g \/etc\/elasticsearch\/certs\/http_ca_key.crt<\/code><\/strong>.<\/p>\n\n\n\nOnce you have the CA key, execute the command below to generate wildcard certificates. Answer the prompts accordingly.<\/p>\n\n\n\n
\/usr\/share\/elasticsearch\/bin\/elasticsearch-certutil http<\/code><\/pre>\n\n\n\n\n- Generate a CSR, enter
n<\/code>.<\/li>\n\n\n\n- Use an existing CA, enter
y<\/code>.<\/li>\n\n\n\n- Enter the absolute path to your new<\/strong> CA certificate, such as the path to the
\/etc\/elasticsearch\/certs\/http_ca.crt<\/code> file.<\/li>\n\n\n\n- Enter the absolute path to your new CA certificate private key, such as the path to the
ca.key<\/code> file.<\/li>\n\n\n\n- Enter an expiration value for your certificate. You can enter the validity period in years, months, or days. For example, enter
5y<\/code> for one year.<\/li>\n\n\n\n- When asked if you want to generate one certificate per node, enter n. Here, we need Wildcard SSL\/TLS certs.<\/li>\n\n\n\n
- When prompted, enter the hostnames, enter all hostnames used to connect to your first node. These hostnames will be added as DNS names in the Subject Alternative Name (SAN) field in your certificate. List every hostname and variant used to connect to your cluster over HTTPS. For the the wildcard certificates, then use a wildcard of your domain, e.g,
*.kifarunix-demo.com<\/code><\/strong>. Press ENTER double and confirm the changes<\/li>\n\n\n\n- Enter the IP addresses that clients can use to connect to your node. Just press Enter to leave blank.<\/li>\n\n\n\n
- Confirm if you need to make any changes, if not proceed.<\/li>\n\n\n\n
- Set keystore password to protect the keys.<\/li>\n\n\n\n
- Enter the filename into which to save lives.<\/li>\n<\/ul>\n\n\n\n
You should now see the certificate files archived in the filename you provided.<\/p>\n\n\n\n
unzip -l \/usr\/share\/elasticsearch\/elasticsearch-ssl-http.zip<\/code><\/pre>\n\n\n\nArchive: \/usr\/share\/elasticsearch\/elasticsearch-ssl-http.zip\n Length Date Time Name\n--------- ---------- ----- ----\n 0 2023-11-24 15:03 elasticsearch\/\n 1365 2023-11-24 15:03 elasticsearch\/README.txt\n 4452 2023-11-24 15:03 elasticsearch\/http.p12\n 850 2023-11-24 15:03 elasticsearch\/sample-elasticsearch.yml\n 0 2023-11-24 15:03 kibana\/\n 1306 2023-11-24 15:03 kibana\/README.txt\n 1915 2023-11-24 15:03 kibana\/elasticsearch-ca.pem\n 1057 2023-11-24 15:03 kibana\/sample-kibana.yml\n--------- -------\n 10945 8 files\n<\/code><\/pre>\n\n\n\nThe wildcard CA file for our domain is the one under Kibana directory in the archive above. You can use that with all clients sending data to Elasticsearch.<\/p>\n\n\n\n
The http.p12 will contain the server’s certificate and keys.<\/p>\n\n\n\n
You can extract to your preferred location. You will have two directories, elasticsearch and kibana, each containing the cert\/CA files and a README.txt<\/code> explaining how to use these files.<\/p>\n\n\n\nmkdir \/etc\/elasticsearch\/certs<\/code><\/pre>\n\n\n\nunzip -d \/etc\/elasticsearch\/certs\/ \/usr\/share\/elasticsearch\/elasticsearch-ssl-http.zip<\/code><\/pre>\n\n\n\nchown -R :elasticsearch \/etc\/elasticsearch\/certs\/<\/code><\/pre>\n\n\n\nConfigure Elasticsearch, in the cluster to use new wildcard certificates;<\/p>\n\n\n\n
vim \/etc\/elasticsearch\/elasticsearch.yml<\/code><\/pre>\n\n\n\n...\n# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents\nxpack.security.http.ssl:\n enabled: true\n# keystore.path: certs\/http.p12\n keystore.path: certs\/elasticsearch\/http.p12<\/strong>\n...\n<\/code><\/pre>\n\n\n\nSave and exit the file.<\/p>\n\n\n\n
Restart Elasticsearch.<\/p>\n\n\n\n
systemctl restart elasticsearch<\/code><\/pre>\n\n\n\nSimilarly, configure Filebeat, Logstash, Kibana or any other client connecting to Elasticsearch to use the new CA certificate.<\/p>\n\n\n\n
You can download the certificate directly on the client from the Elasticsearch using openssl command;<\/p>\n\n\n\n
openssl s_client -connect elk.kifarunix-demo.com:9200 -showcerts | sed -ne '\/-BEGIN CERTIFICATE-\/,\/-END CERTIFICATE-\/p'<\/code><\/pre>\n\n\n\nThe save whatever between the -----BEGIN CERTIFICATE-----<\/code> and -----END CERTIFICATE-----<\/code> in a file as ES CA certificate file.<\/p>\n\n\n\nYou can run certificate verification against the server. For example;<\/p>\n\n\n\n
openssl s_client -connect elk.kifarunix-demo.com:9200 -CAfile \/etc\/filebeat\/es-ca.crt<\/code><\/pre>\n\n\n\nYou should get verification is okay.<\/p>\n\n\n\n
subject=DC = com, CN = kifarunix-demo\n\nissuer=CN = Elasticsearch security auto-configuration HTTP CA\n\n---\nNo client certificate CA names sent\nPeer signing digest: SHA256\nPeer signature type: RSA-PSS\nServer Temp Key: X25519, 253 bits\n---\nSSL handshake has read 3065 bytes and written 400 bytes\nVerification: OK\n---\nNew, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384\nServer public key is 2048 bit\nSecure Renegotiation IS NOT supported\nCompression: NONE\nExpansion: NONE\nNo ALPN negotiated\nEarly data was not sent\nVerify return code: 0 (ok)\n\n<\/code><\/pre>\n\n\n\nUsing Newly Created CA to Generate Wildcard Certificates<\/h4>\n\n\n\n
Our newly generated CA certificate and the key are stored under \/etc\/elasticsearch\/es-certs\/ca\/<\/code><\/strong>.<\/p>\n\n\n\nTo generate the wildcard SSL\/TLS Elasticsearch certificates, you can use the \/usr\/share\/elasticsearch\/bin\/elasticsearch-certutil cert<\/code>.<\/p>\n\n\n\n\/usr\/share\/elasticsearch\/bin\/elasticsearch-certutil cert \\\n\t--name elkstack-certs \\\n\t--ca-cert \/etc\/elasticsearch\/es-certs\/ca\/ca.crt \\\n\t--ca-key \/etc\/elasticsearch\/es-certs\/ca\/ca.key \\\n\t--pem \\\n\t--dns '*.kifarunix-demo.com' \\\n\t--days 3650 \\\n\t--out \/etc\/elasticsearch\/es-certs\/elkstack-certs.zip\n<\/code><\/pre>\n\n\n\nIf you generated CA in PKCS12 format, then you will need to extract the CA key to allow you create the certificates using the CA.<\/p>\n\n\n\n
Once you have the certificates, you can install them accordingly.<\/p>\n\n\n\n
Note that if you set the password for your private key while generating the certificates, then you need to add the password to the keystore to the secure settings in Elasticsearch.<\/p>\n\n\n\n
\/usr\/share\/elasticsearch\/bin\/elasticsearch-keystore add xpack.security.http.ssl.keystore.secure_password<\/code><\/pre>\n\n\n\nEnsure the keystore password is same across the cluster<\/strong>!<\/p>\n\n\n\nSimilarly, configure your Elasticsearch to use the new CA. If you are using certificates in PEM format, then your Elasticsearch configuration will look like;<\/p>\n\n\n\n
xpack.security.http.ssl:\n enabled: true\n key: \/etc\/elasticsearch\/certs\/es-certs\/elkstack-certs.key\n certificate: \/etc\/elasticsearch\/certs\/es-certs\/elkstack-certs.crt\n certificate_authorities: \/etc\/elasticsearch\/certs\/ca\/ca.crt\n<\/code><\/pre>\n\n\n\nConfigure the clients to use the certificate accordingly.<\/p>\n\n\n\n
Using Commercial CA Signed Certificates<\/h3>\n\n\n\n
If you have wildcards certs from a commercial CA, then by all means, configure Elasticsreach as well as ES clients to use them.<\/p>\n\n\n\n
That brings us to a close of our guide on how to generate wildcard SSL certificates for Elasticsearch.<\/p>\n","protected":false},"excerpt":{"rendered":"
Is there an easy way to generate wildcard SSL certificates for Elasticsearch? Yes, definitely. The current Elasticsearch releases, Elasticsearch 8.x, when installed, the HTTP and<\/p>\n","protected":false},"author":10,"featured_media":19414,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[34,910,121,1187],"tags":[7321,7324,7323,7322],"class_list":["post-19403","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-security","category-elastic-stack","category-howtos","category-ssl-tls","tag-elasticsearch-wildcard-ssl","tag-generate-wildcard-ssl-for-elasticsearch","tag-use-wildcard-ssl-on-elk","tag-wildcard-ssl-certs-for-elasticsearch","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/19403"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=19403"}],"version-history":[{"count":12,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/19403\/revisions"}],"predecessor-version":[{"id":20870,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/19403\/revisions\/20870"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/19414"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=19403"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=19403"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=19403"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}