请注意,这个问题是在 2001 年提出的。情况已经发生变化。
我有一台 iOS 设备需要访问 Junos VPN。来自 Junos 管理员的不透明说明说我必须检索已使用 Apple IPCU 提供给设备的证书。我知道证书在设备上(我可以在“设置”中看到它)并且我可以通过 Mail、Safari 和 Junos App 访问 VPN。
Apple 文档指出每个应用程序都有自己的钥匙串(keychain),但所有这三个应用程序都可以看到证书。 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
- 我假设 人类可读的名称显示在 设置。
在“设置”中,证书看起来像这样(可悲的是被混淆了)我指定的搜索文本正是设置中显示的文本。
交叉发布到 Apple developer forums
最佳答案
所以答案(在 Apple forums 上)是 mail.app 和 Safari.app 共享 Apple 钥匙串(keychain)标识符,这是唯一可以使用 Apple MDM 工具将证书推送到的钥匙串(keychain)。任何其他反对这个的人都应该 file a defect以鼓励 Apple 做正确的事。
关于ios - 在 iOS 上查找证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4378892/