snipe-it icon indicating copy to clipboard operation
snipe-it copied to clipboard

Receiving cipher errors trying to generate key for installation.

Open roberthurricane opened this issue 8 years ago • 15 comments

Expected Behavior (or desired behavior if a feature request)

I'm on the step of the setup directions (here: https://snipe-it.readme.io/docs/generate-your-app-key). I assume it is supposed to generate the key and put it in my .env like it says...


Actual Behavior

I keep getting the error:

The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.


Please confirm you have done the following before posting your bug report:

  • [ ] I have enabled debug mode

  • [X ] I have read checked the Common Issues page

  • I checked config/app.php to confirm the cipher is set to "AES-256-CBC" which was the default.

  • I tried running 'php artisan config:clear' and I get the same error about supported ciphers.


Provide answers to these questions:

  • Is this a fresh install or an upgrade? fresh
  • Version of Snipe-IT you're running - latest commit shows 'v4.1.10-pre - build 3185-g5b15a2f'
  • Version of PHP you're running - 7.0.22
  • Version of MySQL/MariaDB you're running - 5.6.37
  • What OS and web server you're running Snipe-IT on - Ubuntu & Apache2.4
  • What method you used to install Snipe-IT (install.sh, manual installation, docker, etc) - git
  • WITH DEBUG TURNED ON, if you're getting an error in your browser, include that error
  • What specific Snipe-IT page you're on, and what specific element you're interacting with to trigger the error - https://snipe-it.readme.io/docs/generate-your-app-key
  • If a stacktrace is provided in the error, include that too.
  • Any errors that appear in your browser's error console.
  • Confirm whether the error is reproducible on the demo: https://snipeitapp.com/demo.
  • Include any additional information you can find in app/storage/logs and your webserver's logs.
  • Include what you've done so far in the installation, and if you got any error messages along the way.
  • Indicate whether or not you've manually edited any data directly in the database

Please do not post an issue without answering the related questions above. If you have opened a different issue and already answered these questions, answer them again, once for every ticket. It will be next to impossible for us to help you.

https://snipe-it.readme.io/docs/getting-help

roberthurricane avatar Jan 16 '18 17:01 roberthurricane

What's your APP_CIPHER set to in your .env?

snipe avatar Jan 16 '18 18:01 snipe

Thanks. Just so it's documented exactly what it is:

'cipher' =>  env('APP_CIPHER', 'AES-256-CBC'),

roberthurricane avatar Jan 16 '18 18:01 roberthurricane

I checked config/app.php to confirm the cipher is set to "AES-256-CBC" which was the default.

Your APP_CIPHER in your .env overrides whatever is in the config/app.php.

snipe avatar Jan 16 '18 18:01 snipe

I have nothing defined in .env for APP_CIPHER.

roberthurricane avatar Jan 16 '18 18:01 roberthurricane

Try adding

APP_CIPHER=AES-256-CBC

to your .env and clear your config cache.

If that still doesn't work, change your APP_KEY in your .env to:

APP_KEY=base64:vSI6nf5+pqzys7GCegkDOCCJQjtVtvp3o66R5YMSw/w=

and clear your config cache. Then try running php artisan key:generate again and clear your config cache one more time, making sure the app key was updated in the .env.

(Also make sure your .env is actually called .env exactly.)

snipe avatar Jan 16 '18 18:01 snipe

Thanks! Adding the APP_CIPHER resulted in the same error. I replaced the default "ChangeMe" APP_KEY to what you gave me, ran a clear then generated the key successfully!

roberthurricane avatar Jan 16 '18 18:01 roberthurricane

Alright I made it through all the install steps, now I am getting a "whoops, looks like something went wrong" error trying to do the pre-flight check step. Not sure if I should move that into a new issue or not. I can if so.

But not seeing any useful logs in the laravel.log in storage/logs and nothing in the Apache2.4 error log either.

I was thinking it might be permissions but I made sure the public directory, the storage directory were all owned by www-data:www-data (what Ubuntu runs Apache as). I noticed there could be issues running composer if not using the user the files are owned by, but www-data is not a user you can log in with. It has no shell defined for security purposes. So I'm kind of stuck what the problem may be here.

roberthurricane avatar Jan 16 '18 18:01 roberthurricane

You'll want to make sure the user you're running commands as and the www-data user share a group, and the permissions are such that that group owns the files and is group-writable.

A whoops error is a framework level error. If you enable debug and clear your config cache, does it give you more verbose output?

snipe avatar Jan 17 '18 00:01 snipe

Also check if SELinux is enabled. That can cause some odd permissions issues.

snipe avatar Jan 17 '18 10:01 snipe

Figured out there was a permissions issue, fixed that and I was able to load the pre-flight check.

After that, I kept getting errors about undefined functions. Seems like there are more packages I need to install for this to work properly. The first one was php7.0-mysql (this should have been obvious, but since this is a new install it wasn't there).

Second one that I am now stuck on is:

FatalThrowableError Call to undefined function Patchwork\utf8_encode()

I tried installing the package 'php-patchwork-utf8' but this did not seem to appease this error as I still get the error about it being undefined.

On another note, it would be nice to see a list of needed php modules for SnipeIt on the requirements page of the documentation and/or the pre-flight check making sure these functions are available and expressing what isn't there and what needs installed before moving forward with populating the database with tables. Every time I run into an error I have to drop the database and recreate it because otherwise it will error out saying the tables already exist.

Thanks for any help you can provide.

roberthurricane avatar Jan 17 '18 14:01 roberthurricane

Alright, installed php7.0-xml (found this in another issue). Restarted apache2 now I am moving on to another error. This one I don't know how to fix however. Doesn't seem like a missing package this time (I think).

QueryException SQLSTATE[42S02]: Base table or view not found: 1146 Table 'snipeit.snipe_oauth_clients' doesn't exist (SQL: insert into snipe_oauth_clients (user_id, name, secret, redirect, personal_access_client, password_client, revoked, updated_at, created_at) values (, Snipe-IT Personal Access Client, dmwLHcJI5zyKKPCMUTqvfpCyTxGG2Art6oKcg0V5, http://localhost, 1, 0, 0, 2018-01-17 09:46:39, 2018-01-17 09:46:39))

roberthurricane avatar Jan 17 '18 14:01 roberthurricane

For the oauth table issue, see the common issues section that addresses this.

The Patchwork\utf8_encode() error is because php-xml is required and it's no longer included with PHP7.

We do actually list the PHP modules needed in the Requirements page.

snipe avatar Jan 17 '18 14:01 snipe

@snipe I had the Cipher issue on our V3.6.3 install on docker when upgrading. Thankfully, I had created a test environment to test the update before doing it on production. Would it be worth adding the APP_CIPHER=AES-256-CBC to the upgrade docs??

I have made a suggestion on your docs

fordster78 avatar Jan 17 '18 19:01 fordster78

The APP_CIPHER is set to fallback to AES-256-CBC if no cipher is given in the .env, so it shouldn't be necessary to specify that. See config/app.php:

    'cipher' =>  env('APP_CIPHER', 'AES-256-CBC'),

snipe avatar Jan 17 '18 21:01 snipe

To anyone that might end up back here, I had the same problem and noticed that the template .env.example file I copied from had the value of ChangeMe assigned to the APP_KEY. I just plugged in an APP_KEY generated from another project temporarily, and was able to run php artisan config:clear and then php artisan key:generate with no issues.

CSAS-Nicholas-Roberts avatar Apr 17 '19 21:04 CSAS-Nicholas-Roberts