[MacRuby-devel] retrieving password from keychain

Karl Varga kjvarga at gmail.com
Sun Apr 19 20:17:02 PDT 2009

Hi there,

I am having a strange problem that other people don't seem to be
having because I can't find any references to in google searches.  I
am using MacRuby 0.4 installed from the binary available on the
macruby binary releases page (MacRuby version 0.4 (ruby 1.9.1)
[universal-darwin9.5, x86_64])

I have an application which stores username/passwords in the keychain.
 I can add items to the keychain (so I can call
SecKeychainAddGenericPassword() fine and therefore I think my setup
must be OK), but I cannot retrieve them.  When I call:

    status, *data = SecKeychainFindGenericPassword(
        nil, service.length, service, username.length, username)

I get an error:

`SecKeychainFindGenericPassword': wrong number of arguments (5 for 8)

The method signature is this:

OSStatus SecKeychainFindGenericPassword (
   CFTypeRef keychainOrArray,
   UInt32 serviceNameLength,
   const char *serviceName,
   UInt32 accountNameLength,
   const char *accountName,
   UInt32 *passwordLength,
   void **passwordData,
   SecKeychainItemRef *itemRef

All the examples I've read suggest that this method in macruby should
only take 5 args and return the status, password length, password
string and item reference (the last 3 extracted from *data) instead of
passing in pointers (which I don't know how to do BTW).

What gives?  Anyone have any idea or had the same problem?

Karl Varga
kjvarga at gmail.com
Cell: +61 (0)4 2075 1356

More information about the MacRuby-devel mailing list