コード例 #1
0
ファイル: chaincode.go プロジェクト: C0rWin/fabric
func newPeerClientConnection() (*grpc.ClientConn, error) {
	var peerAddress = getPeerAddress()
	if comm.TLSEnabled() {
		return comm.NewClientConnectionWithAddress(peerAddress, true, true, comm.InitTLSForPeer())
	}
	return comm.NewClientConnectionWithAddress(peerAddress, true, false, nil)
}
コード例 #2
0
ファイル: conn.go プロジェクト: hyperledger/fabric
// NewGrpcClient return a new GRPC client connection for the specified peer address
func NewGrpcClient(peerAddress string) (*grpc.ClientConn, error) {
	var tmpConn *grpc.ClientConn
	var err error
	if comm.TLSEnabled() {
		tmpConn, err = comm.NewClientConnectionWithAddress(peerAddress, true, true, comm.InitTLSForPeer())
	}
	tmpConn, err = comm.NewClientConnectionWithAddress(peerAddress, true, false, nil)
	if err != nil {
		fmt.Printf("error connection to server at host:port = %s\n", peerAddress)
	}
	return tmpConn, err

}
コード例 #3
0
ファイル: node_grpc.go プロジェクト: C0rWin/fabric
func (node *nodeImpl) getClientConn(address string, serverName string) (*grpc.ClientConn, error) {
	node.Debugf("Dial to addr:[%s], with serverName:[%s]...", address, serverName)

	if node.conf.isTLSEnabled() {
		node.Debug("TLS enabled...")

		config := tls.Config{
			InsecureSkipVerify: false,
			RootCAs:            node.tlsCertPool,
			ServerName:         serverName,
		}
		if node.conf.isTLSClientAuthEnabled() {

		}

		return comm.NewClientConnectionWithAddress(address, false, true, credentials.NewTLS(&config))
	}
	node.Debug("TLS disabled...")
	return comm.NewClientConnectionWithAddress(address, false, false, nil)
}
コード例 #4
0
ファイル: peer.go プロジェクト: tuand27613/fabric
// NewPeerClientConnectionWithAddress Returns a new grpc.ClientConn to the configured local PEER.
func NewPeerClientConnectionWithAddress(peerAddress string) (*grpc.ClientConn, error) {
	if comm.TLSEnabled() {
		return comm.NewClientConnectionWithAddress(peerAddress, true, true, comm.InitTLSForPeer())
	}
	return comm.NewClientConnectionWithAddress(peerAddress, true, false, nil)
}