Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit 1309704

Browse files
committed
[FAB-8866] Handle old config naming for file store
Change-Id: Ieeb1932c05f0275716cc021f951a5ab5e155b8f4 Signed-off-by: Troy Ronda <troy@troyronda.com>
1 parent 9f6e5f6 commit 1309704

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

pkg/msp/filecertstore.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ import (
1818
)
1919

2020
// NewFileCertStore ...
21-
func NewFileCertStore(cryptoConfogMspPath string) (core.KVStore, error) {
22-
_, orgName := path.Split(path.Dir(path.Dir(path.Dir(cryptoConfogMspPath))))
21+
func NewFileCertStore(cryptoConfigMSPPath string) (core.KVStore, error) {
22+
_, orgName := path.Split(path.Dir(path.Dir(path.Dir(cryptoConfigMSPPath))))
2323
opts := &keyvaluestore.FileKeyValueStoreOptions{
24-
Path: cryptoConfogMspPath,
24+
Path: cryptoConfigMSPPath,
2525
KeySerializer: func(key interface{}) (string, error) {
2626
ck, ok := key.(*msp.CertKey)
2727
if !ok {
@@ -30,7 +30,10 @@ func NewFileCertStore(cryptoConfogMspPath string) (core.KVStore, error) {
3030
if ck == nil || ck.MSPID == "" || ck.Username == "" {
3131
return "", errors.New("invalid key")
3232
}
33-
certDir := path.Join(strings.Replace(cryptoConfogMspPath, "{username}", ck.Username, -1), "signcerts")
33+
34+
// TODO: refactor to case insensitive or remove eventually.
35+
r := strings.NewReplacer("{userName}", ck.Username, "{username}", ck.Username)
36+
certDir := path.Join(r.Replace(cryptoConfigMSPPath), "signcerts")
3437
return path.Join(certDir, fmt.Sprintf("%s@%s-cert.pem", ck.Username, orgName)), nil
3538
},
3639
}

pkg/msp/filekeystore.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ import (
1818
)
1919

2020
// NewFileKeyStore ...
21-
func NewFileKeyStore(cryptoConfogMspPath string) (core.KVStore, error) {
21+
func NewFileKeyStore(cryptoConfigMSPPath string) (core.KVStore, error) {
2222
opts := &keyvaluestore.FileKeyValueStoreOptions{
23-
Path: cryptoConfogMspPath,
23+
Path: cryptoConfigMSPPath,
2424
KeySerializer: func(key interface{}) (string, error) {
2525
pkk, ok := key.(*msp.PrivKeyKey)
2626
if !ok {
@@ -29,7 +29,11 @@ func NewFileKeyStore(cryptoConfogMspPath string) (core.KVStore, error) {
2929
if pkk == nil || pkk.MSPID == "" || pkk.Username == "" || pkk.SKI == nil {
3030
return "", errors.New("invalid key")
3131
}
32-
keyDir := path.Join(strings.Replace(cryptoConfogMspPath, "{username}", pkk.Username, -1), "keystore")
32+
33+
// TODO: refactor to case insensitive or remove eventually.
34+
r := strings.NewReplacer("{userName}", pkk.Username, "{username}", pkk.Username)
35+
keyDir := path.Join(r.Replace(cryptoConfigMSPPath), "keystore")
36+
3337
return path.Join(keyDir, hex.EncodeToString(pkk.SKI)+"_sk"), nil
3438
},
3539
}

0 commit comments

Comments
 (0)