# Kibana errors after changing encryptionKey - Failed to decrypt "apiKey" attribute: Unsupported state or unable to authenticate data

**URL:** <https://discuss.elastic.co/t/kibana-errors-after-changing-encryptionkey-failed-to-decrypt-apikey-attribute-unsupported-state-or-unable-to-authenticate-data/344492>\
**Category:** Elasticsearch\
**Created:** [October 5, 2023, 1:56pm UTC](https://discuss.elastic.co/t/kibana-errors-after-changing-encryptionkey-failed-to-decrypt-apikey-attribute-unsupported-state-or-unable-to-authenticate-data/344492 "2023-10-05T13:56:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PodarcisMuralis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/podarcismuralis/32/122606_2.png) [@PodarcisMuralis](https://discuss.elastic.co/u/PodarcisMuralis)\
**Post date:** [October 5, 2023, 1:56pm UTC](https://discuss.elastic.co/t/kibana-errors-after-changing-encryptionkey-failed-to-decrypt-apikey-attribute-unsupported-state-or-unable-to-authenticate-data/344492/1 "2023-10-05T13:56:34Z")

</div>

I use elasticstack 8.5.3 and have 2 Logstash, 5 ELS and 1 Kibana nodes.

I was cleaning the older kibana system indices ( upgraded from 7.17.7) and deleted .security\_7 index also and had to create all built in users again.

I had to also create new encryption key for kibana by using this :  
[kibana-encryption-keys](https://www.elastic.co/guide/en/kibana/8.5/kibana-encryption-keys.html)

```auto
xpack.security.encryptionKey: "xxx"
xpack.encryptedSavedObjects.encryptionKey: "xxx"
xpack.reporting.encryptionKey: "xxx"

```

But after that I keep getting this error:

```auto
Failed to decrypt "apiKey" attribute: Unsupported state or unable to authenticate data

```

or specifically

```auto
Error: Unable to decrypt attribute "apiKey"
    at loadRule (/../kibana-8.5.3/x-pack/plugins/alerting/server/task_runner/rule_loader.js:43:11)
    at TaskRunner.prepareToRun (/../kibana-8.5.3/x-pack/plugins/alerting/server/task_runner/task_runner.js:494:12)
    at TaskRunnerTimer.runWithTimer (/../kibana-8.5.3/x-pack/plugins/alerting/server/task_runner/task_runner_timer.js:57:20)
    at TaskRunner.run (/../kibana-8.5.3/x-pack/plugins/alerting/server/task_runner/task_runner.js:611:30)
    at TaskManagerRunner.run (/../kibana-8.5.3/x-pack/plugins/task_manager/server/task_running/task_runner.js:299:22)

```

It is flooding my logs.

I read this documentation: [xpack-security-secure-saved-objects](https://www.elastic.co/guide/en/kibana/8.5/xpack-security-secure-saved-objects.html)

If I try to use just

```auto
xpack.encryptedSavedObjects:
  encryptionKey: "newKey"
  keyRotation:
    decryptionOnlyKeys: ["oldKey"]

```

I get this error:

```auto
Re-authentication can not be handled

```

I deleted all saved objects on kibana.  
I do not have any rules, alers etc.  
It is just empty kibana but still get these errors.  
I also deleted old version indices  
.kibana\_7  
.kibana\_task\_manager\_7  
.kibana\_event\_log\_7  
but still get this error.

Is this is a kibana bug as stated here?  
["unable to decrypt" error](https://github.com/elastic/kibana/issues/110792)

---

<div class="post-metadata">

**Author:** ![PodarcisMuralis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/podarcismuralis/32/122606_2.png) [@PodarcisMuralis](https://discuss.elastic.co/u/PodarcisMuralis)\
**Post date:** [October 5, 2023, 2:21pm UTC](https://discuss.elastic.co/t/kibana-errors-after-changing-encryptionkey-failed-to-decrypt-apikey-attribute-unsupported-state-or-unable-to-authenticate-data/344492/2 "2023-10-05T14:21:07Z")

</div>

After spending a day on this problem I found out the issue.

I have 2 Kibana Spaces: Default and Custom.  
I was checking the rules and alerts wrongly on Custom.  
But I had many rules on Default Spaces.  
So I changed to Default Space.  
Stack Management - Rules and Connectors - \> Rules  
Click on the 3 dots on the right side of the rules.  
Click on the Update API Key.  
It worked like a magic.

I have these settings in kibana.yml

```auto
xpack.security.encryptionKey: "newKey"
xpack.encryptedSavedObjects.encryptionKey: "newKey"
xpack.reporting.encryptionKey: "newKey"

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 2, 2023, 2:21pm UTC](https://discuss.elastic.co/t/kibana-errors-after-changing-encryptionkey-failed-to-decrypt-apikey-attribute-unsupported-state-or-unable-to-authenticate-data/344492/3 "2023-11-02T14:21:34Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
