Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
| ... | ... |
@@ -895,8 +895,13 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine) (*Daemon, error) |
| 895 | 895 |
return nil, err |
| 896 | 896 |
} |
| 897 | 897 |
|
| 898 |
+ trustKey, err := api.LoadOrCreateTrustKey(config.TrustKeyPath) |
|
| 899 |
+ if err != nil {
|
|
| 900 |
+ return nil, err |
|
| 901 |
+ } |
|
| 902 |
+ |
|
| 898 | 903 |
log.Debugf("Creating repository list")
|
| 899 |
- repositories, err := graph.NewTagStore(path.Join(config.Root, "repositories-"+driver.String()), g) |
|
| 904 |
+ repositories, err := graph.NewTagStore(path.Join(config.Root, "repositories-"+driver.String()), g, trustKey) |
|
| 900 | 905 |
if err != nil {
|
| 901 | 906 |
return nil, fmt.Errorf("Couldn't create Tag store: %s", err)
|
| 902 | 907 |
} |
| ... | ... |
@@ -961,11 +966,6 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine) (*Daemon, error) |
| 961 | 961 |
return nil, err |
| 962 | 962 |
} |
| 963 | 963 |
|
| 964 |
- trustKey, err := api.LoadOrCreateTrustKey(config.TrustKeyPath) |
|
| 965 |
- if err != nil {
|
|
| 966 |
- return nil, err |
|
| 967 |
- } |
|
| 968 |
- |
|
| 969 | 964 |
daemon := &Daemon{
|
| 970 | 965 |
ID: trustKey.PublicKey().KeyID(), |
| 971 | 966 |
repository: daemonRepo, |
| ... | ... |
@@ -16,6 +16,7 @@ import ( |
| 16 | 16 |
"github.com/docker/docker/pkg/archive" |
| 17 | 17 |
"github.com/docker/docker/registry" |
| 18 | 18 |
"github.com/docker/docker/utils" |
| 19 |
+ "github.com/docker/libtrust" |
|
| 19 | 20 |
) |
| 20 | 21 |
|
| 21 | 22 |
// Retrieve the all the images to be uploaded in the correct order |
| ... | ... |
@@ -308,7 +309,26 @@ func (s *TagStore) CmdPush(job *engine.Job) engine.Status {
|
| 308 | 308 |
} |
| 309 | 309 |
|
| 310 | 310 |
if len(manifestBytes) == 0 {
|
| 311 |
- // TODO Create manifest and sign |
|
| 311 |
+ mBytes, err := s.newManifest(repoInfo.LocalName, repoInfo.RemoteName, tag) |
|
| 312 |
+ if err != nil {
|
|
| 313 |
+ return job.Error(err) |
|
| 314 |
+ } |
|
| 315 |
+ js, err := libtrust.NewJSONSignature(mBytes) |
|
| 316 |
+ if err != nil {
|
|
| 317 |
+ return job.Error(err) |
|
| 318 |
+ } |
|
| 319 |
+ |
|
| 320 |
+ if err = js.Sign(s.trustKey); err != nil {
|
|
| 321 |
+ return job.Error(err) |
|
| 322 |
+ } |
|
| 323 |
+ |
|
| 324 |
+ signedBody, err := js.PrettySignature("signatures")
|
|
| 325 |
+ if err != nil {
|
|
| 326 |
+ return job.Error(err) |
|
| 327 |
+ } |
|
| 328 |
+ log.Infof("Signed manifest using daemon's key: %s", s.trustKey.KeyID())
|
|
| 329 |
+ |
|
| 330 |
+ manifestBytes = string(signedBody) |
|
| 312 | 331 |
} |
| 313 | 332 |
|
| 314 | 333 |
manifest, verified, err := s.verifyManifest(job.Eng, []byte(manifestBytes)) |
| ... | ... |
@@ -15,6 +15,7 @@ import ( |
| 15 | 15 |
"github.com/docker/docker/pkg/parsers" |
| 16 | 16 |
"github.com/docker/docker/registry" |
| 17 | 17 |
"github.com/docker/docker/utils" |
| 18 |
+ "github.com/docker/libtrust" |
|
| 18 | 19 |
) |
| 19 | 20 |
|
| 20 | 21 |
const DEFAULTTAG = "latest" |
| ... | ... |
@@ -27,6 +28,7 @@ type TagStore struct {
|
| 27 | 27 |
path string |
| 28 | 28 |
graph *Graph |
| 29 | 29 |
Repositories map[string]Repository |
| 30 |
+ trustKey libtrust.PrivateKey |
|
| 30 | 31 |
sync.Mutex |
| 31 | 32 |
// FIXME: move push/pull-related fields |
| 32 | 33 |
// to a helper type |
| ... | ... |
@@ -54,7 +56,7 @@ func (r Repository) Contains(u Repository) bool {
|
| 54 | 54 |
return true |
| 55 | 55 |
} |
| 56 | 56 |
|
| 57 |
-func NewTagStore(path string, graph *Graph) (*TagStore, error) {
|
|
| 57 |
+func NewTagStore(path string, graph *Graph, key libtrust.PrivateKey) (*TagStore, error) {
|
|
| 58 | 58 |
abspath, err := filepath.Abs(path) |
| 59 | 59 |
if err != nil {
|
| 60 | 60 |
return nil, err |
| ... | ... |
@@ -63,6 +65,7 @@ func NewTagStore(path string, graph *Graph) (*TagStore, error) {
|
| 63 | 63 |
store := &TagStore{
|
| 64 | 64 |
path: abspath, |
| 65 | 65 |
graph: graph, |
| 66 |
+ trustKey: key, |
|
| 66 | 67 |
Repositories: make(map[string]Repository), |
| 67 | 68 |
pullingPool: make(map[string]chan struct{}),
|
| 68 | 69 |
pushingPool: make(map[string]chan struct{}),
|
| ... | ... |
@@ -57,7 +57,7 @@ func mkTestTagStore(root string, t *testing.T) *TagStore {
|
| 57 | 57 |
if err != nil {
|
| 58 | 58 |
t.Fatal(err) |
| 59 | 59 |
} |
| 60 |
- store, err := NewTagStore(path.Join(root, "tags"), graph) |
|
| 60 |
+ store, err := NewTagStore(path.Join(root, "tags"), graph, nil) |
|
| 61 | 61 |
if err != nil {
|
| 62 | 62 |
t.Fatal(err) |
| 63 | 63 |
} |