-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Encrypts can’t decrypt binary column? #102
Comments
That's probably right because the encryption will create a json in which one of the keys is rhe encrypted value. |
Sounds fine. Maybe this should be added to the docs. That if you want to use |
Haven't taken a deep dive into encryption/decryption code. But it might be, that value needs to unescaped before decrypting.
|
The issue here is that Rails doesn't really support encrypting binary columns. I didn't realise this before because it just happens to work for Mysql (and SQLite). Not for PostgreSQL though. I've raised rails/rails#50920 to add proper support. Hopefully that will resolve it. In the meantime I'll update the docs to highlight this. Another note is that there's a potential space saving here. ActiveRecord Encryption serializes messages to JSON with a Base64 encrypted payload which means they use about 30% more space than a binary encoding. Once binary data is properly supported, we could use a MessagePack based serializer for binary columns instead. |
Tried to use encryption on Rails 7.0.2 for my solid cache. Seems like it doesn’t work properly, it encrypts and stores the rows but it can’t be decrypted. It raises exception
ActiveRecord::Encryption::Errors::Decrypt
.I changed my
value
column to be atext
and that solves the issue but not sure that is the correct approach? Should it work with the binary column that comes with the default migration? In that case, am I missing some configuration that is not specified in the readme? 🤷♂️Using postgresql.
All the best,
Emil
Working migration
The text was updated successfully, but these errors were encountered: