title: C++ macOS - Programmatically retrieve code sign certificate information
body: <p>On Windows, there is a possibility to get a .exe/.dll code sign certificate using <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa380264(v=vs.85).aspx" rel="nofollow noreferrer">CryptQueryObject</a>.</p>
  
  <p>Is there any c++ (or objective-c) alternative to retrieve the <strong>Subject name</strong> and the <strong>Serial number</strong> of the certificate which has been used to code sign an .app on macOS ?</p>
  
  <p>I don't have problem to code sign my .app using xcode, and when Im in the terminal, Im able to see that my code has been sign with the proper certificate.</p>
  
  <hr>
  
  <p><strong>EDIT:</strong></p>
  
  <p>The idea is to get something like this command line, but in C++.</p>
  
  <pre><code>codesign -v --extract-certificates MyApp.app/ 
  | openssl x509 -inform DER -in codesign0 -text 
  | grep "Serial" -A 1
  </code></pre>