Skip to content
This repository was archived by the owner on Mar 29, 2022. It is now read-only.
This repository was archived by the owner on Mar 29, 2022. It is now read-only.

Removing Private Key from .env Doesn't work #8

Description

@hundredwatt

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions