9

请注意,这个问题是在 2001 年提出的。情况发生了变化。

我有一台需要访问 Junos VPN 的 iOS 设备。Junos 管理员的不透明说明说我必须检索已使用 Apple IPCU 配置到设备的证书。我知道证书在设备上(我可以在“设置”中看到),我可以通过 Mail、Safari 和 Junos App 访问 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);

它失败。我的问题:

  • 这段代码正确吗?其实我知道这不是因为 SecItemCopyMatching退货 errSecItemNotFound

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

在设置中,证书看起来像这样(可悲的是被混淆了)我指定的搜索文本正是设置中显示的文本。

替代文字

Cross 发布到Apple 开发者论坛

4

2 回答 2

6

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

于 2010-12-10T10:45:30.547 回答
1

自 2015 年年中以来,现在有了(在和Safari Services framework旁边,我们现在有了)。具有访问苹果钥匙串的能力,因此可以使用所有身份:) 非常好。WKWebViewUIWebViewSFSafariViewControllerSFSafariViewController

https://developer.apple.com/videos/play/wwdc2015/504/

https://developer.apple.com/library/ios/documentation/SafariServices/Reference/SafariServicesFramework_Ref/index.html#//apple_ref/doc/uid/TP40016218

于 2016-02-25T12:42:39.893 回答