我想以人类可读的形式获取 iOS 受信任的根证书列表。通过编写代码或任何工具。我怎么能得到那个?
我从这里尝试了一些类似下面的代码,但它返回 null。状态返回 -25300,即未找到项目。
- (void) readCert2 {
NSMutableDictionary *query = [NSMutableDictionary dictionaryWithObjectsAndKeys:
// (__bridge id)kCFBooleanTrue, (__bridge id)kSecReturnAttributes,
(__bridge id)kCFBooleanTrue, (__bridge id)kSecReturnRef,
(__bridge id)kSecMatchLimitAll, (__bridge id)kSecMatchLimit,
nil];
NSArray *secItemClasses = [NSArray arrayWithObjects:
// (__bridge id)kSecClassGenericPassword,
// (__bridge id)kSecClassInternetPassword,
(__bridge id)kSecClassCertificate,
// (__bridge id)kSecClassKey,
// (__bridge id)kSecClassIdentity,
nil];
for (id secItemClass in secItemClasses) {
[query setObject:secItemClass forKey:(__bridge id)kSecClass];
CFTypeRef result = NULL;
OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, &result);
NSLog(@"%@", (__bridge id)result);
if (result != NULL) CFRelease(result);
}
}