Skip to content

Instantly share code, notes, and snippets.

@pesterhazy
Created February 16, 2016 11:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pesterhazy/0c176b6ee28d8fa2a944 to your computer and use it in GitHub Desktop.
Save pesterhazy/0c176b6ee28d8fa2a944 to your computer and use it in GitHub Desktop.
Reset code signing certificates to fix builds using `gym`
#!/usr/bin/env bash
# nuke-certs
#
#
# This script has been reported to help with errors like
#
# this:
# + xcodebuild -exportArchive -exportOptionsPlist /var/folders/rj/8lnf662s3mlgzv5mcq2r2fnc0000gn/T/gym20160216-41694-14bt0ur_config.plist -archivePath '/Users/pe/Library/Developer/Xcode/Archives/2016-02-16/016-02-16 12.09.02.xcarchive' -exportPath /var/folders/rj/8lnf662s3mlgzv5mcq2r2fnc0000gn/T/gym20160216-41694-17mfck9.gym_output
# 2016-02-16 12:10:03.004 xcodebuild[43629:464102] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/rj/8lnf662s3mlgzv5mcq2r2fnc0000gn/T/016-02-16_12-10-03.003.xcdistributionlogs'.
# 2016-02-16 12:10:03.396 xcodebuild[43629:464102] [MT] IDEDistribution: Step failed: <IDEDistributionSigningAssetsStep: 0x7fbd34d0e550>: Error Domain=IDEDistributionErrorDomain Code=1 "The operation couldn’t be completed. (IDEDistributionErrorDomain error 1.)"
# error: exportArchive: The operation couldn’t be completed. (IDEDistributionErrorDomain error 1.)
# Error Domain=IDEDistributionErrorDomain Code=1 "The operation couldn’t be completed. (IDEDistributionErrorDomain error 1.)"
#
# see https://github.com/fastlane/gym/issues/100
#
# Original credit to @izqui
set -x
set -eou
cd "$TMPDIR"
sudo security delete-certificate -c "Apple Worldwide Developer Relations Certification Authority" /Library/Keychains/System.keychain || true
security delete-certificate -c "Apple Worldwide Developer Relations Certification Authority" /Library/Keychains/login.keychain || true
rm -f "AppleWWDRCA.cer"
curl -O -L http://developer.apple.com/certificationauthority/AppleWWDRCA.cer
security import AppleWWDRCA.cer -k ~/Library/Keychains/login.keychain -A || true
@lluisgerard
Copy link

Just in case somebody had the same issue I had, sudo didn't work for me either. The error made reference to the ambiguity of the certificate name "Apple Worldwide..." (because there is more than one certificate with the same name, even though you give it also the path+name). The only way I could solve it was deleting these certs in the Keychain app.

@glesage
Copy link

glesage commented Feb 16, 2016

gotta specify the hash (:

sudo security delete-certificate -Z 0950B6CD3D2F37EA246A1AAA20DFAADBD6FE1F75 /Library/Keychains/System.keychain works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment