update-tls-certificates.asciidoc 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768
  1. [[update-node-certs]]
  2. == Updating node security certificates
  3. You might need to update your TLS certificates if your current node
  4. certificates expire soon, you're adding new nodes to your secured cluster, or
  5. a security breach has broken the trust of your certificate chain. Use the
  6. <<security-api-ssl,SSL certificate>> API to check when your certificates are
  7. expiring.
  8. In instances where you have access to the original Certificate Authority (CA) key and certificate that you used to sign your existing node certificates (and where you can still trust your CA), you can
  9. <<update-node-certs-same,use that CA to sign the new certificates>>.
  10. If you have to trust a new CA from your organization, or you need to generate
  11. a new CA yourself, you need to use this new CA to sign the new node
  12. certificates and instruct your nodes to trust the new CA. In this case, you'll
  13. <<update-node-certs-different,sign node certificates with your new CA>> and
  14. instruct your nodes to trust this certificate chain.
  15. Depending on which certificates are expiring, you might need to update the
  16. certificates for the transport layer, the HTTP layer, or both.
  17. Regardless of the scenario, {es} monitors the SSL resources for updates
  18. by default, on a five-second interval. You can just copy the new
  19. certificate and key files (or keystore) into the {es} configuration directory
  20. and your nodes will detect the changes and reload the keys and certificates.
  21. Because {es} doesn't reload the `elasticsearch.yml` configuration,
  22. you must use *the same file names* if you want to take advantage of automatic certificate and key reloading.
  23. If you need to update the `elasticsearch.yml` configuration or change
  24. passwords for keys or keystores that are stored in the
  25. <<secure-settings,secure settings>>, then you must complete a
  26. <<use-rolling-restarts,rolling restart>>. {es} will not automatically reload changes for
  27. passwords stored in the secure settings.
  28. [[use-rolling-restarts]]
  29. .Rolling restarts are preferred
  30. ****
  31. While it's possible to do an in-place update for security certificates, using
  32. a <<restart-cluster-rolling,rolling restart>> on your cluster is safer. An in-place update avoids some
  33. complications of a rolling restart, but incurs the following risks:
  34. * If you use PEM files, your certificate and key are in separate files. You
  35. must update both files _simultaneously_ or the node might experience a temporary
  36. period where it cannot establish new connections.
  37. * Updating the certificate and key does not automatically force existing
  38. connections to refresh. This means that even if you make a mistake, a node can
  39. seem like it's functioning but only because it still has existing connections.
  40. It's possible that a node will be unable to connect with other nodes, rendering
  41. it unable to recover from a network outage or node restart.
  42. ****
  43. [[update-node-certs-same]]
  44. === Update certificates with the same CA
  45. ++++
  46. <titleabbrev>With the same CA</titleabbrev>
  47. ++++
  48. This procedure assumes that the you have access to the CA certificate and key
  49. that was originally generated (or otherwise held by your organization) and used
  50. to sign the node certificates currently in use. It also assumes that the
  51. clients connecting to {es} on the HTTP layer are configured to trust the CA
  52. certificate.
  53. If you have access to the CA used to sign your existing certificates, you only
  54. need to replace the certificates and keys for each node in your cluster. If you
  55. replace your existing certificates and keys on each node and use the same
  56. filenames, {es} reloads the files starts using the new certificates and keys.
  57. You don't have to restart each node, but doing so forces new TLS connections and is <<use-rolling-restarts,a recommended practice>> when updating certificates.
  58. Therefore, the following steps include a node restart after updating each
  59. certificate.
  60. The following steps provide instructions for generating new node certificates
  61. and keys for both the transport layer and the HTTP layer. You might only need
  62. to replace one of these layer's certificates depending on which of your
  63. certificates are expiring.
  64. [[cert-password-updates]]
  65. IMPORTANT: If your keystore is password protected, the password
  66. is stored in the {es} secure settings, _and_ the password needs to change, then
  67. you must perform a <<restart-cluster-rolling,rolling restart>> on your cluster.
  68. You must also use a different file name for the keystore so that {es} doesn't
  69. reload the file before the node is restarted.
  70. TIP: If your CA has changed, complete the steps in
  71. <<update-node-certs-different,update security certificates with a different CA>>.
  72. [[node-certs-same-transport]]
  73. ==== Generate a new certificate for the transport layer
  74. The following examples use PKCS#12 files, but the same steps apply to JKS
  75. keystores.
  76. . Open the `ES_PATH_CONF/elasticsearch.yml` file and check the names and
  77. locations of the keystores that are currently in use. You'll use the same names
  78. for your new certificate.
  79. +
  80. In this example, the keystore and truststore are pointing to different files.
  81. Your configuration might use the same file that contains the certificate and CA.
  82. In this case, include the path to that file for both the keystore and truststore.
  83. +
  84. [NOTE]
  85. ====
  86. These instructions assume that the provided certificate is signed by a trusted
  87. CA and the verification mode is set to `certificate`. This setting ensures that
  88. nodes to not attempt to perform hostname verification.
  89. ====
  90. +
  91. [source,yaml]
  92. ----
  93. xpack.security.transport.ssl.keystore.path: config/elastic-certificates.p12
  94. xpack.security.transport.ssl.keystore.type: PKCS12
  95. xpack.security.transport.ssl.truststore.path: config/elastic-stack-ca.p12
  96. xpack.security.transport.ssl.truststore.type: PKCS12
  97. xpack.security.transport.ssl.verification_mode: certificate
  98. ----
  99. . Using your existing CA, generate a keystore for your nodes. You must
  100. use the CA that was used to sign the certificate currently in use.
  101. +
  102. [source,shell]
  103. ----
  104. ./bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12
  105. ----
  106. +
  107. [%collapsible%open]
  108. .Command parameters
  109. ====
  110. `--ca <ca_file>`:: Name of the CA keystore used to sign your certificates.
  111. If you used the `elasticsearch-certutil` tool to generate your existing CA,
  112. the keystore name defaults to `elastic-stack-ca.p12`.
  113. ====
  114. a. Enter a name for the output file or accept the default of
  115. `elastic-certificates.p12`.
  116. b. When prompted, enter a password for the node keystore.
  117. . If you entered a password when creating the node keystore that is different
  118. from the current keystore password, run the following command to store the
  119. password in the {es} keystore:
  120. +
  121. --
  122. [source,shell]
  123. ----
  124. ./bin/elasticsearch-keystore add xpack.security.transport.ssl.keystore.secure_password
  125. ----
  126. --
  127. . [[start-rolling-restart,step 4]]On the current node in your cluster where you're updating the keystore,
  128. start a <<restart-cluster-rolling,rolling restart>>.
  129. +
  130. Stop at the step indicating *Perform any needed changes*, and then proceed to
  131. the next step in this procedure.
  132. . [[replace-keystores]]Replace your existing keystore with the new keystore,
  133. ensuring that the file names match. For example, `elastic-certificates.p12`.
  134. +
  135. IMPORTANT: If your
  136. <<cert-password-updates,keystore password is changing>>, then save the
  137. keystore with a new filename so that {es} doesn't attempt to reload the file
  138. before you update the password.
  139. . If you needed to save the new keystore with a new filename, update the
  140. `ES_PATH_CONF/elasticsearch.yml` file to use the filename of the new keystore.
  141. For example:
  142. +
  143. [source,yaml]
  144. ----
  145. xpack.security.transport.ssl.keystore.path: config/elastic-certificates.p12
  146. xpack.security.transport.ssl.keystore.type: PKCS12
  147. xpack.security.transport.ssl.truststore.path: config/elastic-stack-ca.p12
  148. xpack.security.transport.ssl.truststore.type: PKCS12
  149. ----
  150. . Start the node where you updated the keystore.
  151. . [[verify-keystore,step 8]](Optional) Use the
  152. <<security-api-ssl,SSL certificate API>> to verify that {es} loaded the new
  153. keystore.
  154. +
  155. --
  156. [source, console]
  157. ----
  158. GET /_ssl/certificates
  159. ----
  160. // TEST[skip:creates a lot of noise]
  161. --
  162. . If you're only updating certificates for the transport layer (and not the HTTP layer), then complete <<start-rolling-restart>> through <<verify-keystore>> one node at a time until you've updated all keystores in your cluster. You can then
  163. complete the remaining steps for a <<restart-cluster-rolling,rolling restart>>.
  164. +
  165. Otherwise, do not complete a rolling restart. Instead, proceed to the steps for
  166. generating a new certificate for the HTTP layer.
  167. [discrete]
  168. [[transport-layer-sameca-whatsnext]]
  169. ==== What's next?
  170. Well done! You've updated the keystore for the transport layer. You can also
  171. <<node-certs-same-http,update the keystore for the HTTP layer>> if
  172. necessary. If you're not updating the keystore for the HTTP layer, then you're
  173. all set.
  174. [[node-certs-same-http]]
  175. ==== Generate a new certificate for the HTTP layer
  176. Other components such as {kib} or any of the Elastic language clients verify
  177. this certificate when they connect to {es}.
  178. NOTE: If your organization has its own CA, you'll need to
  179. <<certutil-csr,generate Certificate Signing Requests (CSRs)>>. CSRs contain
  180. information that your CA uses to generate and sign a certificate.
  181. . On any node in your cluster where {es} is installed, run the {es} HTTP
  182. certificate tool.
  183. +
  184. [source,shell]
  185. ----
  186. ./bin/elasticsearch-certutil http
  187. ----
  188. +
  189. This command generates a `.zip` file that contains certificates and keys
  190. to use with {es} and {kib}. Each folder contains a `README.txt`
  191. explaining how to use these files.
  192. a. When asked if you want to generate a CSR, enter `n`.
  193. b. When asked if you want to use an existing CA, enter `y`.
  194. c. Enter the absolute path to your CA, such as the path to the
  195. `elastic-stack-ca.p12` file.
  196. d. Enter the password for your CA.
  197. e. Enter an expiration value for your certificate. You can enter the
  198. validity period in years, months, or days. For example, enter `1y` for one
  199. year.
  200. f. When asked if you want to generate one certificate per node, enter `y`.
  201. +
  202. Each certificate will have its own private key, and will be issued for a
  203. specific hostname or IP address.
  204. g. When prompted, enter the name of the first node in your cluster. It's
  205. helpful to use the same node name as the value for the `node.name`
  206. parameter in the `elasticsearch.yml` file.
  207. h. Enter all hostnames used to connect to your first node. These hostnames
  208. will be added as DNS names in the Subject Alternative Name (SAN) field in your certificate.
  209. +
  210. List every hostname and variant used to connect to your cluster over HTTPS.
  211. i. Enter the IP addresses that clients can use to connect to your node.
  212. j. Repeat these steps for each additional node in your cluster.
  213. . After generating a certificate for each of your nodes, enter a password for
  214. your private key when prompted.
  215. . Unzip the generated `elasticsearch-ssl-http.zip` file. This compressed file
  216. contains two directories; one each for {es} and {kib}. Within the `/elasticsearch`
  217. directory is a directory for each node that you specified with its own
  218. `http.p12` file. For example:
  219. +
  220. --
  221. [source,txt]
  222. ----
  223. /node1
  224. |_ README.txt
  225. |_ http.p12
  226. |_ sample-elasticsearch.yml
  227. ----
  228. [source,txt]
  229. ----
  230. /node2
  231. |_ README.txt
  232. |_ http.p12
  233. |_ sample-elasticsearch.yml
  234. ----
  235. [source,txt]
  236. ----
  237. /node3
  238. |_ README.txt
  239. |_ http.p12
  240. |_ sample-elasticsearch.yml
  241. ----
  242. --
  243. . If necessary, rename the `http.p12` file to match the name of your existing
  244. certificate for HTTP client communications. For example, `node1-http.p12`.
  245. . [[start-rolling-restart-http,step 5]]On the current node in your cluster where you're updating the keystore,
  246. start a <<restart-cluster-rolling,rolling restart>>.
  247. +
  248. Stop at the step indicating *Perform any needed changes*, and then proceed to
  249. the next step in this procedure.
  250. . Replace your existing keystore with the new keystore, ensuring that the
  251. file names match. For example, `node1-http.p12`.
  252. +
  253. IMPORTANT: If your
  254. <<cert-password-updates,keystore password is changing>>, then save the
  255. keystore with a new filename so that {es} doesn't attempt to reload the file
  256. before you update the password.
  257. . If you needed to save the new keystore with a new filename, update the
  258. `ES_PATH_CONF/elasticsearch.yml` file to use the filename of the new keystore.
  259. For example:
  260. +
  261. [source,yaml]
  262. ----
  263. xpack.security.http.ssl.enabled: true
  264. xpack.security.http.ssl.keystore.path: node1-http.p12
  265. ----
  266. . If your keystore password is changing, add the password for your private key
  267. to the secure settings in {es}.
  268. +
  269. [source,shell]
  270. ----
  271. ./bin/elasticsearch-keystore add xpack.security.http.ssl.keystore.secure_password
  272. ----
  273. . Start the node where you updated the keystore.
  274. +
  275. --
  276. Use the <<cat-nodes,cat nodes API>> to confirm that the node joined the cluster:
  277. [source,console]
  278. ----
  279. GET _cat/nodes
  280. ----
  281. --
  282. . [[verify-keystore-http,step 10]](Optional) Use the <<security-api-ssl,SSL certificate API>> to verify that {es} loaded the new keystore.
  283. +
  284. --
  285. [source, console]
  286. ----
  287. GET /_ssl/certificates
  288. ----
  289. // TEST[skip:creates a lot of noise]
  290. --
  291. . One node at a time, complete <<start-rolling-restart-http>> through
  292. <<verify-keystore-http>> until you've updated all keystores in your cluster.
  293. . Complete the remaining steps for a <<restart-cluster-rolling,rolling restart>>,
  294. beginning with the step to *Reenable shard allocation*.
  295. [[update-node-certs-different]]
  296. === Update security certificates with a different CA
  297. ++++
  298. <titleabbrev>With a different CA</titleabbrev>
  299. ++++
  300. If you have to trust a new CA from your organization, or you need to generate a new CA yourself, use this new CA to sign the new node certificates and instruct your nodes to trust the new CA.
  301. [[node-certs-different-transport]]
  302. ==== Generate a new certificate for the transport layer
  303. Create a new CA certificate, or get the CA certificate of your organization,
  304. and add it to your existing CA truststore. After you finish updating your certificates for all nodes, you can remove the old CA
  305. certificate from your truststore (but not before!).
  306. NOTE: The following examples use PKCS#12 files, but the same steps apply to JKS
  307. keystores.
  308. . Open the `ES_PATH_CONF/elasticsearch.yml` file and check the names and
  309. locations of the keystores that are currently in use. You'll use the same names
  310. for your new keystores.
  311. +
  312. In this example, the keystore and truststore are using different files.
  313. Your configuration might use the same file for both the keystore and the
  314. truststore.
  315. +
  316. [NOTE]
  317. ====
  318. These instructions assume that the provided certificate is signed by a trusted
  319. CA and the verification mode is set to `certificate`. This setting ensures that
  320. nodes to not attempt to perform hostname verification.
  321. ====
  322. +
  323. [source,yaml]
  324. ----
  325. xpack.security.transport.ssl.keystore.path: config/elastic-certificates.p12
  326. xpack.security.transport.ssl.keystore.type: PKCS12
  327. xpack.security.transport.ssl.truststore.path: config/elastic-stack-ca.p12
  328. xpack.security.transport.ssl.truststore.type: PKCS12
  329. xpack.security.transport.ssl.verification_mode: certificate
  330. ----
  331. . On *any* node in your cluster, generate a new CA certificate. You only need
  332. to complete this step one time. If you're using the CA certificate of your
  333. organization, then skip this step.
  334. +
  335. [source,shell]
  336. ----
  337. ./bin/elasticsearch-certutil ca --pem
  338. ----
  339. +
  340. [%collapsible%open]
  341. .Command parameters
  342. ====
  343. `--pem`:: Generates a directory containing a CA certificate and key in PEM
  344. format instead of PKCS#12.
  345. ====
  346. a. Enter a name for the compressed output file that will contain your
  347. certificate and key, or accept the default name of `elastic-stack-ca.zip`.
  348. b. Unzip the output file. The resulting directory contains a CA certificate
  349. (`ca.crt`) and a private key (`ca.key`).
  350. +
  351. --
  352. IMPORTANT: Keep these file in a secure location as they contain the private key
  353. for your CA.
  354. --
  355. . On *every* node in your cluster, import the new `ca.crt` certificate into your
  356. existing CA truststore. This step ensures that your cluster trusts the new CA
  357. certificate. This example uses the Java `keytool` utility to import the
  358. certificate into the `elastic-stack-ca.p12` CA truststore.
  359. +
  360. [source,shell]
  361. ----
  362. keytool -importcert -trustcacerts -noprompt -keystore elastic-stack-ca.p12 \
  363. -storepass <password> -alias new-ca -file ca.crt
  364. ----
  365. +
  366. [%collapsible%open]
  367. .Command parameters
  368. ====
  369. `-keystore`:: Name of the truststore that you are importing the new CA
  370. certificate into.
  371. `-storepass`:: Password for the CA truststore.
  372. `-alias`:: Name that you want to assign to the new CA certificate entry in the keystore.
  373. `-file`:: Name of the new CA certificate to import.
  374. ====
  375. . [[check-ca-truststore]] Check that the new CA certificate was added to your
  376. truststore.
  377. +
  378. [source,shell]
  379. ----
  380. keytool -keystore config/elastic-stack-ca.p12 -list
  381. ----
  382. When prompted, enter the password for the CA truststore.
  383. +
  384. The output should contain both the existing CA certificate and your new
  385. certificate. If you previously used the `elasticsearch-certutil` tool to
  386. generate your keystore, the alias of the old CA defaults to `ca` and the type of
  387. entry is `PrivateKeyEntry`.
  388. [discrete]
  389. [[node-certs-different-nodes]]
  390. ==== Generate a new certificate for each node in your cluster
  391. Now that your CA truststore is updated, use your new CA certificate to sign
  392. a certificate for your nodes.
  393. NOTE: If your organization has its own CA, you'll need to
  394. <<certutil-csr,generate Certificate Signing Requests (CSRs)>>. CSRs contain
  395. information that your CA uses to generate and sign a security certificate.
  396. . Using the new CA certificate and key, create a new certificate for your nodes.
  397. +
  398. [source,shell]
  399. ----
  400. ./bin/elasticsearch-certutil cert --ca-cert ca/ca.crt --ca-key ca/ca.key
  401. ----
  402. +
  403. [%collapsible%open]
  404. .Command parameters
  405. ====
  406. `--ca-cert`:: Specifies the path to your new CA certificate (`ca.crt`) in PEM
  407. format. You must also specify the `--ca-key` parameter.
  408. `--ca-key`:: Specifies the path to the private key (`ca.key`) for your CA
  409. certificate. You must also specify the `--ca-cert` parameter.
  410. ====
  411. a. Enter a name for the output file or accept the default of
  412. `elastic-certificates.p12`.
  413. b. When prompted, enter a password for your node certificate.
  414. . [[start-rolling-restart-newca,step 2]]On the current node in your cluster where
  415. you're updating the keystore, start a
  416. <<restart-cluster-rolling,rolling restart>>.
  417. +
  418. Stop at the step indicating *Perform any needed changes*, and then proceed to
  419. the next step in this procedure.
  420. . Replace your existing keystore with the new keystore, ensuring that the
  421. file names match. For example, `elastic-certificates.p12`.
  422. +
  423. IMPORTANT: If your
  424. <<cert-password-updates,keystore password is changing>>, then save the
  425. keystore with a new filename so that {es} doesn't attempt to reload the file
  426. before you update the password.
  427. . If you needed to save the new keystore with a new filename, update the
  428. `ES_PATH_CONF/elasticsearch.yml` file to use the filename of the new keystore.
  429. For example:
  430. +
  431. [source,yaml]
  432. ----
  433. xpack.security.transport.ssl.keystore.path: config/elastic-certificates.p12
  434. xpack.security.transport.ssl.keystore.type: PKCS12
  435. xpack.security.transport.ssl.truststore.path: config/elastic-stack-ca.p12
  436. xpack.security.transport.ssl.truststore.type: PKCS12
  437. ----
  438. . Start the node where you updated the keystore.
  439. . [[verify-keystore-newca,step 6]](Optional) Use the <<security-api-ssl,SSL certificate API>> to verify that {es} loaded the new keystore.
  440. +
  441. --
  442. [source, console]
  443. ----
  444. GET /_ssl/certificates
  445. ----
  446. // TEST[skip:creates a lot of noise]
  447. --
  448. . If you're only updating certificates for the transport layer (and not the HTTP
  449. layer), then complete <<start-rolling-restart-newca>> through
  450. <<verify-keystore-newca>> one node at a time until you've updated all keystores
  451. in your cluster. You can then complete the remaining steps for a
  452. <<restart-cluster-rolling,rolling restart>>.
  453. +
  454. Otherwise, do not complete a rolling restart. Instead, proceed to the steps for
  455. generating a new certificate for the HTTP layer.
  456. . (Optional) After replacing keystores on each node in your cluster,
  457. <<check-ca-truststore,list the certificates in your truststore>> and then remove
  458. the old CA certificate.
  459. +
  460. If you previously used the `elasticsearch-certutil` tool to generate your
  461. keystore, the alias of the old CA defaults to `ca` and the type of entry is
  462. `PrivateKeyEntry`.
  463. +
  464. [source,shell]
  465. ----
  466. keytool -delete -noprompt -alias ca -keystore config/elastic-stack-ca.p12 \
  467. -storepass <password>
  468. ----
  469. +
  470. [%collapsible%open]
  471. .Command parameters
  472. ====
  473. `-alias`:: Name of the keystore alias for the old CA certificate that you want to remove from your
  474. truststore.
  475. ====
  476. [discrete]
  477. [[transport-layer-newca-whatsnext]]
  478. ==== What's next?
  479. Well done! You've updated the keystore for the transport layer. You can also
  480. <<node-certs-different-http,update the keystore for the HTTP layer>> if
  481. necessary. If you're not updating the keystore for the HTTP layer, then you're
  482. all set.
  483. [[node-certs-different-http]]
  484. ==== Generate a new certificate for the HTTP layer
  485. You can generate certificates for the HTTP layer using your new CA certificate
  486. and private key. Other components such as {kib} or any of the Elastic language
  487. clients verify this certificate when they connect to {es}.
  488. NOTE: If your organization has its own CA, you'll need to
  489. <<certutil-csr,generate Certificate Signing Requests (CSRs)>>. CSRs contain
  490. information that your CA uses to generate and sign a security certificate
  491. instead of using self-signed certificates that the `elasticsearch-certutil` tool
  492. generates.
  493. .Update clients to trust the new CA
  494. ****
  495. After generating (but before using) new certificates for the HTTP layer, you
  496. need to go to all the clients that connect to {es} (such as {beats}, {ls}, and
  497. any language clients) and configure them to also trust the new CA (`ca.crt`)
  498. that you generated.
  499. This process is different for each client, so refer to your client's
  500. documentation for trusting certificates. You'll
  501. <<node-certs-different-kibana,update HTTP encryption between {kib} and {es}>>
  502. after generating the necessary certificates in this procedure.
  503. ****
  504. . On any node in your cluster where {es} is installed, run the {es} HTTP
  505. certificate tool.
  506. +
  507. [source,shell]
  508. ----
  509. ./bin/elasticsearch-certutil http
  510. ----
  511. +
  512. This command generates a `.zip` file that contains certificates and keys
  513. to use with {es} and {kib}. Each folder contains a `README.txt`
  514. explaining how to use these files.
  515. a. When asked if you want to generate a CSR, enter `n`.
  516. b. When asked if you want to use an existing CA, enter `y`.
  517. c. Enter the absolute path to your *new* CA certificate, such as the path to
  518. the `ca.crt` file.
  519. d. Enter the absolute path to your new CA certificate private key, such as
  520. the path to the `ca.key` file.
  521. e. Enter an expiration value for your certificate. You can enter the
  522. validity period in years, months, or days. For example, enter `1y` for one
  523. year.
  524. f. When asked if you want to generate one certificate per node, enter `y`.
  525. +
  526. Each certificate will have its own private key, and will be issued for a
  527. specific hostname or IP address.
  528. g. When prompted, enter the name of the first node in your cluster. Use the
  529. same node name as the value for the `node.name` parameter in the
  530. `elasticsearch.yml` file.
  531. h. Enter all hostnames used to connect to your first node. These hostnames
  532. will be added as DNS names in the Subject Alternative Name (SAN) field in your certificate.
  533. +
  534. List every hostname and variant used to connect to your cluster over HTTPS.
  535. i. Enter the IP addresses that clients can use to connect to your node.
  536. j. Repeat these steps for each additional node in your cluster.
  537. . After generating a certificate for each of your nodes, enter a password for
  538. your keystore when prompted.
  539. . Unzip the generated `elasticsearch-ssl-http.zip` file. This compressed file
  540. contains one directory for both {es} and {kib}. Within the `/elasticsearch`
  541. directory is a directory for each node that you specified with its own
  542. `http.p12` file. For example:
  543. +
  544. --
  545. [source,txt]
  546. ----
  547. /node1
  548. |_ README.txt
  549. |_ http.p12
  550. |_ sample-elasticsearch.yml
  551. ----
  552. [source,txt]
  553. ----
  554. /node2
  555. |_ README.txt
  556. |_ http.p12
  557. |_ sample-elasticsearch.yml
  558. ----
  559. [source,txt]
  560. ----
  561. /node3
  562. |_ README.txt
  563. |_ http.p12
  564. |_ sample-elasticsearch.yml
  565. ----
  566. --
  567. . If necessary, rename each `http.p12` file to match the name of your existing
  568. certificate for HTTP client communications. For example, `node1-http.p12`.
  569. . [[start-rolling-restart-http-newca,step 5]]On the current node in your cluster where you're updating the keystore,
  570. start a <<restart-cluster-rolling,rolling restart>>.
  571. +
  572. Stop at the step indicating *Perform any needed changes*, and then proceed to
  573. the next step in this procedure.
  574. . Replace your existing keystore with the new keystore, ensuring that the
  575. file names match. For example, `node1-http.p12`.
  576. +
  577. IMPORTANT: If your
  578. <<cert-password-updates,keystore password is changing>>, then save the
  579. keystore with a new filename so that {es} doesn't attempt to reload the file
  580. before you update the password.
  581. . If you needed to save the new keystore with a new filename, update the
  582. `ES_PATH_CONF/elasticsearch.yml` file to use the filename of the new keystore.
  583. For example:
  584. +
  585. [source,yaml]
  586. ----
  587. xpack.security.http.ssl.enabled: true
  588. xpack.security.http.ssl.keystore.path: node1-http.p12
  589. ----
  590. . If your keystore password is changing, add the password for your private key
  591. to the secure settings in {es}.
  592. +
  593. [source,shell]
  594. ----
  595. ./bin/elasticsearch-keystore add xpack.security.http.ssl.keystore.secure_password
  596. ----
  597. . Start the node where you updated the keystore.
  598. +
  599. --
  600. Use the <<cat-nodes,cat nodes API>> to confirm that the node joined the cluster:
  601. [source,console]
  602. ----
  603. GET _cat/nodes
  604. ----
  605. --
  606. . [[verify-keystore-http-newca,step 10]](Optional) Use the <<security-api-ssl,SSL certificate API>> to verify that
  607. {es} loaded the new keystore.
  608. +
  609. --
  610. [source, console]
  611. ----
  612. GET /_ssl/certificates
  613. ----
  614. // TEST[skip:creates a lot of noise]
  615. --
  616. . One node at a time, complete <<start-rolling-restart-http-newca>> through
  617. <<verify-keystore-http-newca>> until you've updated all keystores in your cluster.
  618. . Complete the remaining steps for a <<restart-cluster-rolling,rolling restart>>,
  619. beginning with the step to *Reenable shard allocation*.
  620. [discrete]
  621. [[http-kibana-newca-whatsnext]]
  622. ==== What's next?
  623. Well done! You've updated the keystore for the HTTP layer. You can now
  624. <<node-certs-different-kibana,update encryption between {kib} and {es}>>.
  625. [[node-certs-different-kibana]]
  626. ==== Update encryption between {kib} and {es}
  627. When you ran the `elasticsearch-certutil` tool with the `http` option, it
  628. created a `/kibana` directory containing an `elasticsearch-ca.pem` file. You
  629. use this file to configure {kib} to trust the {es} CA for the HTTP
  630. layer.
  631. . Copy the `elasticsearch-ca.pem` file to the {kib} configuration directory,
  632. as defined by the `KBN_PATH_CONF` path.
  633. +
  634. NOTE: `KBN_PATH_CONF` contains the path for the {kib} configuration files. If
  635. you installed {kib} using archive distributions (`zip` or `tar.gz`), the
  636. path defaults to `KBN_HOME/config`. If you used package distributions
  637. (Debian or RPM), the path defaults to `/etc/kibana`.
  638. . If you modified the filename for the `elasticsearch-ca.pem` file, edit
  639. `kibana.yml` and update the configuration to specify the location of the
  640. security certificate for the HTTP layer.
  641. +
  642. [source,yaml]
  643. ----
  644. elasticsearch.ssl.certificateAuthorities: KBN_PATH_CONF/elasticsearch-ca.pem
  645. ----
  646. . Restart {kib}.