Normally we use sourceAppSigningIdentifier, but it is empty for
non-signed programs. Some users still have them.
Indeed. This is a perfect example of why Apple silicon Macs require that all code be signed, even if it’s only ad hoc signed. It reduces the number of weird edge cases you have to deal with.
We use it to get process name that opens the flow.
That’s not the best way to approach this. Rather, use the audit token to create a code object (
SecCodeCopyGuestWithAttributes) and then use that to get the path to the code (
SecCodeCopyPath). That’s not truly secure — without a code signature you can’t reliably identify code — but it avoids the pid wrapping problem.
Here’s a code snippet:
Code Block let atData: Data = … the audit token as bytes … |
var codeQ: SecCode? = nil |
var err = SecCodeCopyGuestWithAttributes(nil, [ |
kSecGuestAttributeAudit: atData, |
] as NSDictionary, [], &codeQ) |
assert(err == errSecSuccess) |
let code = codeQ! |
|
var staticCodeQ: SecStaticCode? = nil |
err = SecCodeCopyStaticCode(code, [], &staticCodeQ) |
assert(err == errSecSuccess) |
let staticCode = staticCodeQ! |
|
var codeURLQ: CFURL? = nil |
err = SecCodeCopyPath(staticCode, [], &codeURLQ) |
assert(err == errSecSuccess) |
let codeURL = codeURLQ! as URL |
Note that in Swift I have to get the static code from the code, whereas in C-based languages you can treat
SecCode as a ‘subclass’ of
SecStaticCode.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"