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

Commit 8d39602

Browse files
committed
[FAB-7528] Update thirdparty pinning scripts
- To accomodate changes done for internal/fabric-ca for embedded cryptoconfig Change-Id: I1bf3d587c56106b3e9892f178399307ac46c2885 Signed-off-by: Sudesh Shetty <sudesh.shetty@securekey.com>
1 parent 9027753 commit 8d39602

File tree

5 files changed

+28
-15
lines changed

5 files changed

+28
-15
lines changed

internal/github.com/hyperledger/fabric-ca/util/csp.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,37 +126,36 @@ func ImportBCCSPKeyFromPEM(keyFile string, myCSP apicryptosuite.CryptoSuite, tem
126126
if err != nil {
127127
return nil, err
128128
}
129-
130129
key, err := ImportBCCSPKeyFromPEMBytes(keyBuff, myCSP, temporary)
131-
132130
if err != nil {
133-
return nil, errors.WithMessage(err, fmt.Sprintf("Failed parsing private key from %s", keyFile))
131+
return nil, errors.WithMessage(err, fmt.Sprintf("Failed parsing private key from key file %s", keyFile))
134132
}
135-
136133
return key, nil
137134
}
138135

139136
// ImportBCCSPKeyFromPEMBytes attempts to create a private BCCSP key from a pem byte slice
140137
func ImportBCCSPKeyFromPEMBytes(keyBuff []byte, myCSP apicryptosuite.CryptoSuite, temporary bool) (apicryptosuite.Key, error) {
138+
keyFile := "pem bytes"
139+
141140
key, err := factory.PEMtoPrivateKey(keyBuff, nil)
142141
if err != nil {
143-
return nil, err
142+
return nil, errors.WithMessage(err, fmt.Sprintf("Failed parsing private key from %s", keyFile))
144143
}
145144
switch key.(type) {
146145
case *ecdsa.PrivateKey:
147146
priv, err := factory.PrivateKeyToDER(key.(*ecdsa.PrivateKey))
148147
if err != nil {
149-
return nil, errors.WithMessage(err, fmt.Sprintf("Failed to convert ECDSA private key"))
148+
return nil, errors.WithMessage(err, fmt.Sprintf("Failed to convert ECDSA private key for '%s'", keyFile))
150149
}
151150
sk, err := myCSP.KeyImport(priv, factory.GetECDSAPrivateKeyImportOpts(temporary))
152151
if err != nil {
153-
return nil, errors.WithMessage(err, fmt.Sprintf("Failed to import ECDSA private key"))
152+
return nil, errors.WithMessage(err, fmt.Sprintf("Failed to import ECDSA private key for '%s'", keyFile))
154153
}
155154
return sk, nil
156155
case *rsa.PrivateKey:
157-
return nil, errors.Errorf("Failed to import RSA key: RSA private key import is not supported")
156+
return nil, errors.Errorf("Failed to import RSA key from %s; RSA private key import is not supported", keyFile)
158157
default:
159-
return nil, errors.Errorf("Failed to import key: invalid secret key type")
158+
return nil, errors.Errorf("Failed to import key from %s: invalid secret key type", keyFile)
160159
}
161160
}
162161

internal/github.com/hyperledger/fabric-ca/util/util.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,17 @@ import (
3131
"io/ioutil"
3232
"math/big"
3333
mrand "math/rand"
34+
35+
"github.com/hyperledger/fabric-sdk-go/api/apicryptosuite"
36+
factory "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkpatch/cryptosuitebridge"
37+
3438
"net/http"
3539
"path/filepath"
3640
"reflect"
3741
"regexp"
3842
"strings"
3943
"time"
4044

41-
"github.com/hyperledger/fabric-sdk-go/api/apicryptosuite"
42-
factory "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkpatch/cryptosuitebridge"
43-
4445
"github.com/hyperledger/fabric-sdk-go/pkg/errors"
4546

4647
"golang.org/x/crypto/ocsp"

internal/github.com/hyperledger/fabric/bccsp/signer/signer.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ package signer
2121

2222
import (
2323
"crypto"
24-
"io"
2524

2625
"github.com/hyperledger/fabric-sdk-go/api/apicryptosuite"
2726

27+
"io"
28+
2829
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/bccsp/utils"
2930
"github.com/hyperledger/fabric-sdk-go/pkg/errors"
3031
)

internal/github.com/hyperledger/fabric/msp/identities.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ import (
2525
"crypto/rand"
2626
"crypto/x509"
2727
"encoding/hex"
28-
"encoding/pem"
29-
"time"
3028

3129
"github.com/hyperledger/fabric-sdk-go/api/apicryptosuite"
3230

31+
"encoding/pem"
32+
"time"
33+
3334
"github.com/golang/protobuf/proto"
3435
bccsp "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/sdkpatch/cryptosuitebridge"
3536
flogging "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/sdkpatch/logbridge"

scripts/third_party_pins/fabric-ca/apply_fabric_ca_client_utils.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,17 @@ sed -i'' -e 's/&bccsp.ECDSAPrivateKeyImportOpts{Temporary: temporary}/factory.Ge
148148
sed -i'' -e 's/cspsigner.New(/factory.NewCspSigner(/g' "${TMP_PROJECT_PATH}/${FILTER_FILENAME}"
149149
sed -i'' -e 's/utils.PrivateKeyToDER/factory.PrivateKeyToDER/g' "${TMP_PROJECT_PATH}/${FILTER_FILENAME}"
150150
sed -i'' -e 's/utils.PEMtoPrivateKey/factory.PEMtoPrivateKey/g' "${TMP_PROJECT_PATH}/${FILTER_FILENAME}"
151+
sed -i'' -e '/key, err := factory.PEMtoPrivateKey(keyBuff, nil)/ i\
152+
key, err := ImportBCCSPKeyFromPEMBytes(keyBuff, myCSP, temporary) \
153+
if err != nil { \
154+
return nil, errors.WithMessage(err, fmt.Sprintf("Failed parsing private key from key file %s", keyFile)) \
155+
} \
156+
return key, nil \
157+
} \
158+
\/\/ ImportBCCSPKeyFromPEMBytes attempts to create a private BCCSP key from a pem byte slice \
159+
func ImportBCCSPKeyFromPEMBytes(keyBuff []byte, myCSP apicryptosuite.CryptoSuite, temporary bool) (apicryptosuite.Key, error) { \
160+
keyFile := "pem bytes" \
161+
' "${TMP_PROJECT_PATH}/${FILTER_FILENAME}"
151162

152163

153164
FILTER_FILENAME="util/util.go"

0 commit comments

Comments
 (0)