Skip to content

Commit

Permalink
[FAB-18323] CherryPick: remove ephemeral from BCCSP SW options (#1553)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Sykes <matthew.sykes@gmail.com>
Signed-off-by: Wenjian Qiao <wenjianq@gmail.com>
  • Loading branch information
sykesm authored and guoger committed Dec 4, 2020
1 parent 25d99ba commit 746b7e9
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 15 deletions.
2 changes: 1 addition & 1 deletion bccsp/factory/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ BCCSP:
cfgVariations := []*FactoryOpts{
{},
{ProviderName: "SW"},
{ProviderName: "SW", SwOpts: &SwOpts{HashFamily: "SHA2", SecLevel: 256, Ephemeral: true}},
{ProviderName: "SW", SwOpts: &SwOpts{HashFamily: "SHA2", SecLevel: 256}},
jsonBCCSP,
yamlBCCSP,
}
Expand Down
2 changes: 0 additions & 2 deletions bccsp/factory/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ func GetDefaultOpts() *FactoryOpts {
SwOpts: &SwOpts{
HashFamily: "SHA2",
SecLevel: 256,

Ephemeral: true,
},
}
}
Expand Down
1 change: 0 additions & 1 deletion bccsp/factory/pkcs11_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ func TestSetFactoriesInvalidArgs(t *testing.T) {
func TestGetBCCSPFromOpts(t *testing.T) {
opts := GetDefaultOpts()
opts.SwOpts.FileKeystore = &FileKeystoreOpts{KeyStorePath: os.TempDir()}
opts.SwOpts.Ephemeral = false
csp, err := GetBCCSPFromOpts(opts)
assert.NoError(t, err)
assert.NotNil(t, csp)
Expand Down
11 changes: 3 additions & 8 deletions bccsp/factory/swfactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ func (f *SWFactory) Get(config *FactoryOpts) (bccsp.BCCSP, error) {
swOpts := config.SwOpts

var ks bccsp.KeyStore
if swOpts.Ephemeral == true {
ks = sw.NewDummyKeyStore()
} else if swOpts.FileKeystore != nil {
if swOpts.FileKeystore != nil {
fks, err := sw.NewFileBasedKeyStore(nil, swOpts.FileKeystore.KeyStorePath, false)
if err != nil {
return nil, errors.Wrapf(err, "Failed to initialize software key store")
Expand All @@ -65,11 +63,8 @@ func (f *SWFactory) Get(config *FactoryOpts) (bccsp.BCCSP, error) {
// SwOpts contains options for the SWFactory
type SwOpts struct {
// Default algorithms when not specified (Deprecated?)
SecLevel int `mapstructure:"security" json:"security" yaml:"Security"`
HashFamily string `mapstructure:"hash" json:"hash" yaml:"Hash"`

// Keystore Options
Ephemeral bool `mapstructure:"tempkeys,omitempty" json:"tempkeys,omitempty"`
SecLevel int `mapstructure:"security" json:"security" yaml:"Security"`
HashFamily string `mapstructure:"hash" json:"hash" yaml:"Hash"`
FileKeystore *FileKeystoreOpts `mapstructure:"filekeystore,omitempty" json:"filekeystore,omitempty" yaml:"FileKeyStore"`
DummyKeystore *DummyKeystoreOpts `mapstructure:"dummykeystore,omitempty" json:"dummykeystore,omitempty"`
InmemKeystore *InmemKeystoreOpts `mapstructure:"inmemkeystore,omitempty" json:"inmemkeystore,omitempty"`
Expand Down
1 change: 0 additions & 1 deletion msp/configbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ func SetupBCCSPKeystoreConfig(bccspConfig *factory.FactoryOpts, keystoreDir stri
// Only override the KeyStorePath if it was left empty
if bccspConfig.SwOpts.FileKeystore == nil ||
bccspConfig.SwOpts.FileKeystore.KeyStorePath == "" {
bccspConfig.SwOpts.Ephemeral = false
bccspConfig.SwOpts.FileKeystore = &factory.FileKeystoreOpts{KeyStorePath: keystoreDir}
}
}
Expand Down
2 changes: 0 additions & 2 deletions orderer/common/server/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ func TestLoadLocalMSP(t *testing.T) {
SwOpts: &factory.SwOpts{
HashFamily: "SHA2",
SecLevel: 256,
Ephemeral: true,
},
},
},
Expand Down Expand Up @@ -764,7 +763,6 @@ func genesisConfig(t *testing.T) *localconfig.TopLevel {
SwOpts: &factory.SwOpts{
HashFamily: "SHA2",
SecLevel: 256,
Ephemeral: true,
},
},
},
Expand Down

0 comments on commit 746b7e9

Please sign in to comment.