Esempio n. 1
0
func (node *nodeImpl) getECAClient() (*grpc.ClientConn, obcca.ECAPClient, error) {
	node.log.Debug("Getting ECA client...")

	conn, err := node.getClientConn(node.conf.getECAPAddr(), node.conf.getECAServerName())
	if err != nil {
		node.log.Error("Failed getting client connection: [%s]", err)
	}

	client := obcca.NewECAPClient(conn)

	node.log.Debug("Getting ECA client...done")

	return conn, client, nil
}
Esempio n. 2
0
func (node *nodeImpl) callECACreateCertificate(ctx context.Context, in *obcca.ECertCreateReq, opts ...grpc.CallOption) (*obcca.Cert, []byte, error) {
	sockP, err := grpc.Dial(node.conf.getECAPAddr(), grpc.WithInsecure())
	if err != nil {
		node.log.Error("Failed dailing in [%s].", err.Error())

		return nil, nil, err
	}
	defer sockP.Close()

	ecaP := obcca.NewECAPClient(sockP)

	cred, err := ecaP.CreateCertificate(context.Background(), in)
	if err != nil {
		node.log.Error("Failed requesting enrollment certificate [%s].", err.Error())

		return nil, nil, err
	}

	return cred.Cert, cred.Key, nil
}
Esempio n. 3
0
func (node *nodeImpl) callECAReadCertificate(ctx context.Context, in *obcca.ECertReadReq, opts ...grpc.CallOption) (*obcca.Cert, error) {
	sockP, err := grpc.Dial(node.conf.getECAPAddr(), grpc.WithInsecure())
	if err != nil {
		node.log.Error("Failed eca dialing in [%s].", err.Error())

		return nil, err
	}
	defer sockP.Close()

	ecaP := obcca.NewECAPClient(sockP)

	cert, err := ecaP.ReadCertificate(context.Background(), in)
	if err != nil {
		node.log.Error("Failed requesting read certificate [%s].", err.Error())

		return nil, err
	}

	return cert, nil
}