node-certificates.asciidoc 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. [[node-certificates]]
  2. ==== Generating Node Certificates
  3. TLS requires X.509 certificates to perform encryption and authentication of the
  4. application that is being communicated with. In order for the communication
  5. between nodes to be truly secure, the certificates must be validated. The
  6. recommended approach for validating certificate authenticity in an {es} cluster
  7. is to trust the certificate authority (CA) that signed the certificate. By doing
  8. this, as nodes are added to your cluster they just need to use a certificate
  9. signed by the same CA and the node is automatically allowed to join the cluster.
  10. Additionally, it is recommended that the certificates contain subject alternative
  11. names (SAN) that correspond to the node's IP address and DNS name so that
  12. hostname verification can be performed.
  13. In order to simplify the process of generating certificates for the Elastic
  14. Stack, a command line tool, {ref}/certutil.html[`elasticsearch-certutil`] has been
  15. included with {xpack}. This tool takes care of generating a CA and signing
  16. certificates with the CA. `elasticsearch-certutil` can be used interactively or
  17. in a silent mode through the use of an input file. The `elasticsearch-certutil`
  18. tool also supports generation of certificate signing requests (CSR), so that a
  19. commercial- or organization-specific CA can be used to sign the certificates.
  20. For example:
  21. . Optional: Create a certificate authority for your {es} cluster.
  22. +
  23. --
  24. For example, use the `elasticsearch-certutil ca` command:
  25. [source,shell]
  26. ----------------------------------------------------------
  27. bin/elasticsearch-certutil ca
  28. ----------------------------------------------------------
  29. You can configure the cluster to trust all nodes that have a certificate that
  30. has been signed by this CA.
  31. The command outputs a single file, with a default name of `elastic-stack-ca.p12`.
  32. This file is a PKCS#12 keystore that contains the public certificate for your CA
  33. and the private key that is used to sign the certificates for each node.
  34. The `elasticsearch-certutil` command also prompts you for a password to protect
  35. the file and key. If you plan to add more nodes to your cluster in the future,
  36. retain a copy of the file and remember its password.
  37. --
  38. . Generate a certificate and private key for for each node in your cluster.
  39. +
  40. --
  41. For example, use the `elasticsearch-certutil cert` command:
  42. [source,shell]
  43. ----------------------------------------------------------
  44. bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12
  45. ----------------------------------------------------------
  46. The output is a single PKCS#12 keystore that includes the node certificate, node
  47. key, and CA certificate.
  48. You are also prompted for a password. You can enter a password for your
  49. certificate and key, or you can leave the password blank by pressing Enter.
  50. By default `elasticsearch-certutil` generates certificates that have no hostname
  51. information in them (that is, they do not have any Subject Alternative Name
  52. fields). This means that you can use the certificate for every node in your
  53. cluster, but you must turn off hostname verification as shown in the
  54. configuration below.
  55. If you want to use hostname verification within your cluster, run the
  56. `elasticsearch-certutil cert` command once for each of your nodes and provide
  57. the `--name`, `--dns` and `--ip` options.
  58. NOTE: You should secure the output files, since they contain the private keys
  59. for your instance.
  60. Alternatively, if you want to use a commercial or organization-specific CA,
  61. you can use the `elasticsearch-certutil csr` command to generate certificate
  62. signing requests (CSR) for the nodes in your cluster. For more information, see
  63. <<certutil>>.
  64. --
  65. . Copy the node certificate to the appropriate locations.
  66. +
  67. --
  68. Copy the applicable `.p12` file into a directory within the {es} configuration
  69. directory on each node. For example, `/home/es/config/certs`. There is no need
  70. to copy the CA file to this directory.
  71. For each additional Elastic product that you want to configure, copy the
  72. certificates to the relevant configuration directory.
  73. --
  74. NOTE: If you choose not to use `elasticsearch-certutil`, the certificates that
  75. you obtain must allow for both `clientAuth` and `serverAuth` if the extended key
  76. usage extension is present. The certificates need to be in PEM or PKCS#12
  77. format. Although not required, it is highly recommended that the certificate
  78. contain the DNS names and/or IP addresses of the node so that hostname
  79. verification can be used.