fixing timestamp key retrieval

Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
This commit is contained in:
David Lawrence 2015-07-24 18:05:27 -07:00
parent 37bced3efa
commit 47f651ef8a
4 changed files with 11 additions and 2 deletions

2
Godeps/Godeps.json generated
View File

@ -63,7 +63,7 @@
},
{
"ImportPath": "github.com/endophage/gotuf",
"Rev": "374908abc8af7e953a2813c5c2b3944ab625ca68"
"Rev": "5f508200b262dc8f56362523f621417853192812"
},
{
"ImportPath": "github.com/go-sql-driver/mysql",

View File

@ -5,3 +5,9 @@ type ErrMetaNotFound struct{}
func (err ErrMetaNotFound) Error() string {
return "no trust data available"
}
type ErrKeyNotAvailable struct{}
func (err ErrKeyNotAvailable) Error() string {
return "could not retrieve timestamp public key"
}

View File

@ -204,6 +204,9 @@ func (s HTTPStore) GetKey(role string) ([]byte, error) {
if err != nil {
return nil, err
}
if resp.StatusCode != 200 {
return nil, ErrKeyNotAvailable{}
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {

View File

@ -176,7 +176,7 @@ func GetTimestampKeyHandler(ctx context.Context, w http.ResponseWriter, r *http.
key, err := timestamp.GetOrCreateTimestampKey(gun, store, crypto, data.ED25519Key)
if err != nil {
logrus.Debugf("[Notary Server] 500 GET timestamp key: %s", gun)
logrus.Debugf("[Notary Server] 500 GET timestamp key for %s: %v", gun, err)
return errors.ErrUnknown.WithDetail(err)
}