Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Verifying app's signature by code [duplicate]

I have app signed. I created an identity and used codesign to sign my app as per Apple's Code Signing Guide.

Now, how do I check the signature from within my application?

I need to verify this on Cocoa apps (Objective-C) and apps written in C.

like image 331
Mr Aleph Avatar asked Jan 10 '12 21:01

Mr Aleph


1 Answers

You could use NSTask and run "codesign --verify" and check the exit status. Of corse if the program was altered it could be altered to remove the check, so I'm not sure what that buys you.

If you are not worried about directed tampering (like the kind that might remove your check of the signature) you can use the codesign "kill" option, if you do merely executing means the signature is valid (at least for all pages that have been executed so far...but if a not-yet-resident page has been tampered with you will get killed when that one is read in anyway).

Maybe if you could explain a little more about why you want to verify the signature a better answer could be formed.

like image 60
Stripes Avatar answered Sep 20 '22 00:09

Stripes