Ok, @eskimo, I am too dumb to figure this out. In particular, "a requirement that identifies the code you care about" (and note that I'm not getting messages via just XPC). I've gone over the code signing documents, and there's just so much "use a requirement that specifies what you want" without showing me enough about how to get what I want...
There are multiple ways to express what I would like to do. I think I can easily break them down into two types. For these, I'm going to use B as some random process, and A as the process trying to do the checking. (A might be a network extension, an endpoint security process, or just sampling random pids so it can kill them off and see how things respond.)
A wants to see if B is "legitimately signed." I believe "anchor apple or anchor apple generic" is a good starting place. But I also want to ensure that the Identifier belongs to whoever signed it. E.g., if it's signed "com.apple.sh" but was signed that way by me, that's not legitimate. Is there a way to tell that?
A wants to see if B is part of its own organization. This would mean that they're signed the same way (e.g., same signing identity). (I was thinking about checking the identifier, but if A can see that B has the same signing identity as it, as long as it's not adhock 😄, that's correct.) If I use SecCodeCopySigningInformation(), with kSecCSSigningInformation, and then look for kSecCodeInfoCertificates in the dictionary... can I just check to see if they're all the same? Just a simple comparison of each element in each array?
Maybe (2) is in fact so easy I just described it. But what about (1)?