If you were writing C you would have written
SecKeychainRef keyChainRef;
SecKeychainOpen("/path/to/...", &keychainRef);
SecKeychainLock(keyChainRef);
i.e. while SecKeychainOpen requires a pointer to a SecKeychainRef
(so that the output parameter can be filled in), other apis just require a SecKeychainRef
, so you need to dereference the pointer:
framework 'Security'
keychainObject = Pointer.new_with_type('^{OpaqueSecKeychainRef}')
SecKeychainOpen("/Users/charbon/Library/Keychains/Josja.keychain",keychainObject)
SecKeychainLock(keychainObject.value)