@ JamesBucanek, чем вы за ссылку!Вот результирующий код с использованием API Keychain Services.Может быть, это будет полезно другим людям:
let query: [String: Any] = [
kSecClass as String: kSecClassIdentity,
kSecReturnRef as String: kCFBooleanTrue,
kSecMatchLimit as String: kSecMatchLimitAll
]
var items: CFTypeRef?
// Get list of all SecIdentity from Keychain without limiting search and without any filtering applied
guard SecItemCopyMatching(query as CFDictionary, &items) == errSecSuccess, let array = items as? NSArray else {
return
}
for item in array {
let identity = item as! SecIdentity
var certificate: SecCertificate?
// Get SecCertificate out of SecIdentity object (it contains both SecCertificate and SecKey
if SecIdentityCopyCertificate(identity, &certificate) == errSecSuccess {
var commonName: CFString?
// Print name for each certificate
if SecCertificateCopyCommonName(certificate!, &commonName) == errSecSuccess {
print(commonName! as String)
}
}
}