Skip to content

Instantly share code, notes, and snippets.

@jjgod
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjgod/f7179a0a658b2ea1c624 to your computer and use it in GitHub Desktop.
Save jjgod/f7179a0a658b2ea1c624 to your computer and use it in GitHub Desktop.
Build with `clang -framework CoreFoundation -Wall -framework Security KeychainTest.c -o kctest`
#include <sys/param.h>
#include <Security/Security.h>
static void displayName(const void *value, void *context)
{
SecKeychainRef keychain = (SecKeychainRef) value;
UInt32 pathLength = MAXPATHLEN;
char pathName[MAXPATHLEN + 1];
SecKeychainGetPath(keychain, &pathLength, pathName);
printf(" \"%*s\"\n", (int)pathLength, pathName);
}
int main() {
CFArrayRef searchList = NULL;
SecKeychainCopySearchList(&searchList);
CFRange range = { 0, CFArrayGetCount(searchList) };
CFArrayApplyFunction(searchList, range, displayName, NULL);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment