在resign app之后无法在Keychain中保存凭据

时间:2012-11-11 18:40:42

标签: ios keychain

我编写了一个应用程序,它使用KeychainItemWrapper类将用户凭据保存在iOS Keychain中。 一切正常,但如果应用程序被拒绝供企业使用,则保存凭据将不再起作用。

我收到以下错误,但应用程序没有崩溃:

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

我发起了以下课程:

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

我还尝试创建一个Entitlements.plist(使用XCode 4.5.2)

enter image description here

和以下代码:

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];

执行此操作时,我收到应用程序崩溃,并显示以下消息:

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)

更新: 那是我用来辞职的剧本

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

我会感激任何提示。

1 个答案:

答案 0 :(得分:0)

看起来您没有正确地对应用进行代码签名。代码对权利没有影响。

确保捆绑标识符正确且代码签名有效

相关问题