title: Codesign says "no identity found" however the identity is on the keychain
body: <p>I am integrating code signing into our builds and have created a custom keychain which is held within the source code tree and used to sign the code (it's copied to <code>~/Library/Keychains</code> before being used, so it's in a well known location).</p>
  
  <p>However when attempting to sign I get an error:</p>
  
  <pre><code>$ /usr/bin/codesign --sign='Mac Developer: John Doe (AA1AAA1AAA)' \
      --keychain=~/Library/Keychains/xxx.keychain \
      dist/64/gmake/release/bin/libmylib.dylib
  
  Mac Developer: John Doe (AA1AAA1AAA): no identity found
  </code></pre>
  
  <p>However:</p>
  
  <pre><code>$ security find-identity -p codesigning ~/Library/Keychains/xxx.keychain
  
  Policy: Code Signing
    Matching identities
    1) 49F2FBE79899DF18A9638AC6B1302E2EB6E079AD "Mac Developer: John Doe (AA1AAA1AAA)"
       1 identities found
  
    Valid identities only
    1) 49F2FBE79899DF18A9638AC6B1302E2EB6E079AD "Mac Developer: John Doe (AA1AAA1AAA)"
  </code></pre>
  
  <p>So I don't understand why <code>codesign</code> is unable to find the identity.</p>
  
  <p>Can anyone suggest a solution? </p>
  
  <p>Note that I have also tried with the identity's SHA-1, with the same result.</p>