Database not encrypted since iOS 15.2
SwifterPJ opened this issue ยท 2 comments
Hello
I'm raising an issue here because I run out of ideas on how to fix my project by myself.
The problem is that my database is not encrypted anymore on iOS (actually since iOS 15.2 and above).
I prepared a KMM project with basic DB operations (create DB, add table and a row)
The example project can be found here
To test a db encryption I just run an iOS application on simulators (e.g: try with iOS 15.0 and iOS 15.2) and perform following tests for both iOS versions:
When the app is launched a db file is created and can be easily accessed from local drive by entering the path logged by the app.
To test db encryption I just open the file "sqlite test.db" and execute for example ".tables". If database is encrypted then I'm receiving an error - which is expected and desired, otherwise db tables are listed.
You can notice that databases are encrypted prior to iOS 15.2 and not encrypted since.
Any help would be appreciated as you guys have the best tools to debug the problem.
P.S: Just to make sure it can work, I created a native project with SQLite and SQLCipher libs - the result is that the db is encrypted on any iOS version with native approach.
With regards
PJ
My guess is that apple removed the Sqlite encryption extensions for iOS 15+. Seems like others have had similar issues: https://developer.apple.com/forums/thread/697001. I don't think we've documented encryption anywhere in the driver, as we mostly leave documentation at the sqldelight layber, but we probably should.
We have a blog post where we talk about this: https://touchlab.co/multiplatform-encryption-with-sqldelight-and-sqlcipher/. Essentially, it seemed like apple was compiling with SEE, but not talking about it anywhere, so using it would be a bad idea. If we need encryption for anything, we use SQLCipher.
Just to make sure it can work, I created a native project with SQLite and SQLCipher libs
Where is the version with SQLCipher? Make sure linkSqlite = true
is false. We want to make sure the app uses the SQLCipher version.
Thank you for your answer. I missed to switch linkSqlite = true
to linkSqlite = false
.
Apparently with linkSqlite = true
the app was using SEE to encrypt the DB but since iOS 15.2 SEE was removed it just stopped working.
So linkSqlite = false
forces the DB to use SQLCipher as encryption engine -> now it works fine.
Thanks a lot again! ๐