hyperledger/fabric · error

the identity must be a client or a peer identity to be valid

Error message

the identity must be a client or a peer identity to be valid, not a combination of them. OUs: %s, MSP: [%s]

What it means

The identity has more than one OU that resolves to a client/peer role, so Fabric cannot assign it a single unambiguous role. validateIdentityOUsV11 requires exactly one matching role OU and rejects combinations (e.g. a certificate containing both 'client' and 'peer' OUs that match configured identifiers).

Source

Thrown at msp/mspimplvalidate.go:228

		}

		// Yes. Then, enforce the certifiers identifier is this is specified.
		// It is not specified, it means that any certification path is fine.
		if len(nodeOU.CertifiersIdentifier) != 0 && !bytes.Equal(nodeOU.CertifiersIdentifier, OU.CertifiersIdentifier) {
			return errors.Errorf("certifiersIdentifier does not match: %v, MSP: [%s]", OUIDs(id.GetOrganizationalUnits()), msp.name)
		}
		counter++
		if counter > 1 {
			break
		}
	}

	// the identity should have exactly one OU role, return an error if the counter is not 1.
	if counter == 0 {
		return errors.Errorf("the identity does not have an OU that resolves to client or peer. OUs: %s, MSP: [%s]", OUIDs(id.GetOrganizationalUnits()), msp.name)
	}
	if counter > 1 {
		return errors.Errorf("the identity must be a client or a peer identity to be valid, not a combination of them. OUs: %s, MSP: [%s]", OUIDs(id.GetOrganizationalUnits()), msp.name)
	}

	return nil
}

func (msp *bccspmsp) validateIdentityOUsV142(id *identity) error {
	// Run the same checks as per V1
	err := msp.validateIdentityOUsV1(id)
	if err != nil {
		return err
	}

	// -- Check for OU enforcement
	if !msp.ouEnforcement {
		// No enforcement required
		return nil
	}

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Reissue the certificate with exactly one role OU
  2. Ensure ClientOUIdentifier and PeerOUIdentifier have distinct OrganizationalUnitIdentifier values
  3. Remove duplicate role OUs from the certificate subject

Example fix

// before: cert subject CN=x, OU=client, OU=peer
OU=client, OU=peer
// after
OU=client
Defensive patterns

Strategy: validation

Validate before calling

func singleRoleOU(cert *x509.Certificate, allowed map[string]struct{}) int {
    n := 0
    for _, ou := range cert.Subject.OU {
        if _, ok := allowed[ou]; ok { n++ }
    }
    return n
}
// n != 1 means the identity will be rejected (0: no role, >1: ambiguous).

Prevention

When it happens

Trigger: msp.Validate(identity) where multiple of id.GetOrganizationalUnits() match both ClientOUIdentifier and PeerOUIdentifier (or two OUs matching the same identifier class), incrementing counter past 1.

Common situations: Certificate issued with multiple OU RDNs (e.g. OU=client, OU=peer) by mistake; MSP config where client and peer identifiers use the same OrganizationalUnitIdentifier; duplicate OU entries in NodeOUs.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/c871b632b95c461e. Report an issue: GitHub.