[v0.9.0] osxkeychain: fix regressions on get and list #361
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
- What I did
osxkeychain: list: do not error out when keychain is empty
Commit 4cdcdc2 replaced the in-tree Objective-C code with github.com/keybase/go-keychain and inadvertently introduced a new failure mode on the
List
operation - it now fails when the keychain is empty.Before:
After:
osxkeychain: store: use Apple's proto consts
Commit 4cdcdc2 swapped consts
kSecProtocolTypeHTTPS
andkSecProtocolTypeHTTP
with plain-text "https" and "http" strings.This is causing a regression where credentials stored with prior versions (< v0.9.0) can't be fetched anymore.
Unfortunately we can't just revert back to using Objective-C consts, as these are unsigned integers that need to be converted into
CFStringRef
and then passed to an helper likekeychain.CFStringToString
.Although
keychain.CFStringToString
is exported, it takes a C typeC.CFStringRef
so it's not consumable from other packages due to Cgo restrictions:We could alternatively copy
keychain.CFStringToString
into theosxkeychain
package, but this commit takes a simpler approach: just hardcode the value ofkSecProtocolTypeHTTPS
andkSecProtocolTypeHTTP
as strings. (These consts are very unlikely to ever change since it'd break all existing consumers.)This is NOT handling backward compatibility with v0.9.0, since it was released only 12hrs ago. So this fix won't work with credentials created with v0.9.0.
- How to verify it
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)