在iOS上查找证书

Rog*_*Rog 9 certificate keychain ios

请注意,这个问题是在2001年被问到的.情况发生了变化.

我有一个需要访问Junos VPN的iOS设备.从管理的Junos不透明的指示说,我要检索已供应给使用苹果IPCU设备的证书.我知道证书是设备上(我可以看到它在设置),虽然邮件,Safari和基于Junos应用程序,我可以访问VPN.

Apple文档声明每个应用程序都有自己的钥匙串,但这三个应用程序都可以看到证书.Jusos可以访问IPCU提供的证书,这意味着任何应用都可以访问此证书.但是,当我尝试找到它时:

    CFTypeRef   certificateRef = NULL;                                                  // will hold a ref to the cert we're trying to retrieve
const char *certLabelString = "myCertificateName";                                      // c string of the certificate we're searching for.
CFStringRef certLabel = CFStringCreateWithCString( NULL, certLabelString, kCFStringEncodingUTF8); // the search we need - a string match for a UTF8 String.

const void *keys[] =   { kSecClass, kSecAttrLabel, kSecReturnRef };
const void *values[] = { kSecClassCertificate, certLabel, kCFBooleanTrue };
CFDictionaryRef dict = CFDictionaryCreate(NULL, keys, values, 3, NULL, NULL);       // set up a search to retrieve this certificate.
OSStatus status = SecItemCopyMatching(dict, &certificateRef);                               // Search the keychain, returning in dict

if(status != errSecSuccess)
    NSLog(@"keychain find returned %ld", status);

if(dict)
    CFRelease(dict);
Run Code Online (Sandbox Code Playgroud)

它失败.我的问题:

  • 这段代码是否正确?其实我知道这不是因为 SecItemCopyMatching回报 errSecItemNotFound

  • 我应该使用什么值 certLabelString- 我假设设置中显示的人类可读名称.

在"设置"中,证书看起来像这样(遗憾地模糊不清)我指定的搜索文本正是设置中显示的文本.

替代文字

Cross发布到Apple开发人员论坛

Rog*_*Rog 6

所以答案(在Apple论坛上)是mail.app和Safari.app共享Apple钥匙串标识符,这是唯一可以使用Apple MDM工具推送证书的钥匙串.任何反对这一点的人都应该提出缺陷,以鼓励Apple做正确的事.