Skip to content

Commit

Permalink
Merge pull request #2606 from oasislabs/ptrus/fix/cmd-registry
Browse files Browse the repository at this point in the history
cmd/registry/runtime: fix loading entities
  • Loading branch information
ptrus authored Jan 28, 2020
2 parents 6a99a0a + 57887f7 commit 82ece0a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
1 change: 1 addition & 0 deletions .changelog/2606.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cmd/registry/runtime: fix loading entities in registry runtime cmd commands
21 changes: 8 additions & 13 deletions go/oasis-node/cmd/registry/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import (
"github.com/oasislabs/oasis-core/go/common/cbor"
"github.com/oasislabs/oasis-core/go/common/crypto/hash"
"github.com/oasislabs/oasis-core/go/common/crypto/signature"
fileSigner "github.com/oasislabs/oasis-core/go/common/crypto/signature/signers/file"
"github.com/oasislabs/oasis-core/go/common/entity"
"github.com/oasislabs/oasis-core/go/common/logging"
"github.com/oasislabs/oasis-core/go/common/node"
"github.com/oasislabs/oasis-core/go/common/sgx"
Expand Down Expand Up @@ -236,7 +234,14 @@ func runtimeFromFlags() (*registry.Runtime, signature.Signer, error) {
return nil, nil, fmt.Errorf("invalid TEE hardware")
}

_, signer, err := loadEntity(cmdFlags.Signer())
entityDir, err := cmdFlags.SignerDirOrPwd()
if err != nil {
logger.Error("failed to retrieve signer dir",
"err", err,
)
return nil, nil, fmt.Errorf("failed to retrive signer dir")
}
_, signer, err := cmdCommon.LoadEntity(cmdFlags.Signer(), entityDir)
if err != nil {
logger.Error("failed to load owning entity",
"err", err,
Expand Down Expand Up @@ -434,16 +439,6 @@ func signForRegistration(rt *registry.Runtime, signer signature.Signer, isGenesi
return signed, err
}

func loadEntity(dataDir string) (*entity.Entity, signature.Signer, error) {
if cmdFlags.DebugTestEntity() {
return entity.TestEntity()
}

// TODO/hsm: Configure factory dynamically.
entitySignerFactory := fileSigner.NewFactory(dataDir, signature.SignerEntity)
return entity.Load(dataDir, entitySignerFactory)
}

// Register registers the runtime sub-command and all of it's children.
func Register(parentCmd *cobra.Command) {
for _, v := range []*cobra.Command{
Expand Down

0 comments on commit 82ece0a

Please sign in to comment.