OpenSSL::Cipher::CipherError in KeyringsController#create
masterkain opened this issue · comments
Kain commented
Given
class Keyring
include Mongoid::Document
include Mongoid::Encryptor
And
class MyKeyring < Keyring
field :my_secret_key
encrypts :my_secret_key,
mode: :asymmetric,
password: 'key',
private_key_file: Rails.root.join('config', 'keys', 'private'),
public_key_file: Rails.root.join('config', 'keys', 'public')
validates :my_secret_key, presence: true
OpenSSL::Cipher::CipherError in KeyringsController#create
wrong final block length
encrypted_strings (0.3.3) lib/encrypted_strings/symmetric_cipher.rb:85:in `final'
encrypted_strings (0.3.3) lib/encrypted_strings/symmetric_cipher.rb:85:in `decrypt'
encrypted_strings (0.3.3) lib/encrypted_strings/extensions/string.rb:101:in `decrypt'
encrypted_strings (0.3.3) lib/encrypted_strings/asymmetric_cipher.rb:173:in `private_rsa'
encrypted_strings (0.3.3) lib/encrypted_strings/asymmetric_cipher.rb:119:in `decrypt'
encrypted_strings (0.3.3) lib/encrypted_strings/extensions/string.rb:101:in `decrypt'
encrypted_strings (0.3.3) lib/encrypted_strings/extensions/string.rb:185:in `is_string_equal?'
encrypted_strings (0.3.3) lib/encrypted_strings/extensions/string.rb:168:in `equals_with_encryption'
mongoid (2.0.2) lib/mongoid/dirty.rb:227:in `!='
mongoid (2.0.2) lib/mongoid/dirty.rb:227:in `modify'
mongoid (2.0.2) lib/mongoid/attributes.rb:96:in `write_attribute'
mongoid (2.0.2) lib/mongoid/fields.rb:161:in `block (2 levels) in create_accessors'
mongoid-encryptor (0.0.4) lib/mongoid/encryptor.rb:56:in `write_encrypted_attribute'
mongoid-encryptor (0.0.4) lib/mongoid/encryptor.rb:23:in `block (2 levels) in encrypts'
/Users/kain/.rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-f88e9d83f13c/activesupport/lib/active_support/callbacks.rb:392:in `_run_validation_callbacks'
/Users/kain/.rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-f88e9d83f13c/activesupport/lib/active_support/callbacks.rb:81:in `run_callbacks'
/Users/kain/.rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-f88e9d83f13c/activemodel/lib/active_model/validations/callbacks.rb:53:in `run_validations!'
/Users/kain/.rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-f88e9d83f13c/activemodel/lib/active_model/validations.rb:179:in `valid?'
mongoid (2.0.2) lib/mongoid/validations.rb:50:in `valid?'
app/controllers/keyrings_controller.rb:49:in `create'
Is there anything else I can try? Thanks.
Kain commented
Silly me, I forgot the password option in, closing :)