Cipher and / or key length are invalid [EncryptionServiceProvider] Laravel5 - encryption

First time laravel5 run after install composer Cipher and / or key length are invalid [EncryptionServiceProvider] error in Laravel5 ?

Simply,
Beginner in laravel5.. when you are install composer in laravel project after error "Cipher and / or key length are invalid [EncryptionServiceProvider]" solved
open project directory and run there laravel composer
in composer command->php artisan key:generate you see
this type of key generate [gcVkEsRcFdjcsYVFuZee8yOLfiRZl1VE]. Copy
this key
open project_directory/config/app.php
'key' => env('APP_KEY', 'gcVkEsRcFdjcsYVFuZee8yOLfiRZl1VE'),
paste that key which see in bold letter replace with new generate key remove '[]' must be...

I think you have some key generation problem. You can generate the keys by following below simple steps.
Add an APP_KEY by running php artisan key:generate from the command line in your project root. This will generate a random, 32 character string which is used for encryption.
You should already have 'cipher' => 'AES-256-CBC', within your project_directory/config/app.php.
Run the project. This might work.
Happy Coding :)

Related

Flyway 7.7.3 seems to ignore my "callback"

I am upgrading from Flyway 5.4 to 7.7.3 and ran into some issue.
flyway -teams -url=jdbc:oracle:thin:#localhost:1521/XE "-user=xxx as SYSDBA" -password=xxx -table=flyway_schema_history_app -encoding=utf-8 -baselineOnMigrate=true migrate
(I have the teams edition license)
Flyway gives me the following error message:
**
ERROR: Unable to parse statement in /flyway/sql/incremental/Build_302_Baseline/V302_106__fosprd_INSERT_Master_eg_pocqueue.sql at line 117 col 1. See https://flywaydb.org/documentation/knownparserlimitations for more information: No value provided for variable substitution: &R. Check your configuration. If this is not a SQLPLus variable intended to be substituted (eg. in a string literal), then you will need to add SET DEFINE OFF in the script beforehand.
Caused by: No value provided for variable substitution: &R. Check your configuration. If this is not a SQLPLus variable intended to be substituted (eg. in a string literal), then you will need to add SET DEFINE OFF in the script beforehand.
**
This is caused by a special character "&" in the SQL statement, however, I have made sure the SQL file is using UTF-8 encoding as well as Unix return (LF).
Also, I keep my callbacks under:
bash-5.0$ pwd
/flyway/sql/callbacks
bash-5.0$ ls
afterBaseline.sql afterEachUndo.sql afterMigrateError.sql afterUndo.sql beforeEachUndo.sql
afterBaselineError.sql afterEachUndoError.sql afterRepair.sql afterUndoError.sql beforeMigrate.sql
afterEachMigrate.sql afterMigrate.sql afterRepairError.sql beforeEachMigrate.sql beforeUndo.sql
This used to be able to run on 5.4 with no issue. But it's giving me this error on 7.7.3, anyone can point me to the right direction?
Thanks
This is due to the changes between versions of flyway's SQLPlus support and the fat you have a teams license.
As indicated in the message, this is related to SQLPlus's variable substitution:
https://flywaydb.org/documentation/database/oracle#variable-substitution
If you are not using SQLPlus features, you could try disabling them:
https://flywaydb.org/documentation/configuration/parameters/oracleSqlPlus
but the recommended solution is to place SET DEFINE OFF in the SQL script before the offending ampersand (with the option of reverting that afterwards)

Setting up TPM2 in Ubuntu: tpm2-abrmd error "insufficient buffer to get handle"

I am trying to setup an encrypted drive using the TPM2.0 module on a NUC7i5 on a new installation of Ubuntu server 18.04.
I compiled from sources and installed tpm2-tss (1.3.0), tpm2-abrmd (1.2.0) and tpm2-tools (3.0.2), and I tested some of the tpm2_* utilities and they seem to work. I also installed clevis v10.
I generated a secret using tpm2_getrandom 32 -o secret.key, and then tried to encrypt the secret using the TPM using the following command:
cat secret.key | sudo clevis encrypt tpm2 '{"pcr_ids":"7","pcr_bank":"sha256"}' > secret.jwe
When I do that however, I get the following error:
ERROR:
CreatePrimary Failed ! ErrorCode: 0x9a2
ERROR: Unable to run tpm2_createprimary
Creating TPM2 primary key failed!
When checking the status of the tpm2-abrmd service (systemctl status tpm2-abrmd.service), I get this error:
tpm2-abrmd[1308]: tpm2_response_get_handle: insufficient buffer to get handle
I tried different options for the clevis encryption, tried different ways to generate the secret, but I still can't figure out what the issue is.
The TPM module is a SLB9665 from Infineon Technologies.
I tried with and without taking ownership of the TPM, and always with a clear TPM every time.
Has anyone ran into that issue?
So, apparently the issue was that I shouldn't have taken ownership of the TPM.
After resetting the TPM, the clevis command works.

Cannot proceed alfresco installation because of encoding mismatch

