This repository was archived by the owner on Mar 29, 2022. It is now read-only.
Description Any insight here? I set it up and ran the migration:
user.rb
class User < ActiveRecord ::Base
attr_encrypted :token , :secret , public_key : ENV [ 'PUBLIC_KEY_FILE' ] ,
private_key : ENV [ 'PRIVATE_KEY_FILE' ] ,
private_key_password : ENV [ 'PRIVATE_KEY_PASSWORD' ]
end
.env
PUBLIC_KEY_FILE=public.pem
#PRIVATE_KEY_FILE=private.pem
#PRIVATE_KEY_PASSWORD=E64dK8RnELtmiKiKYcAKNMCkU
Then I tried updating an encrypted column on the command line and got exceptions:
> user = User.first
=> #<#<Class:#<User:0x007fbae6a25af0>>:0x3fdd73512d78>
> user.update_attribute :token, '123'
OpenSSL::PKey::RSAError: private key needed.
from /Users/jason/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/bundler/gems/cryptonite-5b9f4ac91b5b/lib/cryptonite.rb:118:in `private_decrypt'
[11] pry(main)> user.update_attributes token: '123'
ArgumentError: Value is already encrypted
from /Users/jason/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/bundler/gems/cryptonite-5b9f4ac91b5b/lib/cryptonite.rb:108:in `encrypt'
Reactions are currently unavailable
Any insight here? I set it up and ran the migration:
user.rb
.env
Then I tried updating an encrypted column on the command line and got exceptions: