rails_event_store: Error when decrypting event with new cipher key
Hi guys, I think I found another issue
So the use case is this - we have some events that are encrypted using a cipher key with an identifier
When we delete that cipher key from the database, similar events being encrypted after the cipher key has been deleted, will result in creating a new cipher key in our db with an identical identifier.
So when we try to decrypt the old events with the new cipher key, this happens:
2020-08-31 13:21:43 - Psych::SyntaxError - (<unknown>): invalid leading UTF-8 octet at line 1 column 1:
/Users/nicolaiseerup/.rvm/rubies/ruby-2.6.5/lib/ruby/2.6.0/psych.rb:456:in `parse'
/Users/nicolaiseerup/.rvm/rubies/ruby-2.6.5/lib/ruby/2.6.0/psych.rb:456:in `parse_stream'
/Users/nicolaiseerup/.rvm/rubies/ruby-2.6.5/lib/ruby/2.6.0/psych.rb:390:in `parse'
/Users/nicolaiseerup/.rvm/rubies/ruby-2.6.5/lib/ruby/2.6.0/psych.rb:277:in `load'
/Users/nicolaiseerup/.rvm/gems/ruby-2.6.5@smart-workspaces/gems/ruby_event_store-1.1.1/lib/ruby_event_store/mappers/transformation/encryption.rb:117:in `decrypt_attribute'
Maybe this line should also rescue from Psych::SyntaxError
?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (6 by maintainers)
With that set of cryptogram, iv & key you will get a
{M]\xEAμ\xEA\x99\xE5\"ЮF\xE6bM)C\xA1݃\x96\xBC_\xB2\xD7DN\"\x80i
as decrypted message, of course later when we try to parse it to as YAML it fails.This seems like not RES related problem - I think you should verify your keys management.
Ok, let me try to reproduce our case somehow - please leave this issue open a bit