title: bug? in codesign --remove-signature feature
body: <p>I would like to remove the digital signature from a Mac app that has been signed with codesign. There is an undocumented option to codesign, --remove-signature, which by it's name seems to be what I need. However, I can't get it to work. I realize it is undocumented, but I could really use the functionality. Maybe I'm doing something wrong?</p>
  
  <pre><code> codesign -s MyIdentity foo.app
  </code></pre>
  
  <p>works normally, signing the app</p>
  
  <pre><code> codesign --remove-signature foo.app
  </code></pre>
  
  <p>does disk activity for several seconds, then says</p>
  
  <pre><code> foo.app: invalid format for signature
  </code></pre>
  
  <p>and foo.app has grown to 1.9 GB!!! (Specifically, it is the executable in foo.app/Contents/Resources/MacOS that grows, from 1.1 MB to 1.9 GB.)</p>
  
  <p>The same thing happens when I try to sign/unsign a binary support tool instead of a .app.</p>
  
  <p>Any ideas?</p>
  
  <hr>
  
  <p>Background: This is my own app; I'm not trying to defeat copy protection or anything like that.</p>
  
  <p>I would like to distribute a signed app so that each update to the app won't need user approval to read/write the app's entries in the Keychain. However, some people need to modify the app by adding their own folder to /Resources. If they do that, the signature becomes invalid, and the app can't use it's own Keychain entries.</p>
  
  <p>The app can easily detect if this situation has happened. If the app could then remove it's signature, everything would be fine. Those people who make this modification would need to give the modified, now-unsigned app permission to use the Keychain, but that's fine with me.</p>