node-certificates.asciidoc 4.3 KB

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