cachethq / Docker

A Dockerized version of Cachet.
https://cachethq.io
BSD 3-Clause "New" or "Revised" License
415 stars 280 forks source link

No supported encrypter found. The cipher and / or key length are invalid. Using Getting started with Docker Compose docs #330

Closed sedan07 closed 5 years ago

sedan07 commented 6 years ago

Hi,

I've just followed the docs at: https://docs.cachethq.io/docs/get-started-with-docker and when I go to http://localhost I get a 500 error.

The error recorded in the error logs:

cachet_1    | 2018/07/07 19:41:59 [error] 71#71: *21 FastCGI sent in stderr: "PHP message: [2018-07-07 19:41:59] development.ERROR: RuntimeException: No supported encrypter found. The cipher and / or key length are invalid. in /var/www/html/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php:45
cachet_1    | Stack trace:
cachet_1    | #0 /var/www/html/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php(25): Illuminate\Encryption\EncryptionServiceProvider->getEncrypterForKeyAndCipher(NULL, 'AES-256-CBC')
cachet_1    | #1 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(731): Illuminate\Encryption\EncryptionServiceProvider->Illuminate\Encryption\{closure}(Object(Illuminate\Foundation\Application), Array)
cachet_1    | #2 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(629): Illuminate\Container\Container->build(Object(Closure), Array)
cachet_1    | #3 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(697): Illuminate\Container\Container->make('encrypter', Array)
cachet_1    | #4 /var/www/html/vendor/laravel/f" while reading response header from upstream, client: 172.24.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost", referrer: "http://localhost/"
cachet_1    | 172.24.0.1 - - [07/Jul/2018:19:41:59 +0000] "GET / HTTP/1.1" 500 3165 "http://localhost/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36" "-"
cachet_1    | [07-Jul-2018 19:41:59] WARNING: [pool www] child 250 said into stderr: "NOTICE: PHP message: [2018-07-07 19:41:59] development.ERROR: RuntimeException: AES-256-CBC No supported encrypter found. The cipher and / or key length are invalid. in /var/www/html/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php:45"
cachet_1    | [07-Jul-2018 19:41:59] WARNING: [pool www] child 250 said into stderr: "Stack trace:"
cachet_1    | [07-Jul-2018 19:41:59] WARNING: [pool www] child 250 said into stderr: "#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php(25): Illuminate\Encryption\EncryptionServiceProvider->getEncrypterForKeyAndCipher(NULL, 'AES-256-CBC')"
cachet_1    | [07-Jul-2018 19:41:59] WARNING: [pool www] child 250 said into stderr: "#1 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(731): Illuminate\Encryption\EncryptionServiceProvider->Illuminate\Encryption\{closure}(Object(Illuminate\Foundation\Application), Array)"
cachet_1    | [07-Jul-2018 19:41:59] WARNING: [pool www] child 250 said into stderr: "#2 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(629): Illuminate\Container\Container->build(Object(Closure), Array)"
cachet_1    | [07-Jul-2018 19:41:59] WARNING: [pool www] child 250 said into stderr: "#3 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(697): Illuminate\Container\Container->make('encrypter', Array)"

I've tried the suggestions of:

php artisan key:generate
php artisan config:cache

But these make no difference. I've followed the docs exactly and it doesn't work out the box? is there an extra undocumented step I need?

Tried the version mentioned in the docs: v2.3.10 and v2.3.15 and master and no joy with any.

welcome[bot] commented 6 years ago

:wave: Thank you for opening your first issue. I'm just an automated bot that's here to help you get the information you need quicker, so please ignore this message if it doesn't apply to your issue. If you're looking for support, you should try the Slack group by registering your email address at https://cachethq-slack.herokuapp.com. Alternatively, email support@alt-three.com for our Professional support service (please note, this a paid service. If you're issue is with documentation, you can suggest edits by clicking the Suggest Edits link on any page, or open an issue at https://github.com/CachetHQ/Docs

Atriusftw commented 6 years ago

Have you copied .env.example to .env? If yes, try manually setting the APP_KEY that gets output from php artisan key:generate in the .env file.

zizivtop commented 6 years ago

The doco is pretty confusing: it doesn't say anything about .env files, but looking to the docker files - the .env file looks very different from what example one. generating the key, and updating the .env file doesn't help - it still gives 500 ISE.

jbrooksuk commented 6 years ago

Okay, copy the .env.example file to .env (making sure that the file is writeable) then run:

php artisan key:generate
php artisan app:install
jbrooksuk commented 6 years ago

If you're on v2.4 the install command will be php artisan cachet:install.

millermarkj commented 6 years ago

I am having exactly the same issues as described here. I followed the (very limited) set of instructions for deploying via docker. There was no .env.example file, however, there was a .env.docker file in the ./conf directory from the cloned repository. I copied that file to .env in the same dir.

None of this has any effect. Things I've done: 1) Run the php artisan ... commands above:

