Thank you for your reply once again Matt.
I think the solution is pretty close.
I have the PKCS#12/p12 Digital Identity already installed on my device (as a profile).
Can I access it through
getCertArrayFromKeychain()?. If this is possible, what would be the code of this function, or how can I access that Digital Identity?
I am already doing it obtaining the Digital Identity directly from the assets of my project, but I need to do this for every user that wants to use the app (needs to be dynamic, not static), so I need to access that profile installed on the device. This is the code I actually used to do it.
Code Block | let pathToCert = Bundle.main.path(forResource: "aLosada7", ofType: "p12") |
| let localCertificate = NSData(contentsOfFile: pathToCert! )! |
|
| let options = [String(kSecImportExportPassphrase):"yourpassword"] |
| var items: CFArray? = nil |
| let result = SecPKCS12Import(localCertificate, options as CFDictionary, &items) |
|
| if (result != errSecSuccess) { |
| print(result) |
| } |
|
| let info = (items! as NSArray).firstObject! as! NSDictionary |
| let identity = info[String(kSecImportItemIdentity)] as! SecIdentity |
|
| let credentials = URLCredential(identity: identity, certificates: nil, persistence: .forSession) |
Thank you once again for your time. I really appreciate it so much.