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

Remove the ephemeral field from the BCCSP software options #1553

Merged
merged 1 commit into from
Jul 8, 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
2 changes: 1 addition & 1 deletion bccsp/factory/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ BCCSP:
cfgVariations := []*FactoryOpts{
{},
{ProviderName: "SW"},
{ProviderName: "SW", SwOpts: &SwOpts{HashFamily: "SHA2", SecLevel: 256, Ephemeral: true}},
{ProviderName: "SW", SwOpts: &SwOpts{HashFamily: "SHA2", SecLevel: 256}},
yamlBCCSP,
}

Expand Down
1 change: 0 additions & 1 deletion bccsp/factory/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,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 @@ -49,7 +49,6 @@ func TestInitFactoriesInvalidArgs(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
9 changes: 2 additions & 7 deletions bccsp/factory/swfactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ func (f *SWFactory) Get(config *FactoryOpts) (bccsp.BCCSP, error) {

var ks bccsp.KeyStore
switch {
case swOpts.Ephemeral:
ks = sw.NewDummyKeyStore()
case swOpts.FileKeystore != nil:
fks, err := sw.NewFileBasedKeyStore(nil, swOpts.FileKeystore.KeyStorePath, false)
if err != nil {
Expand All @@ -64,11 +62,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"`
}

Expand Down
12 changes: 11 additions & 1 deletion bccsp/pkcs11/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,17 @@ func New(opts PKCS11Opts, keyStore bccsp.KeyStore) (bccsp.BCCSP, error) {
}

sessions := make(chan pkcs11.SessionHandle, sessionCacheSize)
csp := &impl{swCSP, conf, ctx, sessions, slot, pin, lib, opts.SoftVerify, opts.Immutable}
csp := &impl{
BCCSP: swCSP,
conf: conf,
ctx: ctx,
sessions: sessions,
slot: slot,
pin: pin,
lib: lib,
softVerify: opts.SoftVerify,
immutable: opts.Immutable,
}
csp.returnSession(*session)
return csp, nil
}
Expand Down
1 change: 0 additions & 1 deletion msp/configbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,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 msp/configbuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func TestSetupBCCSPKeystoreConfig(t *testing.T) {
bccspConfig.SwOpts = &factory.SwOpts{
HashFamily: "SHA2",
SecLevel: 256,
Ephemeral: true,
}
rtnConfig = SetupBCCSPKeystoreConfig(bccspConfig, keystoreDir)
assert.NotNil(t, rtnConfig.SwOpts.FileKeystore)
Expand Down Expand Up @@ -77,7 +76,6 @@ func TestSetupBCCSPKeystoreConfig(t *testing.T) {
bccspConfig.SwOpts = &factory.SwOpts{
HashFamily: "SHA2",
SecLevel: 256,
Ephemeral: true,
}
rtnConfig = SetupBCCSPKeystoreConfig(bccspConfig, keystoreDir)
assert.NotNil(t, rtnConfig.SwOpts.FileKeystore)
Expand Down
4 changes: 1 addition & 3 deletions orderer/common/server/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package server

import (
"fmt"
"github.com/hyperledger/fabric/orderer/common/onboarding"
"io/ioutil"
"net"
"net/http"
Expand Down Expand Up @@ -38,6 +37,7 @@ import (
"github.com/hyperledger/fabric/orderer/common/cluster"
"github.com/hyperledger/fabric/orderer/common/localconfig"
"github.com/hyperledger/fabric/orderer/common/multichannel"
"github.com/hyperledger/fabric/orderer/common/onboarding"
server_mocks "github.com/hyperledger/fabric/orderer/common/server/mocks"
"github.com/hyperledger/fabric/orderer/consensus"
"github.com/hyperledger/fabric/protoutil"
Expand Down Expand Up @@ -386,7 +386,6 @@ func TestLoadLocalMSP(t *testing.T) {
SwOpts: &factory.SwOpts{
HashFamily: "SHA2",
SecLevel: 256,
Ephemeral: true,
},
},
},
Expand Down Expand Up @@ -917,7 +916,6 @@ func genesisConfig(t *testing.T, genesisFile string) *localconfig.TopLevel {
SwOpts: &factory.SwOpts{
HashFamily: "SHA2",
SecLevel: 256,
Ephemeral: true,
},
},
},
Expand Down