user@host:/opt/svc/cachet$ docker exec -it cachet_cachet_1 /bin/bash
bash-4.4$ php artisan key:generate
Application key [base64:cWb5fQcbJCsq+Xj5+cbXQltqQm3tsPeRcXdAMaAxJqM=] set successfully.
bash-4.4$ php artisan app:install
Clearing settings cache...
Settings cache cleared!
Backing up database...
Dumping database and uploading...

Successfully dumped pgsql, compressed with gzip and store it to local at /var/www/html/database/backups/2018-09-12 13.29.34
Backup completed!
Application key [base64:2sTW7SBjPGkZ0nXVo6Op42OAsObdDEhf4d238aLqQ1M=] set successfully.
Configuration cache cleared!
Configuration cached successfully!
Route cache cleared!
Routes cached successfully!
Copied Directory [/vendor/roumen/feed/src/views] To [/resources/views/vendor/feed]
Publishing complete for tag []!
Nothing to migrate.
Clearing cache...
Application cache cleared!
Cache cleared!

The result from cachet's logs:

cachet_1    | 2018/09/12 13:29:50 [error] 120#120: *1 FastCGI sent in stderr: "PHP message: [2018-09-12 13:29:50] development.ERROR: RuntimeException: No supported encrypter found. The cipher and / or key length are invalid. in /var/www/html/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php:45
cachet_1    | Stack trace:
cachet_1    | #0 /var/www/html/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php(25): Illuminate\Encryption\EncryptionServiceProvider->getEncrypterForKeyAndCipher(NULL, 'AES-256-CBC')
cachet_1    | #1 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(731): Illuminate\Encryption\EncryptionServiceProvider->Illuminate\Encryption\{closure}(Object(Illuminate\Foundation\Application), Array)
cachet_1    | #2 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(629): Illuminate\Container\Container->build(Object(Closure), Array)
cachet_1    | #3 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(697): Illuminate\Container\Container->make('encrypter', Array)
cachet_1    | #4 /var/www/html/vendor/laravel/framework/src" while reading response header from upstream, client: 192.168.6.35, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.6.66:8000"
cachet_1    | [12-Sep-2018 13:29:50] WARNING: [pool www] child 189 said into stderr: "NOTICE: PHP message: [2018-09-12 13:29:50] development.ERROR: RuntimeException: No supported encrypter found. The cipher and / or key length are invalid. in /var/www/html/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php:45"
cachet_1    | [12-Sep-2018 13:29:50] WARNING: [pool www] child 189 said into stderr: "Stack trace:"
cachet_1    | [12-Sep-2018 13:29:50] WARNING: [pool www] child 189 said into stderr: "#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php(25): Illuminate\Encryption\EncryptionServiceProvider->getEncrypterForKeyAndCipher(NULL, 'AES-256-CBC')"
cachet_1    | [12-Sep-2018 13:29:50] WARNING: [pool www] child 189 said into stderr: "#1 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(731): Illuminate\Encryption\EncryptionServiceProvider->Illuminate\Encryption\{closure}(Object(Illuminate\Foundation\Application), Array)"
cachet_1    | [12-Sep-2018 13:29:50] WARNING: [pool www] child 189 said into stderr: "#2 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(629): Illuminate\Container\Container->build(Object(Closure), Array)"
cachet_1    | [12-Sep-2018 13:29:50] WARNING: [pool www] child 189 said into stderr: "#3 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(697): Illuminate\Container\Container->make('encrypter', Array)"
cachet_1    | [12-Sep-2018 13:29:50] WARNING: [pool www] child 189 said into stderr: "#4 /var/www/html/vendor/laravel/frame..."

2) I ran the php artisan cachet:install command which threw a giant red error:

user@host:/opt/svc/cachet$ docker exec -it cachet_cachet_1 /bin/bash
bash-4.4$ php artisan cachet:install
[2018-09-12 13:25:07] development.ERROR: Symfony\Component\Console\Exception\CommandNotFoundException: Command "cachet:install" is not defined.

Did you mean one of these?
    app:install
    migrate:install
    cachet:metrics
    cachet:seed
    cache:clear
    cache:table in /var/www/html/vendor/symfony/console/Application.php:515
Stack trace:
#0 /var/www/html/vendor/symfony/console/Application.php(183): Symfony\Component\Console\Application->find('cachet:install')
#1 /var/www/html/vendor/symfony/console/Application.php(117): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(107): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /var/www/html/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 {main} {"identification":{"id":"d1dca80c-75a0-4f92-a953-4334c6fd489a"}}

  [Symfony\Component\Console\Exception\CommandNotFoundException]
  Command "cachet:install" is not defined.
  Did you mean one of these?
      app:install
      migrate:install
      cachet:metrics
      cachet:seed
      cache:clear
      cache:table

The documentation is woefully lacking here.

sebbourgeois commented 5 years ago

