@@ -31,9 +31,10 @@ const (
3131 SignCerts = "signcerts"
3232)
3333
34- // GetSigningIdentity retrieves a signing identity from the passed arguments
35- func GetSigningIdentity (mspConfigPath , mspID string , bccspConfig * config.BCCSP ) (driver.SigningIdentity , error ) {
36- mspInstance , err := LoadLocalMSPAt (mspConfigPath , mspID , BCCSPType , bccspConfig )
34+ // GetSigningIdentity retrieves a signing identity from the passed arguments.
35+ // If keyStorePath is empty, then it is assumed that the key is at mspConfigPath/keystore
36+ func GetSigningIdentity (mspConfigPath , keyStorePath , mspID string , bccspConfig * config.BCCSP ) (driver.SigningIdentity , error ) {
37+ mspInstance , err := LoadLocalMSPAt (mspConfigPath , keyStorePath , mspID , BCCSPType , bccspConfig )
3738 if err != nil {
3839 return nil , err
3940 }
@@ -48,7 +49,7 @@ func GetSigningIdentity(mspConfigPath, mspID string, bccspConfig *config.BCCSP)
4849
4950// LoadLocalMSPAt loads an MSP whose configuration is stored at 'dir', and whose
5051// id and type are the passed as arguments.
51- func LoadLocalMSPAt (dir , id , mspType string , bccspConfig * config.BCCSP ) (msp.MSP , error ) {
52+ func LoadLocalMSPAt (dir , keyStorePath , id , mspType string , bccspConfig * config.BCCSP ) (msp.MSP , error ) {
5253 if mspType != BCCSPType {
5354 return nil , errors .Errorf ("invalid msp type, expected 'bccsp', got %s" , mspType )
5455 }
@@ -57,7 +58,7 @@ func LoadLocalMSPAt(dir, id, mspType string, bccspConfig *config.BCCSP) (msp.MSP
5758 return nil , errors .WithMessagef (err , "could not get msp config from dir [%s]" , dir )
5859 }
5960
60- cp , _ , err := GetBCCSPFromConf (dir , bccspConfig )
61+ cp , _ , err := GetBCCSPFromConf (dir , keyStorePath , bccspConfig )
6162 if err != nil {
6263 return nil , errors .WithMessagef (err , "failed to get bccsp from config [%v]" , bccspConfig )
6364 }
@@ -89,7 +90,7 @@ func LoadVerifyingMSPAt(dir, id, mspType string) (msp.MSP, error) {
8990 return nil , errors .WithMessagef (err , "could not get msp config from dir [%s]" , dir )
9091 }
9192
92- cp , _ , err := GetBCCSPFromConf (dir , nil )
93+ cp , _ , err := GetBCCSPFromConf (dir , "" , nil )
9394 if err != nil {
9495 return nil , errors .WithMessagef (err , "failed to get bccsp" )
9596 }
@@ -121,14 +122,17 @@ func LoadLocalMSPSignerCert(dir string) ([]byte, error) {
121122
122123// GetBCCSPFromConf returns a BCCSP instance and its relative key store from the passed configuration.
123124// If no configuration is passed, the default one is used, namely the `SW` provider.
124- func GetBCCSPFromConf (dir string , conf * config.BCCSP ) (bccsp.BCCSP , bccsp.KeyStore , error ) {
125+ func GetBCCSPFromConf (dir string , keyStorePath string , conf * config.BCCSP ) (bccsp.BCCSP , bccsp.KeyStore , error ) {
126+ if len (keyStorePath ) == 0 {
127+ keyStorePath = filepath .Join (dir , "keystore" )
128+ }
125129 if conf == nil {
126- return GetSWBCCSP (dir )
130+ return GetSWBCCSP (keyStorePath )
127131 }
128132
129133 switch conf .Default {
130134 case "SW" :
131- return GetSWBCCSP (dir )
135+ return GetSWBCCSP (keyStorePath )
132136 case "PKCS11" :
133137 return GetPKCS11BCCSP (conf )
134138 default :
@@ -172,7 +176,7 @@ func skiMapper(p11Opts config.PKCS11) func([]byte) []byte {
172176
173177// GetSWBCCSP returns a new instance of the software-based BCCSP
174178func GetSWBCCSP (dir string ) (bccsp.BCCSP , bccsp.KeyStore , error ) {
175- ks , err := sw .NewFileBasedKeyStore (nil , filepath . Join ( dir , "keystore" ) , true )
179+ ks , err := sw .NewFileBasedKeyStore (nil , dir , true )
176180 if err != nil {
177181 return nil , nil , err
178182 }
0 commit comments