繁体   English   中英

将钥匙串共享添加到已有用户的生产应用程序

[英]Adding keychain sharing to production app that already has users

我们有一个已发布的iOS应用程序。 IDE是XCode6。 我想添加钥匙串共享以从iOS 8共享扩展访问应用程序中存在的sessionID。

问题是,只要打开钥匙串共享,就无法再访问已存在的sessionID。

只要关闭钥匙串共享,就可以访问它。

该字典被传递到SecItemCopyMatching,无论“Keychain Groups:”是什么,只要启用了keychain共享,它总是返回-25300(未找到)。

[0] (null)  @"svce" : @"SESSION_ID_KEY"   
[1] (null)  @"r_Data" : @"1"    
[2] (null)  @"m_Limit" : @"m_LimitOne"  
[3] (null)  @"class" : @"genp"  
[4] (null)  @"acct" : @"SESSION_ID_KEY"   
[5] (null)  @"pdmn" : @"ck" 

知道为什么访问密钥可能不起作用? 我尝试使用捆绑包前缀和名称设置kSecAttrAccessGroup,但它仍然无法在模拟器上运行。

希望我得到你的答案和赏金:)

我最初遇到了同样的问题并遇到过这篇文章,我知道你提到过你试过捆绑前缀和名称。 但是让我们进行一次健全检查。

MyApp.entitlementsMyApp Extension.entitlements我将Keychain Access Groups设置为$(AppIdentifierPrefix)com.company.MyApp (这是默认值)。

我使用这个SO答案https://stackoverflow.com/a/20340883访问了ABCD1234 (又名AppIdentifierPrefix值)的值,但硬编码可能不是这里的最佳做法,所以考虑看这个像这样的解决方案https://stackoverflow.com /一个/2588957分之11841898

然后在我的应用程序中注意我添加的所有内容使我的当前代码工作如下: [keychainItem setObject:@"ABCD1234.com.company.MyApp" forKey:(__bridge id)kSecAttrAccessGroup]; 在更新项目之前,我现在可以访问共享扩展中的钥匙串项目。

几个月前在iOS 7中实现应用内通信时,我遇到了类似的问题。 我在Apple的GenericKeyChain示例项目中发现了这句话:

  // Apps that are built for the simulator aren't signed, so there's no keychain access group // for the simulator to check. This means that all apps can see all keychain items when run // on the simulator. // // If a SecItem contains an access group attribute, SecItemAdd and SecItemUpdate on the // simulator will return -25243 (errSecNoAccessForItem). 

因此,如果您在模拟器上进行测试,则需要删除“kSecAttrAccessGroup”。

在设备上它应该使用此密钥。

暂无
暂无

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

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