-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathcommon.go
More file actions
47 lines (40 loc) · 1.02 KB
/
common.go
File metadata and controls
47 lines (40 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package common
import (
"github.com/hyperledger/fabric-admin-sdk/pkg/identity"
"github.com/hyperledger/fabric-admin-sdk/pkg/network"
"google.golang.org/grpc"
)
type ConnectionDetail struct {
ID identity.SigningIdentity
Connection grpc.ClientConnInterface
}
func ConstructConnectionDetail(mspID string, SignCert string, PrivKeyPath string, orgPeerAddress string, TLSCACert string) (*ConnectionDetail, error) {
peer := network.Node{
Addr: orgPeerAddress,
TLSCACert: TLSCACert,
}
err := peer.LoadConfig()
if err != nil {
return nil, err
}
peerConnection, err := network.DialConnection(peer)
if err != nil {
return nil, err
}
cert, _, err := identity.ReadCertificate(SignCert)
if err != nil {
return nil, err
}
priv, err := identity.ReadECDSAPrivateKey(PrivKeyPath)
if err != nil {
return nil, err
}
orgMSP, err := identity.NewPrivateKeySigningIdentity(mspID, cert, priv)
if err != nil {
return nil, err
}
return &ConnectionDetail{
Connection: peerConnection,
ID: orgMSP,
}, nil
}