Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/registry/runtime: fix loading entities #2606

Merged
merged 1 commit into from
Jan 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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