Skip to content

Commit

Permalink
Merge pull request #21 from 99designs/fix-bug-with-ls
Browse files Browse the repository at this point in the history
Open the keychain and specify it for search, fixes #14
  • Loading branch information
lox committed Sep 28, 2015
2 parents 4e18db1 + 6058ff9 commit 88b46bb
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions keyring/keychain.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@ func (k *OSXKeychain) Keys() ([]string, error) {
C.kSecMatchLimit: C.kSecMatchLimitAll,
C.kSecReturnAttributes: C.CFTypeRef(C.kCFBooleanTrue),
}

kref, err := openKeychain(k.path)
if err != nil {
return nil, err
}

searchArray := arrayToCFArray([]C.CFTypeRef{C.CFTypeRef(kref)})
defer C.CFRelease(C.CFTypeRef(searchArray))
query[C.kSecMatchSearchList] = C.CFTypeRef(searchArray)

queryDict := mapToCFDictionary(query)
defer C.CFRelease(C.CFTypeRef(queryDict))

Expand Down Expand Up @@ -270,6 +280,7 @@ func createKeychain(path string, promptUser bool, password string) (C.SecKeychai

// The returned SecKeychainRef, if non-nil, must be released via CFRelease.
func openKeychain(path string) (C.SecKeychainRef, error) {
log.Printf("opening keychain %s", path)
pathName := C.CString(path)
defer C.free(unsafe.Pointer(pathName))

Expand Down

0 comments on commit 88b46bb

Please sign in to comment.