Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When i change my app_key in my .env i get an error that i have a wrong mac address #134

Closed
danielgroen opened this issue Apr 3, 2020 · 5 comments
Labels
invoiceninja Related to the application need feedback Needs feedback from creator

Comments

@danielgroen
Copy link
Contributor

I also tried to re-generate it but in other issues i understood that there is a known issue that the .env file could not be updated. Is this also the issue? Because now my app is running on the standard app_key which is pretty insecure.

@hillelcoren
Copy link
Member

You can run php artisan ninja:update-key to set a new key but make sure to backup your database and .env file first

@danielgroen
Copy link
Contributor Author

danielgroen commented Apr 5, 2020

when i try the command i'll get the following message:

docker exec -i docker-compose_app_1 php artisan ninja:update-key

Sun, 05 Apr 2020 10:51:38 +0000 Running UpdateKey...
Sun, 05 Apr 2020 10:51:38 +0000 Error: app key and cipher are not set

It suggets that i don't have any key in my .env file. True so far...
So i generated one key for myself, putted it in the .env file, afterwards i restarted the container i think my database and the key are out of sync.

docker exec -i docker-compose_app_1 php artisan ninja:update-key

Sun, 05 Apr 2020 10:46:48 +0000 Running UpdateKey...
[2020-04-05 10:46:48] production.ERROR: ***Illuminate\Contracts\Encryption\DecryptException*** [0] : /var/www/app/vendor/laravel/framework/src/Illuminate/Encryption/Encrypter.php [Line 195] => The MAC is invalid.  {"context":"PHP","user_id":0,"account_id":0,"user_name":"","method":"GET","user_agent":"","locale":"en","ip":"127.0.0.1","count":1,"is_console":"yes","is_api":"no","db_server":"mysql","url":"/"} []
[2020-04-05 10:46:48] production.ERROR: [stacktrace] 2020-04-05 10:46:48 The MAC is invalid.: 
#0 /var/www/app/vendor/laravel/framework/src/Illuminate/Encryption/Encrypter.php(134): Illuminate\Encryption\Encrypter->getJsonPayload(Array) 
#1 /var/www/app/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(221): Illuminate\Encryption\Encrypter->decrypt('eyJpdiI6ImlLeTl...') 
#2 /var/www/app/app/Models/AccountGateway.php(137): Illuminate\Support\Facades\Facade::__callStatic('decrypt', Array) 
#3 /var/www/app/app/Console/Commands/UpdateKey.php(57): App\Models\AccountGateway->getConfig() 
#4 [internal function]: App\Console\Commands\UpdateKey->handle() 
#5 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array) 
#6 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() 
#7 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure)) 
#8 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/Container.php(549): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL) 
#9 /var/www/app/vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\Container\Container->call(Array) 
#10 /var/www/app/vendor/symfony/console/Command/Command.php(252): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle)) 
#11 /var/www/app/vendor/laravel/framework/src/Illuminate/Console/Command.php(170): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle)) 
#12 /var/www/app/vendor/symfony/console/Application.php(946): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 
#13 /var/www/app/vendor/symfony/console/Application.php(248): Symfony\Component\Console\Application->doRunCommand(Object(App\Console\Commands\UpdateKey), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 
#14 /var/www/app/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 
#15 /var/www/app/vendor/laravel/framework/src/Illuminate/Console/Application.php(88): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 
#16 /var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(121): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 
#17 /var/www/app/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 
#18 {main}    {"context":"PHP","user_id":0,"account_id":0,"user_name":"","method":"GET","user_agent":"","locale":"en","ip":"127.0.0.1","count":2,"is_console":"yes","is_api":"no","db_server":"mysql","url":"/"} []

In Encrypter.php line 195:
  The MAC is invalid.  

@hillelcoren
Copy link
Member

One solution is to manually delete the records in the account_gateways table and then re-add the payment gateways in the UI

@lalop lalop added the invoiceninja Related to the application label Apr 24, 2020
@gerroon
Copy link

