Skip to content

Commit 26274da

Browse files
authored
Merge pull request #361 from akerouanton/fix-regressions-v0.9.0
[v0.9.0] osxkeychain: fix regressions on get and list
2 parents 36a3c50 + f4cdabf commit 26274da

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

osxkeychain/osxkeychain.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ func (h Osxkeychain) List() (map[string]string, error) {
117117
default:
118118
return nil, err
119119
}
120-
} else if len(res) == 0 {
121-
return nil, credentials.NewErrCredentialsNotFound()
122120
}
123121

124122
resp := make(map[string]string)
@@ -131,14 +129,22 @@ func (h Osxkeychain) List() (map[string]string, error) {
131129
return resp, nil
132130
}
133131

132+
const (
133+
// Hardcoded protocol types matching their Objective-C equivalents.
134+
// https://developer.apple.com/documentation/security/ksecattrprotocolhttps?language=objc
135+
kSecProtocolTypeHTTPS = "htps" // This is NOT a typo.
136+
// https://developer.apple.com/documentation/security/ksecattrprotocolhttp?language=objc
137+
kSecProtocolTypeHTTP = "http"
138+
)
139+
134140
func splitServer(serverURL string, item keychain.Item) error {
135141
u, err := registryurl.Parse(serverURL)
136142
if err != nil {
137143
return err
138144
}
139-
item.SetProtocol("https")
145+
item.SetProtocol(kSecProtocolTypeHTTPS)
140146
if u.Scheme == "http" {
141-
item.SetProtocol("http")
147+
item.SetProtocol(kSecProtocolTypeHTTP)
142148
}
143149
item.SetServer(u.Hostname())
144150
if p := u.Port(); p != "" {

0 commit comments

Comments
 (0)