I am new to Alfresco and I am trying to install alfresco in my debian server(via ssh access) following the installation guide. However, the installation stops and shows me this error :
Error: There has been an error.
initdb.bin: encoding mismatch
The encoding you selected (UTF8) and the encoding that the selected
locale uses (LATIN1) do not match. This would lead to misbehavior in
various character string processing functions. Rerun initdb.bin and either
do not specify an encoding explicitly, or choose a matching combination.
I tried updating the locales of the server but still the issue exists. How do I fix this?
I have successfully installed it by doing the following steps:
Commented out the Send_ENV in /etc/ssh/ssh_config variable in the local machine and Accept_ENV in /etc/ssh/sshd_config variable in the server.
Edited /etc/locale.gen to uncomment en_US.UTF-8.
Ran locale-gen
Edited /etc/locale.conf and added LANG=en_US.UTF-8.
Successfully installed alfresco.

How to correctly setup keys with Hadley's secure package

I would like to use Hadley Wickam's secure package from GitHub.
The example usage isn't explicit about how to create keys and where to store them and I'm messing something up (possibly more than one thing).
I installed the package
# install.packages("devtools")
devtools::install_github("s-u/PKI") # needed for bug fixes not currently on CRAN
devtools::install_github("hadley/secure")
set up a vault folder:
dir.create("vault")
Then the next step is to add a user / key:
secure::add_user("hackr", local_key())
and of course if I literally run that last line as-is it says
Error: No key matches id_rsa
Because I don't have a key. So, I used PuttyGen to create a public/private RSA key pair.
I saved them to my desktop and tried putting the full path in the command above:
secure::add_user("hackr", local_key("C:/Users/hackr/Desktop/r_public_key"))
But that didn't work:
Error: No key matches
Then I tried saving the public key in the vault and doing:
secure::add_user("hackr", local_key("r_public_key"))
but I got the same error. Next I tried putting the public key in the working directory (one directory higher than the vault) but got the same error.
Finally, I tried copying the keys to C:\Users\hackr\.ssh but that also led to the same error.
I suspect I need to save the key somewhere special (in Windows I'm not sure where that would be?) and/or I am using the wrong type of key since PuttyGen is for SSH (?).
It looks like local_key is assuming your key is stored in ~/.ssh (which is a reasonable assumption). By default it assumes that the file is named id_rsa.pub so if you've renamed it then you'll need to pass the name into local_key.
I haven't used this package but always remember those wise words "Hack-R view the source"
The issue is that Hadley's local_key() function is assuming your key is stored in ~/.ssh which is where the commands below will place it by default, and name it id_rsa.pub. If you have a different setup, you can change the defaults, or you could simply follow the steps below.
Step 1
Go to https://help.github.com/articles/generating-an-ssh-key/
Read up. It's useful stuff to know.
It will tell you to do this in the console:
ssh-keygen -t rsa -b 4096 -C "your_email#example.com"
Set a passphrase. Remember it.
Then enter this:
ssh-add ~/.ssh/id_rsa
Enter your passphrase.
Step 2
Your secure::add_user("hackr", local_key()) should work now.

Migration Error When setting up rspec

I'm trying to add rspec testing to an app I've already been working on. I've been following this tutorial: http://everydayrails.com/2012/03/19/testing-series-rspec-models-factory-girl.html which is from 2012, so I'm sure it was done using Rails 3. I installed rspec and capybara, ran bundle, and ran rails g rspec:install. I started writing the test of my Question model below, and when I ran it with rspec spec/models/question_spec.rb
I received the error: Migrations are pending; run 'bin/rake db:migrate RAILS_ENV=test' to resolve this issue. I tried to run that and I received this error about one of my previous migrations:
== ChangeTestTypeInScores: migrating =========================================
-- change_column(:scores, :test_type, "boolean USING CAST(test_type AS boolean)")
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
SQLite3::SQLException: near "USING": syntax error: CREATE TABLE "scores" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "test_type" boolean USING CAST(test_type AS boolean), "name" varchar(255), "created_at" datetime, "updated_at" datetime, "user_id" integer, "month" varchar(255), "year" varchar(255))
How can I correctly set up rspec without messing up my database, which works fine otherwise?
rails_helper.rb:
ENV["RAILS_ENV"] ||= 'test'
require 'spec_helper'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara/rspec'
ActiveRecord::Migration.check_pending!
.rspec:
--color
--require spec_helper
--require rails_helper
--format documentation
question_spec.rb:
require 'spec_helper'
describe Question do
it "has a valid factory"
it "is invalid without a body"
it "is invalid without an answer"
end
I assume there's an issue with my changing the :test_type in my Scores model to boolean based on that error, but it all works great locally and on Heroku, so I don't want to mess with my database in order to run tests. Any help is appreciated.
UPDATE:
I added this to the test.rb file:
config.active_record.maintain_test_schema = false
Also, I updated my version of rails to 4.1.6 after seeing many other related Stack Overflow issues. Now I get this error:
/Users/tambe257/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:241:in `load': cannot load such file -- /Users/tambe257/programming/rails_projects/fast_track/spec/models/question.rb (LoadError)
It looks like a problem with some dependencies, but I've been googling the error with no luck.
On the update above I added this to the test.rb file, which actually cleared things up:
config.active_record.maintain_test_schema = false
I was then getting the (LoadError), but that was due to my file name not being completely correct. When you enter something like this below, be sure the route and file name are correct!
rspec spec/models/question_spec.rb

Resources