[quote='833855022, DTS Engineer, /thread/779910?answerId=833855022#833855022']
Note that the --raw option gives you machine readable output, which is a step up from pkgutil.
[/quote]
The raw output in spctl sounds interesting. Thanks for pointing it out. We will look into it.
Our current dilemma why we also considered relying on spctl is because xar API returns us subject names as strings. I haven't seen yet a way to distinguish between subjects specific to Apple vs. company specific certificates.
So when we extract information from a Developer ID Installer certificate, it gives an array like this
["", "G2", "Apple Certification Authority"]
This is the result of using
xar_signature_get_x509certificate_data
API and then passing the data to
SecCertificateCopyValues
API to extract
kSecOIDX509V1SubjectName
field
We would like to make sure that the signature contains only authorized team IDs to prevent cases where unexpected team IDs are present in addition to the expected one.
The problem that sparked this discussion was the fact that the certificate that corresponds to "", the actual Developer ID Installer certificate, is not trusted by a clean system. The certificates higher in the chain are trusted. Those with subject names "G2" and "Apple Certification Authority".
So we cannot put a requirement for Developer ID Installer to be passing
SecTrustEvaluateWithError
check.
That is why spctl command was considered as a replacement to xar. In a way, spctl covers both bits on the validation that we are interested in. It can check that Gatekeeper accepts the package and it provides the teamID information.