After upgrading to macOS 10.12 Sierra and Xcode 8, code signing is broken for me.
Every time I try to sign an app, no matter how simple, I get /usr/bin/codesign failed with exit code 11.
Retry running codesign.
Occasionally, we encounter build failures in our CI system from codesign with exit code 11 for no apparent reason. Looking in Console.app I see a segmentation fault in thread Dispatch queue: com.apple.security.XPCTimeStampingService. I understand that this means that some error occurred trying to talk to the timestamp server.
This isn't the same issue as OP, but I found this question while investigating my issue.
Encountered the same issue today, but in my case, there were no expired certificates in Keychain. Trick from https://forums.developer.apple.com/thread/65055 worked for me:
I got both issues with a fresh new certificate, so it was not just about the certificate being old. But I got around it by specifying the certificate by ID instead of name — first getting the ID via:
security find-identity -p codesigningand, from the output of that, copying the long hex ID for the key I want, and pasting that into my codesign invocation:
sudo codesign -s 001CA54450805B2D8D1646793D0339BA7EB931D1 --timestamp=none /opt/local/bin/ggdb