mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-02-14 03:09:39 +03:00
'Unsupported cipher or incorrect key length' when using generated APP_KEY via docker compose #5026
Closed
opened 2026-02-05 09:34:46 +03:00 by OVERLORD
·
10 comments
No Branch/Tag Specified
development
l10n_development
release
v25-12
llm_only
vectors
v25-11
docker_env
drawio_rendering
user_permissions
ldap_host_failover
svg_image
prosemirror
captcha_example
fix/video-export
v25.12.3
v25.12.2
v25.12.1
v25.12
v25.11.6
v25.11.5
v25.11.4
v24.11.4
v25.11.3
v25.11.2
v25.11.1
v25.11
v25.07.3
v25.07.2
v25.07.1
v25.07
v25.05.2
v25.05.1
v25.05
v25.02.5
v25.02.4
v25.02.3
v25.02.2
v25.02.1
v25.02
v24.12.1
v24.12
v24.10.3
v24.10.2
v24.10.1
v24.10
v24.05.4
v24.05.3
v24.05.2
v24.05.1
v24.05
v24.02.3
v24.02.2
v24.02.1
v24.02
v23.12.3
v23.12.2
v23.12.1
v23.12
v23.10.4
v23.10.3
v23.10.2
v23.10.1
v23.10
v23.08.3
v23.08.2
v23.08.1
v23.08
v23.06.2
v23.06.1
v23.06
v23.05.2
v23.05.1
v23.05
v23.02.3
v23.02.2
v23.02.1
v23.02
v23.01.1
v23.01
v22.11.1
v22.11
v22.10.2
v22.10.1
v22.10
v22.09.1
v22.09
v22.07.3
v22.07.2
v22.07.1
v22.07
v22.06.2
v22.06.1
v22.06
v22.04.2
v22.04.1
v22.04
v22.03.1
v22.03
v22.02.3
v22.02.2
v22.02.1
v22.02
v21.12.5
v21.12.4
v21.12.3
v21.12.2
v21.12.1
v21.12
v21.11.3
v21.11.2
v21.11.1
v21.11
v21.10.3
v21.10.2
v21.10.1
v21.10
v21.08.6
v21.08.5
v21.08.4
v21.08.3
v21.08.2
v21.08.1
v21.08
v21.05.4
v21.05.3
v21.05.2
v21.05.1
v21.05
v21.04.6
v21.04.5
v21.04.4
v21.04.3
v21.04.2
v21.04.1
v21.04
v0.31.8
v0.31.7
v0.31.6
v0.31.5
v0.31.4
v0.31.3
v0.31.2
v0.31.1
v0.31.0
v0.30.7
v0.30.6
v0.30.5
v0.30.4
v0.30.3
v0.30.2
v0.30.1
v0.30.0
v0.29.3
v0.29.2
v0.29.1
v0.29.0
v0.28.3
v0.28.2
v0.28.1
v0.28.0
v0.27.5
v0.27.4
v0.27.3
v0.27.2
v0.27.1
v0.27
v0.26.4
v0.26.3
v0.26.2
v0.26.1
v0.26.0
v0.25.5
v0.25.4
v0.25.3
v0.25.2
v0.25.1
v0.25.0
v0.24.3
v0.24.2
v0.24.1
v0.24.0
v0.23.2
v0.23.1
v0.23.0
v0.22.0
v0.21.0
v0.20.3
v0.20.2
v0.20.1
v0.20.0
v0.19.0
v0.18.5
v0.18.4
v0.18.3
v0.18.2
v0.18.1
v0.18.0
v0.17.4
v0.17.3
v0.17.2
v0.17.1
v0.17.0
v0.16.3
v0.16.2
v0.16.1
v0.16.0
v0.15.3
v0.15.2
v0.15.1
v0.15.0
v0.14.3
v0.14.2
v0.14.1
v0.14.0
v0.13.1
v0.13.0
v0.12.2
v0.12.1
v0.12.0
v0.11.2
v0.11.1
v0.11.0
v0.10.0
v0.9.3
v0.9.2
v0.9.1
v0.9.0
v0.8.2
v0.8.1
v0.8.0
v0.7.6
v0.7.5
v0.7.4
v0.7.3
0.7.2
v.0.7.1
v0.7.0
v0.6.3
v0.6.2
v0.6.1
v0.6.0
v0.5.0
Labels
Clear labels
🎨 Design
📖 Docs Update
🐛 Bug
🐛 Bug
:cat2:🐈 Possible duplicate
💿 Database
☕ Open to discussion
💻 Front-End
🐕 Support
🚪 Authentication
🌍 Translations
🔌 API Task
🏭 Back-End
⛲ Upstream
🔨 Feature Request
🛠️ Enhancement
🛠️ Enhancement
🛠️ Enhancement
❤️ Happy feedback
🔒 Security
🔍 Pending Validation
💆 UX
📝 WYSIWYG Editor
🌔 Out of scope
🔩 API Request
:octocat: Admin/Meta
🖌️ View Customization
❓ Question
🚀 Priority
🛡️ Blocked
🚚 Export System
♿ A11y
🔧 Maintenance
> Markdown Editor
pull-request
Mirrored from GitHub Pull Request
No Label
🐕 Support
Milestone
No items
No Milestone
Projects
Clear projects
No project
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: starred/BookStack#5026
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @chaospheremk on GitHub (Oct 25, 2024).
Attempted Debugging
Searched GitHub Issues
Describe the Scenario
The problem is that after a fresh install/setup of bookstack, I go to the bookstack URL I configured and see a header of "An Error Occurred" with the content under it showing "An unknown error occurred"
This is a fresh install of bookstack via docker-compose. I'm using mariadb as the mysql database. I did use the recommendation in the documentation to generate the APP_KEY with the following command
docker run -it --rm --entrypoint /bin/bash lscr.io/linuxserver/bookstack:latest appkeyThis generates a 44 character APP_KEY. However, online documentation seems to indicate that it should be a 32 character key? I'm not entirely sure.
Other documentation suggests using
php artisan key:generateandphp artisan migratebut that appears to be for a manual install. I'm not sure how I would or could accomplish the same thing when installing via docker compose.Exact BookStack Version
v24.10-ls170
Log Content
With APP_DEBUG not set to true:
Details
With APP_DEBUG set to true, I can go to the bookstack ip and see the following:
Error
RuntimeException
Unsupported cipher or incorrect key length. Supported ciphers are: aes-128-cbc, aes-256-cbc, aes-128-gcm, aes-256-gcm.
Environment
PHP Version: 8.3.12
BookStack Version: v24.10
Stack Trace
Details
Hosting Environment
I am simply trying to host bookstack via Docker with docker compose. Host OS is Ubuntu 24.04.
@ssddanbrown commented on GitHub (Oct 25, 2024):
Whatever is generated via that appkey command should be fine, since it's just running the
key:generatecommand we suggest anyway:1eb8aa7e86/root/appkey@chaospheremk commented on GitHub (Oct 25, 2024):
@ssddanbrown Well, as an update... just for kicks I generated my own 32 character key, plugged it in, and now bookstack is working. So it appears that what was generated by the appkey command is unfortunately not fine. What it generates is too long for bookstack to be able to use.
There might be a problem with the key:generate command and the default number of characters? It appears 44 characters is too long of a key for a default installation. Or am I missing something?
Second, is there any issue with me generating my own key? I didn't use key:generate and just used a powershell function I personally created to generate a random password at variable lengths.
@cgaskins-tx commented on GitHub (Oct 27, 2024):
I am running in to the exact same problem with Ubuntu 24.04 as the docker host + MariaDB.
production.ERROR: Unsupported cipher or incorrect key length.I generated my key using the documented command:
docker run -it --rm --entrypoint /bin/bash lscr.io/linuxserver/bookstack:latest appkeyWhich generates a key but causes the error above at runtime.
I tried generating my own key as follows and I still get the same error.
openssl rand -base64 32@chaospheremk - How did you generate your own key?
@cgaskins-tx commented on GitHub (Oct 27, 2024):
Well never mind... I was generating a key to long - duh...
Tried again with the following:
openssl rand -base64 24It worked perfectly. I am up and running now. :-)
@ssddanbrown commented on GitHub (Oct 28, 2024):
@chaospheremk @cgaskins-tx When you were using the
appkeycommand were you just taking the text after thebase64:in the output string? If so, that could be the issue, that should be part of the value:The desired value is 32 bytes, which is what that command provides, but it is represented base64 encoded which results in a longer string.
Don't think any major issue, might just be less secure (using a narrower range of bytes within the key).
@cgaskins-tx commented on GitHub (Oct 28, 2024):
Yes sir. I did NOT include the "base64:" so that was probably the issue. I apologize for the mistake.
@chaospheremk commented on GitHub (Nov 4, 2024):
I generated it with a custom powershell function I created for randomly generating passwords
I took the output from the above function
New-ComplexPassword -Length 32and just plugged it in. It worked fine. After reading the above conversation it's possible I did not includebase64:in my value as well.@ssddanbrown commented on GitHub (Nov 4, 2024):
Okay, thanks for confirming.
I'll therefore close this off but if this continues to occur I'll look to collaborate with the linuxserver team to improve their guidance around this.
@tenebrisnox commented on GitHub (Jan 12, 2025):
Just to belatedly add that this issue dogged me with a fresh install until I tried @cgaskins-tx's solution. Worked. Thank you.
@pfeyz commented on GitHub (Dec 7, 2025):
this just bit me and it to took me hours to realize what the cause was.
the
appkeycommand is generating an appkey string in color, so if you redirect stdout from that command to somewhere it will have extra control code bytes at the start and end of the string