title: CodeSign collisions between Developer and Enterprise Distribution
body: <p>My company uses one build machine (a Mac Mini) as a CI node to build our iOS app. We currently build an Ad-Hoc and an App Store config on the mini. We've recently enrolled in the Enterprise Program and want to start building an Enterprise config as well. However, our build process now fails, because we now have two certificates called "iPhone Distribution: Widget Corporation". One is the distribution cert for AdHoc/AppStore, and one is for Enterprise (Apple calls it In-House).</p>
  
  <p>I've tried modifying the mini's keychains such that one cert is in the login keychain and one is in a new keychain called "enterprise", but this just shifted the error from the start of the build:</p>
  
  <pre><code>CodeSign error: Certificate identity 'iPhone Distribution: Widget Corporation' appears more than once in the keychain.
  </code></pre>
  
  <p>to the end of the build:</p>
  
  <pre><code>iPhone Distribution: Widget Corporation: ambiguous (matches "iPhone Distribution: Widget Corporation" in /Users/hudson.admin/Library/Keychains/login.keychain and "iPhone Distribution: Widget Corporation" in /Users/hudson.admin/Library/Keychains/enterprise.keychain)
  </code></pre>
  
  <p>My question is whether or not there's a way to properly sandbox the two certificates so I can build Ad-Hoc, App Store, and In-House versions of the app on the same machine. The only possible solution I've yet to try is to actually bundle the certs along with the source and use <code>security</code> to add and delete the certificates as I need them; clearly that solution isn't very pretty and poses security risks.</p>
  
  <p>Any ideas?</p>