Up ! Same situation here, docker documentation does not cover at all this..

b33rcity commented 5 years ago

Also having this issue with Docker on v2.3.14. Something I noticed that seems wrong:

$ php artisan key:generate
Application key [base64:37mbVCeRFS8IRt6efdhqZa2pwgulhjR6cXgzo+jN4hY=] set successfully.

$ env
DB_DRIVER=pgsql
DB_PORT=5432
DB_HOST=postgres
cachet_ver=v2.3.14
HOSTNAME=c8bc42a40b58
DEBUG=false
APP_LOG=errorlog
NGINX_VERSION=1.13.9
COMPOSER_VERSION=1.6.3
PWD=/var/www/html
APP_KEY=null                ####### The key was not updated?
HOME=/home/www-data
DB_PASSWORD=postgres
archive_url=https://github.com/cachethq/Cachet/archive/v2.3.14.tar.gz
TERM=xterm
CACHE_DRIVER=apc
DB_USERNAME=postgres
SHLVL=1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
DB_PREFIX=chq_
DB_DATABASE=postgres
_=/usr/bin/env

$ php artisan app:install
Clearing settings cache...
Settings cache cleared!
Backing up database...
Dumping database and uploading...

Successfully dumped pgsql, compressed with gzip and store it to local at /var/www/html/database/backups/2018-10-27 22.41.59
Backup completed!
Application key [base64:j8oFosQ5tVWUD7D18iMQtw/5Uq8Upv5JqLgfd3akhjY=] set successfully. 
                                       ######## Completely different key?
Configuration cache cleared!
Configuration cached successfully!
Route cache cleared!
Routes cached successfully!
Copied Directory [/vendor/roumen/feed/src/views] To [/resources/views/vendor/feed]
Publishing complete for tag []!
Nothing to migrate.
Clearing cache...
Application cache cleared!
Cache cleared!

/var/www/html
$ env
DB_DRIVER=pgsql
DB_PORT=5432
DB_HOST=postgres
cachet_ver=v2.3.14
HOSTNAME=c8bc42a40b58
DEBUG=false
APP_LOG=errorlog
NGINX_VERSION=1.13.9
COMPOSER_VERSION=1.6.3
PWD=/var/www/html
APP_KEY=null  ######## Still no key in env
HOME=/home/www-data
DB_PASSWORD=postgres
archive_url=https://github.com/cachethq/Cachet/archive/v2.3.14.tar.gz
TERM=xterm
CACHE_DRIVER=apc
DB_USERNAME=postgres
SHLVL=1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
DB_PREFIX=chq_
DB_DATABASE=postgres
_=/usr/bin/env

/var/www/html
$ cat .env
APP_ENV="development"
APP_DEBUG="true"
APP_URL="http://localhost"
APP_LOG="errorlog"
APP_KEY=base64:j8oFosQ5tVWUD7D18iMQtw/5Uq8Upv5JqLgfd3akhjY=base64:37mbVCeRFS8IRt6efdhqZa2pwgulhjR6cXgzo+jN4hY="null" ###### At least it's gettind added to .env....

DB_DRIVER="pgsql"
DB_HOST="postgres"
DB_DATABASE="postgres"
DB_USERNAME="postgres"
DB_PASSWORD="postgres"
DB_PORT="5432"
DB_PREFIX="chq_"

DOCKER=true

CACHE_DRIVER="apc"

SESSION_DOMAIN="http://localhost"

QUEUE_DRIVER="database"

CACHET_EMOJI="false"
CACHET_BEACON="true"
CACHET_AUTO_TWITTER="true"

MAIL_DRIVER="smtp"
MAIL_HOST="localhost"
MAIL_PORT="25"

NEXMO_SMS_FROM="Cachet"

At this point I can source .env and the keys will appear in env as expected.

So, are there supposed to be two different keys? If so, shouldn't each get its own ENV variable?

Btw, it doesn't seem to matter if I remove one of the keys or leave them both there--I still get a 500 accompanied by the infamous WARNING: [pool www] child 128 said into stderr: "#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php(25): Illuminate\Encryption\EncryptionServiceProvider->getEncrypterForKeyAndCipher(NULL, 'AES-256-CBC')"

The "NULL" in that error message is a bit concerning. It's next on things I plan to investigate.

jordanwilson230 commented 5 years ago

Any update to this issue? Issues found in standard out-of-the-box installs should be prioritized IMO. @b33rcity let me know if you've found anything that makes cachet-docker usable at this point.

jhodges10 commented 5 years ago

@b33rcity Also wondering if there's a fix for this. Out-of-the-box Docker installs that work are kind of the whole point with Docker.

jbrooksuk commented 5 years ago

@djdefi could you investigate please?

jasimmonsv commented 5 years ago

the API_KEY passed has to be a length of 32 as defined in Encrypter.php. As soon as I passed in a 32 char string, this error went away and everything came right up.