objective c - Accessing OS X keychain item from trusted application -



objective c - Accessing OS X keychain item from trusted application -

i'm creating keychain , i'm adding item predefined trusted aplication list it:

seckeychaincreate([keychainpath utf8string], (uint32)strlen(keychainpass), keychainpass, false, null, &somekeychain); osstatus somestatus = seckeychainitemcreatefromcontent(ksecgenericpassworditemclass, &list, len, encryptedpass, somekeychain, accessref, &somekeychainitem);

when open newly created keychain keychain access application, can see application on trusted app list:

the problem is, when seek read key keychain through 1 of trusted applications

seckeychainunlock(somekeychain, (uint32)strlen(keychainpass), keychainpass, true); uint32 passwordlen = 0; void *passdata = nil; const char *cuser_name = [nsusername() cstringusingencoding:nsutf8stringencoding]; osstatus genericpasserr = seckeychainfindgenericpassword(somekeychain, 0, null, strlen(cuser_name), cuser_name, &passwordlen, &passdata, null);

genericpasserr equals -25293, means error: 0xffff9d33 -25293 user name or passphrase entered not correct.

earlier in code, run seckeychainsetuserinteractionallowed(0), , if comment line out, prompted scheme permission application access keychain, , if grant it, runs fine. however, whole point need able without prompting user. , expect work since added app acl. know doing wrong?

everything works without prompt when tick "all programs have access item" radio box in attached screenshot. don't want able access it, listed apps.

i able create similar test programme work. however, had remove , re-add tool allowed list after each time had rebuilt it. did same error code when not doing that.

here's code:

#import <foundation/foundation.h> #import <security/security.h> int main() { @autoreleasepool { seckeychainref kc; osstatus status = seckeychainsetuserinteractionallowed(false); printf("status: %d\n", status); status = seckeychainopen("/users/tsnorri/library/keychains/test.keychain", &kc); printf("status: %d\n", status); { char const *keychainpass = "test123"; status = seckeychainunlock(kc, (uint32) strlen(keychainpass), keychainpass, true); cfstringref err = seccopyerrormessagestring(status, null); printf("status: %d err: %s\n", status, [(id) err utf8string]); cfrelease(err); } uint32 passwordlen = 0; void *passdata = null; char const *username = "tsnorri"; char const *servicename = "test"; { seckeychainitemref item = null; status = seckeychainfindgenericpassword(kc, strlen(servicename), servicename, strlen(username), username, &passwordlen, &passdata, &item); cfstringref err = seccopyerrormessagestring(status, null); printf("status: %d err: %s\n", status, [(id) err utf8string]); cfrelease(err); } printf("pass: %s\n", passdata); } homecoming 0; }

objective-c cocoa keychain security-framework sfauthorizationpluginview

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -