1
0

certutil.asciidoc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. [role="xpack"]
  2. [testenv="gold+"]
  3. [[certutil]]
  4. == elasticsearch-certutil
  5. The `elasticsearch-certutil` command simplifies the creation of certificates for
  6. use with Transport Layer Security (TLS) in the Elastic Stack.
  7. [float]
  8. === Synopsis
  9. [source,shell]
  10. --------------------------------------------------
  11. bin/elasticsearch-certutil
  12. (
  13. (ca [--ca-dn <name>] [--days <n>] [--pem])
  14. | (cert ([--ca <file_path>] | [--ca-cert <file_path> --ca-key <file_path>])
  15. [--ca-dn <name>] [--ca-pass <password>] [--days <n>]
  16. [--dns <domain_name>] [--in <input_file>] [--ip <ip_addresses>]
  17. [--keep-ca-key] [--multiple] [--name <file_name>] [--pem])
  18. | (csr [--dns <domain_name>] [--in <input_file>] [--ip <ip_addresses>]
  19. [--name <file_name>])
  20. [-E <KeyValuePair>] [--keysize <bits>] [--out <file_path>]
  21. [--pass <password>]
  22. )
  23. [-h, --help] ([-s, --silent] | [-v, --verbose])
  24. --------------------------------------------------
  25. [float]
  26. === Description
  27. You can specify one of the following modes: `ca`, `cert`, `csr`. The
  28. `elasticsearch-certutil` command also supports a silent mode of operation to
  29. enable easier batch operations.
  30. [float]
  31. [[certutil-ca]]
  32. ==== CA mode
  33. The `ca` mode generates a new certificate authority (CA). By default, it
  34. produces a single PKCS#12 output file, which holds the CA certificate and the
  35. private key for the CA. If you specify the `--pem` parameter, the command
  36. generates a zip file, which contains the certificate and private key in PEM
  37. format.
  38. You can subsequently use these files as input for the `cert` mode of the command.
  39. [float]
  40. [[certutil-cert]]
  41. ==== CERT mode
  42. The `cert` mode generates X.509 certificates and private keys. By default, it
  43. produces a single certificate and key for use on a single instance.
  44. To generate certificates and keys for multiple instances, specify the
  45. `--multiple` parameter, which prompts you for details about each instance.
  46. Alternatively, you can use the `--in` parameter to specify a YAML file that
  47. contains details about the instances.
  48. An instance is any piece of the Elastic Stack that requires a TLS or SSL
  49. certificate. Depending on your configuration, {es}, Logstash, {kib}, and Beats
  50. might all require a certificate and private key. The minimum required
  51. information for an instance is its name, which is used as the common name for
  52. the certificate. The instance name can be a hostname value or a full
  53. distinguished name. If the instance name would result in an invalid file or
  54. directory name, you must also specify a file name in the `--name` command
  55. parameter or in the `filename` field in an input YAML file.
  56. You can optionally provide IP addresses or DNS names for each instance. If
  57. neither IP addresses nor DNS names are specified, the Elastic stack products
  58. cannot perform hostname verification and you might need to configure the
  59. `verfication_mode` security setting to `certificate` only. For more information
  60. about this setting, see <<security-settings>>.
  61. All certificates that are generated by this command are signed by a CA. You can
  62. provide your own CA with the `--ca` or `--ca-cert` parameters. Otherwise, the
  63. command automatically generates a new CA for you. For more information about
  64. generating a CA, see the <<certutil-ca,CA mode of this command>>.
  65. By default, the `cert` mode produces a single PKCS#12 output file which holds
  66. the instance certificate, the instance private key, and the CA certificate. If
  67. you specify the `--pem` parameter, the command generates PEM formatted
  68. certificates and keys and packages them into a zip file.
  69. If you specify the `--keep-ca-key`, `--multiple` or `--in` parameters,
  70. the command produces a zip file containing the generated certificates and keys.
  71. [float]
  72. [[certutil-csr]]
  73. ==== CSR mode
  74. The `csr` mode generates certificate signing requests (CSRs) that you can send
  75. to a trusted certificate authority to obtain signed certificates. The signed
  76. certificates must be in PEM or PKCS#12 format to work with {security}.
  77. By default, the command produces a single CSR for a single instance.
  78. To generate CSRs for multiple instances, specify the `--multiple` parameter,
  79. which prompts you for details about each instance. Alternatively, you can use
  80. the `--in` parameter to specify a YAML file that contains details about the
  81. instances.
  82. The `cert` mode produces a single zip file which contains the CSRs and the
  83. private keys for each instance. Each CSR is provided as a standard PEM
  84. encoding of a PKCS#10 CSR. Each key is provided as a PEM encoding of an RSA
  85. private key.
  86. [float]
  87. === Parameters
  88. `ca`:: Specifies to generate a new local certificate authority (CA). This
  89. parameter cannot be used with the `csr` or `cert` parameters.
  90. `cert`:: Specifies to generate new X.509 certificates and keys.
  91. This parameter cannot be used with the `csr` or `ca` parameters.
  92. `csr`:: Specifies to generate certificate signing requests. This parameter
  93. cannot be used with the `ca` or `cert` parameters.
  94. `--ca <file_path>`:: Specifies the path to an existing CA key pair
  95. (in PKCS#12 format). This parameter cannot be used with the `ca` or `csr` parameters.
  96. `--ca-cert <file_path>`:: Specifies the path to an existing CA certificate (in
  97. PEM format). You must also specify the `--ca-key` parameter. The `--ca-cert`
  98. parameter cannot be used with the `ca` or `csr` parameters.
  99. `--ca-dn <name>`:: Defines the _Distinguished Name_ (DN) that is used for the
  100. generated CA certificate. The default value is
  101. `CN=Elastic Certificate Tool Autogenerated CA`. This parameter cannot be used
  102. with the `csr` parameter.
  103. `--ca-key <file_path>`:: Specifies the path to an existing CA private key (in
  104. PEM format). You must also specify the `--ca-cert` parameter. The `--ca-key`
  105. parameter cannot be used with the `ca` or `csr` parameters.
  106. `--ca-pass <password>`:: Specifies the password for an existing CA private key
  107. or the generated CA private key. This parameter cannot be used with the `ca` or
  108. `csr` parameters.
  109. `--days <n>`:: Specifies an integer value that represents the number of days the
  110. generated certificates are valid. The default value is `1095`. This parameter
  111. cannot be used with the `csr` parameter.
  112. `--dns <domain_name>`:: Specifies a comma-separated list of DNS names. This
  113. parameter cannot be used with the `ca` parameter.
  114. `-E <KeyValuePair>`:: Configures a setting.
  115. `-h, --help`:: Returns all of the command parameters.
  116. `--in <input_file>`:: Specifies the file that is used to run in silent mode. The
  117. input file must be a YAML file. This parameter cannot be used with the `ca`
  118. parameter.
  119. `--ip <IP_addresses>`:: Specifies a comma-separated list of IP addresses. This
  120. parameter cannot be used with the `ca` parameter.
  121. `--keep-ca-key`:: When running in `cert` mode with an automatically-generated
  122. CA, specifies to retain the CA private key for future use.
  123. `--keysize <bits>`::
  124. Defines the number of bits that are used in generated RSA keys. The default
  125. value is `2048`.
  126. `--multiple`::
  127. Specifies to generate files for multiple instances. This parameter cannot be
  128. used with the `ca` parameter.
  129. `--name <file_name>`::
  130. Specifies the name of the generated certificate. This parameter cannot be used
  131. with the `ca` parameter.
  132. `--out <file_path>`:: Specifies a path for the output files.
  133. `--pass <password>`:: Specifies the password for the generated private keys.
  134. +
  135. Keys stored in PKCS#12 format are always password protected.
  136. +
  137. Keys stored in PEM format are password protected only if the
  138. `--pass` parameter is specified. If you do not supply an argument for the
  139. `--pass` parameter, you are prompted for a password.
  140. +
  141. If you want to specify a _blank_ password (without prompting), use
  142. `--pass ""` (with no `=`).
  143. `--pem`:: Generates certificates and keys in PEM format instead of PKCS#12. This
  144. parameter cannot be used with the `csr` parameter.
  145. `-s, --silent`:: Shows minimal output.
  146. `-v, --verbose`:: Shows verbose output.
  147. [float]
  148. === Examples
  149. The following command generates a CA certificate and private key in PKCS#12
  150. format:
  151. [source, sh]
  152. --------------------------------------------------
  153. bin/elasticsearch-certutil ca
  154. --------------------------------------------------
  155. You are prompted for an output filename and a password. Alternatively, you can
  156. specify the `--out` and `--pass` parameters.
  157. You can then generate X.509 certificates and private keys by using the new
  158. CA. For example:
  159. [source, sh]
  160. --------------------------------------------------
  161. bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12
  162. --------------------------------------------------
  163. You are prompted for the CA password and for an output filename and password.
  164. Alternatively, you can specify the `--ca-pass`, `--out`, and `--pass` parameters.
  165. By default, this command generates a file called `elastic-certificates.p12`,
  166. which you can copy to the relevant configuration directory for each Elastic
  167. product that you want to configure. For more information, see
  168. {xpack-ref}/ssl-tls.html[Setting Up TLS on a Cluster].
  169. [float]
  170. [[certutil-silent]]
  171. ==== Using `elasticsearch-certutil` in Silent Mode
  172. To use the silent mode of operation, you must create a YAML file that contains
  173. information about the instances. It must match the following format:
  174. [source, yaml]
  175. --------------------------------------------------
  176. instances:
  177. - name: "node1" <1>
  178. ip: <2>
  179. - "192.0.2.1"
  180. dns: <3>
  181. - "node1.mydomain.com"
  182. - name: "node2"
  183. ip:
  184. - "192.0.2.2"
  185. - "198.51.100.1"
  186. - name: "node3"
  187. - name: "node4"
  188. dns:
  189. - "node4.mydomain.com"
  190. - "node4.internal"
  191. - name: "CN=node5,OU=IT,DC=mydomain,DC=com"
  192. filename: "node5" <4>
  193. --------------------------------------------------
  194. <1> The name of the instance. This can be a simple string value or can be a
  195. Distinguished Name (DN). This is the only required field.
  196. <2> An optional array of strings that represent IP Addresses for this instance.
  197. Both IPv4 and IPv6 values are allowed. The values are added as Subject
  198. Alternative Names.
  199. <3> An optional array of strings that represent DNS names for this instance.
  200. The values are added as Subject Alternative Names.
  201. <4> The filename to use for this instance. This name is used as the name of the
  202. directory that contains the instance's files in the output. It is also used in
  203. the names of the files within the directory. This filename should not have an
  204. extension. Note: If the `name` provided for the instance does not represent a
  205. valid filename, then the `filename` field must be present.
  206. When your YAML file is ready, you can use the `elasticsearch-certutil` command
  207. to generate certificates or certificate signing requests. Simply use the `--in`
  208. parameter to specify the location of the file. For example:
  209. [source, sh]
  210. --------------------------------------------------
  211. bin/elasticsearch-certutil cert --silent --in instances.yml --out test1.zip --pass testpassword
  212. --------------------------------------------------
  213. This command generates a compressed `test1.zip` file. After you decompress the
  214. output file, there is a directory for each instance that was listed in the
  215. `instances.yml` file. Each instance directory contains a single PKCS#12 (`.p12`)
  216. file, which contains the instance certificate, instance private key, and CA
  217. certificate.
  218. You an also use the YAML file to generate certificate signing requests. For
  219. example:
  220. [source, sh]
  221. --------------------------------------------------
  222. bin/elasticsearch-certutil csr --silent --in instances.yml --out test2.zip --pass testpassword
  223. --------------------------------------------------
  224. This command generates a compressed file, which contains a directory for each
  225. instance. Each instance directory contains a certificate signing request
  226. (`*.csr` file) and private key (`*.key` file).