简体   繁体   English

退出应用后无法在Keychain中保存凭据

[英]Can not save credentials in Keychain after resign app

I wrote an App which saves the user credentials in the iOS Keychain using the KeychainItemWrapper class. 我编写了一个应用程序,该应用程序使用KeychainItemWrapper类将用户凭据保存在iOS钥匙串中。 All works fine, but if the App is getting resigned for enterprise use, saving credentials do not work anymore. 一切正常,但是如果该应用程序已被辞职供企业使用,则保存凭据将不再起作用。

I get the following Error but the App is not crashing: 我收到以下错误,但应用程序没有崩溃:

SecItemCopyMatching: missing entitlement
securityd[2314] <Error>: Directory[2312] SecItemCopyMatching: missing entitlement
securityd[2314] <Error>: Directory[2312] SecItemAdd: missing entitlement
securityd[2314] <Error>: Directory[2312] SecItemCopyMatching: missing entitlement
securityd[2314] <Error>: XYZ[2312] SecItemAdd: missing entitlement

I initiate the class a follows: 我开始上课:

KeychainItemWrapper *wrapper = [[KeychainItemWrapper alloc] initWithIdentifier:@"MYAPP_credentials" accessGroup:nil];
[keychain setObject:userName forKey:(__bridge id)kSecAttrAccount];
[keychain setObject:password forKey:(__bridge id)kSecValueData];

I tried also to create an Entitlements.plist (using XCode 4.5.2) 我也尝试创建一个Entitlements.plist(使用XCode 4.5.2)

在此处输入图片说明

and the following code: 和以下代码:

KeychainItemWrapper *wrapper = [[KeychainItemWrapper alloc] initWithIdentifier:@"p7s1_dictionary" accessGroup:@"net.XYZ.directory"];
[keychain setObject:userName forKey:(__bridge id)kSecAttrAccount];
[keychain setObject:password forKey:(__bridge id)kSecValueData];

While doing this I get an App crash with the following message: 这样做时,我的应用程序崩溃并显示以下消息:

Assertion failure in -[KeychainItemWrapper writeToKeychain],  /Users/omid/Documents/Workspace/Xcode workspace/Directory/KeychainItemWrapper.m:305
2012-11-11 19:51:48.860 Directory[4162:907] *** Terminating app due to uncaught exception  'NSInternalInconsistencyException', reason: 'Couldn't add the Keychain Item.'
First throw call stack:
(0x32c7c2a3 0x33b3a97f 0x32c7c15d 0x348252af 0x32cbf 0x3230f 0x43aad 0x3488aef5 0x347ca9f1  0x347ca90d 0x39d9d5df 0x39d9cccb 0x39dc5133 0x32bc274d 0x39dc5593 0x39d2915d 0x32c51683  0x32c50ee9 0x32c4fcb7 0x32bc2ebd 0x32bc2d49 0x3a9c02eb 0x3a47e2f9 0x1ac69 0x1a140)

Update: That's the script I use to resign 更新:这是我用来辞职的脚本

IPA="path to the .ipa file"
PROVISION="path to the .mobileprovision file"
CERTIFICATE="iPhone Distribution: a name"
export CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/usr/bin/codesign_allocate"
unzip -q "$IPA"
rm -rf Payload/*.app/_CodeSignature Payload/*.app/CodeResources
cp "$PROVISION" Payload/*.app/embedded.mobileprovision
/usr/bin/codesign -f -s "$CERTIFICATE" --resource-rules Payload/*.app/ResourceRules.plist Payload/*.app
zip -qr resigned.ipa Payload
rm -rf Payload

I would be thankful for any hint. 如有任何提示,我将不胜感激。

looks like you're not correctly code-signing the app. 您似乎未正确对该应用进行代码签名。 the code has no influence on the entitlements. 该代码对权利没有影响。

make sure the bundle identifier is correct and the codesigning works 确保捆绑包标识符正确并且代码签名有效

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

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