func (fabricCAServices *FabricCA) Enroll(enrollmentID string, enrollmentSecret string) (apicryptosuite.Key, []byte, error) {
	if enrollmentID == "" {
		return nil, nil, errors.New("enrollmentID required")
	}
	if enrollmentSecret == "" {
		return nil, nil, errors.New("enrollmentSecret required")
	}
	req := &api.EnrollmentRequest{
		CAName: fabricCAServices.fabricCAClient.Config.CAName,
		Name:   enrollmentID,
		Secret: enrollmentSecret,
	}
	enrollmentResponse, err := fabricCAServices.fabricCAClient.Enroll(req)
	if err != nil {
		return nil, nil, errors.Wrap(err, "enroll failed")
	}
	return enrollmentResponse.Identity.GetECert().Key(), enrollmentResponse.Identity.GetECert().Cert(), nil
}
Enroll a registered user in order to receive a signed X509 certificate.
enrollmentID The registered ID to use for enrollment
enrollmentSecret The secret associated with the enrollment ID
Returns X509 certificate
package fabricca
import (
	"github.com/pkg/errors"
	config "github.com/hyperledger/fabric-sdk-go/api/apiconfig"
	sdkApi "github.com/hyperledger/fabric-sdk-go/api/apifabca"
	api "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/api"
	fabric_ca "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/lib"
	"github.com/hyperledger/fabric-sdk-go/pkg/config/urlutil"
	"github.com/hyperledger/fabric-sdk-go/pkg/logging"
	"github.com/hyperledger/fabric-sdk-go/api/apicryptosuite"
)
var logger = logging.NewLogger("fabric_sdk_go")
type FabricCA struct {
	fabricCAClient *fabric_ca.Client
}
func NewFabricCAClient(org string, config config.Config, cryptoSuite apicryptosuite.CryptoSuite) (*FabricCA, error) {
	if org == "" || config == nil || cryptoSuite == nil {
		return nil, errors.New("organization, config and cryptoSuite are required to load CA config")
	}
	c := &fabric_ca.Client{
		Config: &fabric_ca.ClientConfig{},
	}
	conf, err := config.CAConfig(org)
	if err != nil {
		return nil, err
	}
	if conf == nil {
		return nil, errors.Errorf("Orgnization %s have no corresponding CA in the configs", org)
	}
	c.Config.CAName = conf.CAName
	c.Config.URL = urlutil.ToAddress(conf.URL)
	c.Config.TLS.CertFiles, err = config.CAServerCertPaths(org)
	if err != nil {
		return nil, err
	}
	c.Config.TLS.Client.CertFile, err = config.CAClientCertPath(org)
	if err != nil {
		return nil, err
	}
	c.Config.TLS.Client.KeyFile, err = config.CAClientKeyPath(org)
	if err != nil {
		return nil, err
	}
	_, err = config.Client()
	if err != nil {
		return nil, err
	}
	c.Config.TLS.Enabled = urlutil.IsTLSEnabled(conf.URL)
	c.Config.MSPDir = config.CAKeyStorePath()
	c.Config.CSP = cryptoSuite
	fabricCAClient := FabricCA{fabricCAClient: c}
	err = c.Init()
	if err != nil {
		return nil, errors.Wrap(err, "init failed")
	}
	return &fabricCAClient, nil
}
func (fabricCAServices *FabricCA) CAName() string {
	return fabricCAServices.fabricCAClient.Config.CAName
}