-
Notifications
You must be signed in to change notification settings - Fork 365
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
Encryption documentation (for encrypted_drift
) (file is not a database
)
#2864
Comments
Hopefully, the upcoming native-assets feature will fix this by giving us full control over the libraries we want to link. Since we're using dynamic libraries, I also don't think there's much of a problem on Android. sqlite3 and sqlcipher can be loaded into the same process there, we're distinguishing symbols by looking them up through the library. iOS is problematic because we're typically linking everything into one bundle, so libraries with duplicate symbol names will cause a clash. As far as I'm aware, there really is no way to use both sqlite3 and sqlcipher in the same project on iOS. So if you have a dependency on sqlcipher, I'd drop the dependency on |
Original comment mentions a temporary solution, which can be untimatively resolved by dart-lang/sdk#50565 Original commentBut the `drift` itself depends on the `sqlite3`. Even though it is not linking any libraries to drift, it might be very misleading because:
One of possible long-term solutions to prevent any issues with the setup is to split
[*] Dependency override for 3rd party packages dependent on dependency_overrides:
...
sqflite:
git:
url: https://www.github.com/davidmartos96/sqflite_sqlcipher.git
ref: fmdb_override
path: sqflite For usage without encryption: dependencies:
drift: any
drift_sqlite3: any For usage with encryption: dependency_overrides:
sqflite:
git:
url: https://www.github.com/davidmartos96/sqflite_sqlcipher.git
ref: fmdb_override
path: sqflite
dependencies:
drift: any
drift_sqflite_sqlcipher: any
# OR
# drift_sqlcipher: any As a result, the usage will be more straightforward and will not require any additional setup. And this will eliminate almost all problems that might be cause by the database linking. Do you see any caveats with this approach? P.S. With this approach, P.P.S. One of examples in the repo might be outdated. P.P.P.S. Do I understand correctly that if I modify |
@simolus3 To use SQLCipher only:
main.dart in Flutter app: import 'package:sqlcipher_flutter_libs/sqlcipher_flutter_libs.dart';
import 'package:sqlite3/open.dart';
void main() {
// No need to override IOS
// because `sqlite3.framework` is already replaced with SQLCipher implementation
open.overrideFor(OperatingSystem.android, openCipherOnAndroid);
WidgetsFlutterBinding.ensureInitialized();
// ...
runApp(...);
} pubspec.yaml in Flutter app:
pubspec.yaml in Plugin:
|
dart-lang/sdk#50565 would be really a game-changer. |
Problem
On IOS, SQLite (FMDB) and SQLCipher (FMDB/SQLCipher) are in conflict.
Avoid linking both of them in the project at the same time.
It will lead to unintended unpredictable behavior.
I am having the same issue as described here (
file is not a database
):#1810
Potential fix:
#1810 (comment)
Use Case
Assuming the following use case:
drift
as a DBsqlite3
viaNativeDatabase(...)
)flutter_cache_manager
sqflite
)encrypted_drift
sqflite_sqlcipher
viaEncryptedExecutor(...)
)pubspec.yaml
in Flutter app:pubspec.yaml
in Plugin:Proposition
@simolus3 @davidmartos96 Could you please update the documentation on what is the proper way to set up the described use case?
Especially:
FMDB
andFMDB/SQLCipher
at the same time)?More info on the SQLite vs SQLCipher
Additional links:
https://drift.simonbinder.eu/docs/platforms/encryption/#extra-setup-on-android-and-ios
https://pub.dev/packages/sqflite_sqlcipher#if-using-sqflite-as-direct-or-transitive-dependency
https://pub.dev/packages/sqlcipher_flutter_libs#incompatibilities-with-sqlite3-on-ios-and-macos
https://discuss.zetetic.net/t/encrypted-db-in-swift-ios-via-fmdb-can-not-open-in-sql-db-browser/4813/4
https://discuss.zetetic.net/t/important-advisory-sqlcipher-with-xcode-8-and-new-sdks/1688
https://discuss.zetetic.net/t/cannot-open-encrypted-database-with-sqlcipher-4/3654/4
More additional links:
https://github.com/sqlcipher/sqlcipher
https://pub.dev/packages/sqlite3_flutter_libs
https://pub.dev/packages/sqlcipher_flutter_libs
https://ccgus.github.io/fmdb/html/index.html
#1480
https://discuss.zetetic.net/t/can-sqlite-and-sqlcipher-be-used-simultaneously/3609/2
The text was updated successfully, but these errors were encountered: