realm-core: Compacted, encrypted Realm cannot be opened
There’s a Cocoa user who is employing encryption on one of their Realm files, and then attempting to save out a compacted copy using the same encryption key: https://github.com/realm/realm-cocoa/issues/3194
They’ve reported that the copy of the Realm file refuses to open, even with the same encryption key supplied. Before I ask them to send us the code for their app, I’m wondering if there might be any obvious corruption on the second file.
The files are attached here: EncryptedRealmFiles.zip
The encryption key they’re using, in base64 is 33443335324145432d453238422d343738432d423138372d39313137323742333133393300000000000000000000000000000000000000000000000000000000
. This can be pasted into the Realm Browser to test opening it.
Can anyone take a really brief look at this to see if there’s anything obviously wrong with the second file? I realise that since both of these files are encrypted, there’s possibly not a lot to see here.
Thanks!
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 17 (17 by maintainers)
Commits related to this issue
- cherry-picked fix from #1529 for #1498 — committed to realm/realm-core by finnschiermer 8 years ago
- Merge pull request #1638 from realm/fsa/fix_alloc_attach cherry-picked fix from #1529 for #1498 — committed to realm/realm-core by finnschiermer 8 years ago
- cherry-picked fix from #1529 for #1498 — committed to realm/realm-core by finnschiermer 8 years ago
While the fix in #1638 mentioned that this corruption would occur in the case of a crash during the opening of a Realm file, it can also happen if an exception is thrown out of
SlabAlloc::attach_file
. One such exception that is thrown in normal usage is theDecryptionFailed
exception when attempting to open an encrypted Realm file with an incorrect (or no) encryption key. This is something that the Realm Browser does for every Realm it opens, causing Browser versions without this fix (all recent versions) to corrupt every encrypted Realm file in streaming format that they open.