I downloaded a P12 file (containing a private key) from the company server, and retrieved the private key from this P12 file using a password :
private func loadPrivateKeyFromPKCS12(path: String, password: String) throws -> SecKey? {
let p12Data: Data
do {
p12Data = try Data(contentsOf: fileURL)
} catch let readError {
...
}
let options: [CFString: Any] = [
kSecImportExportPassphrase: password as CFString
]
var items: CFArray?
let status = SecPKCS12Import(p12Data as CFData, options as CFDictionary, &items)
guard status == errSecSuccess else {
throw exception
}
var privateKey: SecKey?
let idd = identity as! SecIdentity
let _ = SecIdentityCopyPrivateKey(idd, &privateKey)
return privateKey
}
However, when I use this private key to call SecKeyCreateSignature for data signing, a dialog box always pops up to ask user to input the Mac admin password.
What confuses me is that this private key is clearly stored in the local P12 file, and there should be no access to the keychain involved in this process. Why does the system still require the user's login password for signing?
Is it possible to perform silent signing (without the system dialog popping up) in this scenario?
1
0
79