static int S_show_identities(int argc, char * argv[]) { int count; int i; CFArrayRef list; OSStatus status; status = EAPSecIdentityListCreate(&list); if (status != noErr) { fprintf(stderr, "EAPSecIdentityListCreate returned %ld\n", (long)status); return (-1); } count = CFArrayGetCount(list); printf("Number of identities: %d\n", count); for (i = 0; i < count; i++) { EAPSecIdentityHandleRef handle; SecIdentityRef identity; CFStringRef username; identity = (SecIdentityRef)CFArrayGetValueAtIndex(list, i); username = identity_copy_username(identity); SCPrint(TRUE, stdout, CFSTR("\n%d. '%@'\n"), i + 1, username); CFRelease(username); handle = EAPSecIdentityHandleCreate(identity); dump_as_xml(handle); CFRelease(handle); } CFRelease(list); return (0); }
static void tests(void) { SSLContextRef ctx = NULL; SecIdentityRef identity; CFArrayRef list = NULL; CFArrayRef trust_chain; AddIdentityToKeychain(); EAPSecIdentityListCreate(&list); identity = (SecIdentityRef)CFArrayGetValueAtIndex(list, 0); is(CFGetRetainCount(identity), 1, "identity rc = 1"); ok_status(EAPSecIdentityCreateIdentityTrustChain(identity, &trust_chain), "EAPSecIdentityCreateIdentityTrustChain"); ok(ctx=SSLCreateContext(NULL, kSSLClientSide, kSSLStreamType), "SSLNewContext"); ok_status(SSLSetCertificate(ctx, trust_chain), "SSLSetCertificate"); CFReleaseNull(ctx); DeleteIdentityFromKeychain(); CFRelease(trust_chain); CFReleaseNull(list); }