The codesign command should be:
codesign -s "Developer ID Application: Certificate Common Name" dist/MyCool.app
You also need to add the intermediate certificates from Apple (in case you haven't added those to your keychain).
- Developer ID Certification Authority
Apple Worldwide Developer Relations Certification Authority (WWDR)
- http://www.apple.com/certificateauthority/
- Download the Intermediate Certificates listed.
- Add them to your keychain
Also, take a look at the Apple Developer Codesigning Workflow Guide