gerroon commented Apr 27, 2020

I am getting an errro when I try to update the key too, can someone please tell me the right way to do this?

docker exec -i invoiceninja_docker_app_1 php artisan ninja:update-key

Mon, 27 Apr 2020 16:22:16 +0000 Running UpdateKey...
[2020-04-27 16:22:17] production.ERROR: ***Illuminate\Database\QueryException*** [42S02] : /var/www/app/vendor/laravel/framework/src/Illuminate/Database/Connection.php [Line 664] => SQLSTATE[42S02]: Base table or view not found: 1146 Table 'ninja.account_gateways' doesn't exist (SQL: select * from `account_gateways`)  {"context":"PHP","user_id":0,"account_id":0,"user_name":"","method":"GET","user_agent":"","locale":"en","ip":"127.0.0.1","count":1,"is_console":"yes","is_api":"no","db_server":"mysql","url":"/"} []
[2020-04-27 16:22:17] production.ERROR: [stacktrace] 2020-04-27 04:22:17 SQLSTATE[42S02]: Base table or view not found: 1146 Table 'ninja.account_gateways' doesn't exist (SQL: select * from `account_gateways`): #0 /var/www/app/vendor/laravel/framework/src/Illuminate/Database/Connection.php(624): Illuminate\Database\Connection->runQueryCallback('select * from `...', Array, Object(Closure)) #1 /var/www/app/vendor/laravel/framework/src/Illuminate/Database/Connection.php(333): Illuminate\Database\Connection->run('select * from `...', Array, Object(Closure)) #2 /var/www/app/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1719): Illuminate\Database\Connection->select('select * from `...', Array, true) #3 /var/www/app/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1704): Illuminate\Database\Query\Builder->runSelect() #4 /var/www/app/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(481): Illuminate\Database\Query\Builder->get(Array) #5 /var/www/app/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(465): Illuminate\Database\Eloquent\Builder->getModels(Array) #6 /var/www/app/app/Console/Commands/UpdateKey.php(53): Illuminate\Database\Eloquent\Builder->get() #7 [internal function]: App\Console\Commands\UpdateKey->handle() #8 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array) #9 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() #10 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure)) #11 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/Container.php(549): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL) #12 /var/www/app/vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\Container\Container->call(Array) #13 /var/www/app/vendor/symfony/console/Command/Command.php(252): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle)) #14 /var/www/app/vendor/laravel/framework/src/Illuminate/Console/Command.php(170): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle)) #15 /var/www/app/vendor/symfony/console/Application.php(946): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #16 /var/www/app/vendor/symfony/console/Application.php(248): Symfony\Component\Console\Application->doRunCommand(Object(App\Console\Commands\UpdateKey), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #17 /var/www/app/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #18 /var/www/app/vendor/laravel/framework/src/Illuminate/Console/Application.php(88): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #19 /var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(121): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #20 /var/www/app/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #21 {main}    {"context":"PHP","user_id":0,"account_id":0,"user_name":"","method":"GET","user_agent":"","locale":"en","ip":"127.0.0.1","count":2,"is_console":"yes","is_api":"no","db_server":"mysql","url":"/"} []

In Connection.php line 664:
                                                                               
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'ninja.account_ga  
  teways' doesn't exist (SQL: select * from `account_gateways`)                
                                                                               

In PDOConnection.php line 79:
                                                                               
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'ninja.account_ga  
  teways' doesn't exist                                                        
                                                                               

In PDOConnection.php line 77:
                                                                               
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'ninja.account_ga  
  teways' doesn't exist                                                        

@codedge
Copy link
Contributor

codedge commented Aug 16, 2020

@danielgroen Is you issue solved. It seems thise one is so old and versions have changed that all this info is outdated.
Let me know if I can close this issue.

@codedge codedge added the need feedback Needs feedback from creator label Aug 16, 2020
@turbo124 turbo124 closed this as completed Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invoiceninja Related to the application need feedback Needs feedback from creator
Projects
None yet
Development

No branches or pull requests

6 participants