Posts

Post not yet marked as solved
9 Replies
1.8k Views
Hi, we have some code in our xcode project that needs to acces keychain's certificate to use them. We use the SecItemCopyMatching method to get a list of SecCertificate like this: var query = [String: Any]() query[String(kSecClass)] = kSecClassCertificate query[String(kSecMatchLimit)] = kSecMatchLimitAll var result: AnyObject? let status = SecItemCopyMatching(query as CFDictionary, &result) and we are now having troubles making this work with smartcards. We use a Gemalto smartcard that contains a certificate. On our terminal application, when we use "security list-smartcard", we get a line with it's ID. com.gemalto.Gemalto-Smart-Card-Token.PKCS11-Token:XXXXXXXXXXXXXXXX The thing is, in our code, the certificate stored in the smartcard isn't retrieved by our current query. We tried to do a more specific query like this: let getquery: [String: Any] = [kSecClass as String: kSecClassKey, kSecAttrTokenID as String: "com.gemalto.Gemalto-Smart-Card-Token.PKCS11-Token:XXXXXXXXXXXXXXXX", kSecReturnPersistentRef as String: true] but it seems we can't have access to it. results are nil. We believed at first that it was because we didn't add the entitlement "com.apple.security.smartcard" to our project, but we get the same result enabling it. Can somebody provide us some leads about getting SecCertificate that can be used to sign from a smartcard ? Thank you.
Posted
by Brosini.
Last updated
.