code: func NewCAClient(orgName string, ctx contextApi.Client) (*CAClientImpl, error) {
  
  	if orgName == "" {
  		orgName = ctx.IdentityConfig().Client().Organization
  	}
  
  	if orgName == "" {
  		return nil, errors.New("organization is missing")
  	}
  
  	netConfig := ctx.EndpointConfig().NetworkConfig()
  	// viper keys are case insensitive
  	orgConfig, ok := netConfig.Organizations[strings.ToLower(orgName)]
  	if !ok {
  		return nil, errors.New("org config retrieval failed")
  	}
  	if len(orgConfig.CertificateAuthorities) == 0 {
  		return nil, errors.New("no CAs configured")
  	}
  
  	var adapter *fabricCAAdapter
  	var registrar msp.EnrollCredentials
  	var err error
  
  	// Currently, an organization can be associated with only one CA
  	caName := orgConfig.CertificateAuthorities[0]
  	caConfig, ok := ctx.IdentityConfig().CAConfig(orgName)
  	if ok {
  		adapter, err = newFabricCAAdapter(orgName, ctx.CryptoSuite(), ctx.IdentityConfig())
  		if err == nil {
  			registrar = caConfig.Registrar
  		} else {
  			return nil, errors.Wrapf(err, "error initializing CA [%s]", caName)
  		}
  	} else {
  		return nil, errors.Errorf("error initializing CA [%s]", caName)
  	}
  
  	identityManager, ok := ctx.IdentityManager(orgName)
  	if !ok {
  		return nil, fmt.Errorf("identity manager not found for organization '%s", orgName)
  	}
  
  	mgr := &CAClientImpl{
  		orgName:         orgName,
  		caName:          caName,
  		orgMSPID:        orgConfig.MSPID,
  		cryptoSuite:     ctx.CryptoSuite(),
  		identityManager: identityManager,
  		userStore:       ctx.UserStore(),
  		adapter:         adapter,
  		registrar:       registrar,
  	}
  	return mgr, nil
  }
docs: // NewCAClient creates a new CA CAClient instance