I can't take full credit for this. I found it here and added a little bit to the end that I needed in my case.
Create readcert.m with these contents:
#import <Security/Security.h>
#import <Foundation/Foundation.h>
void checkCerts () {
OSStatus status;
const void *keys[] = {
kSecClass,
kSecReturnRef,
kSecMatchLimit
};
const void *values[] = {
kSecClassCertificate,
kCFBooleanTrue,
kSecMatchLimitAll
};
CFDictionaryRef query = CFDictionaryCreate(NULL, keys, values, 3, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFArrayRef results;
if ((status = SecItemCopyMatching((CFDictionaryRef) query, (CFTypeRef *)&results)) != noErr) {
NSLog(@"Failed to copy certificates: %d", status);
return;
}
CFIndex count = CFArrayGetCount(results);
CFIndex i;
for (i = 0; i < count; i++) {
SecCertificateRef cert = (SecCertificateRef) CFArrayGetValueAtIndex(results, i);
CFErrorRef error;
CFDictionaryRef vals = SecCertificateCopyValues(cert, NULL, &error);
if (vals == NULL) {
CFStringRef subjectSummary = SecCertificateCopySubjectSummary(cert);
NSLog(@"Found a triggering certificate: %@", subjectSummary);
}
}
CFRelease(results);
}
int main (int argc, char *argv[]) {
NSAutoreleasePool *p = [[NSAutoreleasePool alloc] init];
checkCerts();
[p release];
return 0;
}
Then, compile it with:
clang -o readcert readcert.m -framework Security -framework Foundation
Then run it:
./readcert
It should output the name of the bad certificate. In my case, it was a certificate from a Linksys router. I deleted the certificate from my keychain, but Xcode was still crashing and readcert was still saying it was there, so I ended up executing this command.
sudo security delete-certificate -c Linksys_WRVS4400Nv2
I'm not sure where the certificate was coming from, I didn't see it in the login or system keychains, but after deleting it from the command line, everything was peachy again in Xcode.