繁体   English   中英

为现有 sqlite 上的持久存储管理器更改 NSPersistentStoreFileProtectionKey

[英]Changing NSPersistentStoreFileProtectionKey for persistent store manager on existing sqlite

在应用程序处于后台时调用 addPersistentStoreWithType 时,我的sqlite文件有时不可用,并且收到此错误:

[Model createPersistentStoreCoordinatorWithStoreURL:] line 387 $ sqlite 加密状态 NSFileProtectionCompleteUntilFirstUserAuthentication 错误 : Error Domain=NSCocoaErrorDomain Code=256 “操作无法完成。(Cocoa 错误 256.)” UserInfo=0x1560e540 {NSUnderizationDelivery,DomainSQLException

我发现这是因为文件仍然受到保护(默认为NSFileProtectionCompleteUntilFirstUserAuthentication因此在用户重新启动后第一次解锁设备后,受保护的数据可用)。 我觉得这不是正确的行为,因为我有大量的崩溃,而且我无法想象很多人在野外重新启动后仍然锁定他们的设备。

因此,我现在正在添加我的持久存储协调器,并像这样调整配置

NSDictionary *options = @{
        NSMigratePersistentStoresAutomaticallyOption : @YES,
        NSInferMappingModelAutomaticallyOption : @YES,
        NSPersistentStoreFileProtectionKey : NSFileProtectionNone
    }; 

问题:

  1. 如果设备被锁定,这是否可以确保文件在后台也可用?
  2. 如果我更改NSPersistentStoreFileProtectionKey这会破坏 sqlite(/ 里面的数据)吗?
  3. 我没有在数据库中存储敏感数据,但是,您在使用NSFileProtectionNone时是否看到安全问题?
  1. 是的,它会。 这就是这个键的作用。
  2. 不,不会。 我有一个带有默认保护密钥的持久存储协调器,然后将 NSFileProtectionComplete 添加到其中,数据正常。
  3. 是的。 如果有人可以访问您的 db 文件,他可以轻松读取它。 检查这篇文章: https : //github.com/project-imas/encrypted-core-data#strings-comparison

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM