github.com/kaituanwang/hyperledger@v2.0.1+incompatible/docs/source/membership/membership.md (about) 1 # Membership 2 3 If you've read through the documentation on [identity](../identity/identity.html) 4 you've seen how a PKI can provide verifiable identities through a chain 5 of trust. Now let's see how these identities can be used to represent the 6 trusted members of a blockchain network. 7 8 This is where a **Membership Service** Provider (MSP) comes into play --- 9 **it identifies which Root CAs and Intermediate CAs are trusted to define 10 the members of a trust domain, e.g., an organization**, either by listing the 11 identities of their members, or by identifying which CAs are authorized to 12 issue valid identities for their members, or --- as will usually be the case --- 13 through a combination of both. 14 15 The power of an MSP goes beyond simply listing who is a network participant or 16 member of a channel. An MSP can identify specific **roles** an actor might play either 17 within the scope of the organization the MSP represents (e.g., admins, or as members 18 of a sub-organization group), and sets the basis for defining **access privileges** 19 in the context of a network and channel (e.g., channel admins, readers, writers). 20 21 The configuration of an MSP is advertised to all the channels where members of 22 the corresponding organization participate (in the form of a **channel MSP**). In 23 addition to the channel MSP, peers, orderers, and clients also maintain a **local MSP** 24 to authenticate member messages outside the context of a channel and to define the 25 permissions over a particular component (who has the ability to install chaincode on 26 a peer, for example). 27 28 In addition, an MSP can allow for the identification of a list of identities that 29 have been revoked --- as discussed in the [Identity](../identity/identity.html) 30 documentation --- but we will talk about how that process also extends to an MSP. 31 32 We'll talk more about local and channel MSPs in a moment. For now let's see what 33 MSPs do in general. 34 35 ### Mapping MSPs to Organizations 36 37 An **organization** is a managed group of members. This can be something as big 38 as a multinational corporation or a small as a flower shop. Typically an organization is 39 represented as a single MSP. Note that this is different from the organization concept 40 defined in an X.509 certificate, which we'll talk about later. 41 42 The exclusive relationship between an organization and its MSP makes it sensible to 43 name the MSP after the organization, a convention you'll find adopted in most policy 44 configurations. For example, organization `ORG1` would likely have an MSP called 45 something like `ORG1-MSP`. In some cases an organization may require multiple 46 membership groups --- for example, where channels are used to perform very different 47 business functions between organizations. In these cases it makes sense to have 48 multiple MSPs and name them accordingly, e.g., `ORG2-MSP-NATIONAL` and 49 `ORG2-MSP-GOVERNMENT`, reflecting the different membership roots of trust within 50 `ORG2` in the `NATIONAL` sales channel compared to the `GOVERNMENT` regulatory 51 channel. 52 53 ![MSP1](./membership.diagram.3.png) 54 55 *Two different MSP configurations for an organization. The first configuration shows 56 the typical relationship between an MSP and an organization --- a single MSP defines 57 the list of members of an organization. In the second configuration, different MSPs 58 are used to represent different organizational groups with national, international, 59 and governmental affiliation.* 60 61 #### Organizational Units and MSPs 62 63 An organization is often divided up into multiple **organizational units** (OUs), each 64 of which has a certain set of responsibilities. For example, the `ORG1` 65 organization might have both `ORG1-MANUFACTURING` and `ORG1-DISTRIBUTION` OUs 66 to reflect these separate lines of business. When a CA issues X.509 certificates, 67 the `OU` field in the certificate specifies the line of business to which the 68 identity belongs. 69 70 We'll see later how OUs can be helpful to control the parts of an organization who 71 are considered to be the members of a blockchain network. For example, only 72 identities from the `ORG1-MANUFACTURING` OU might be able to access a channel, 73 whereas `ORG1-DISTRIBUTION` cannot. 74 75 Finally, though this is a slight misuse of OUs, they can sometimes be used by 76 different organizations in a consortium to distinguish each other. In such cases, the 77 different organizations use the same Root CAs and Intermediate CAs for their chain 78 of trust, but assign the `OU` field to identify members of each organization. 79 We'll also see how to configure MSPs to achieve this later. 80 81 ### Local and Channel MSPs 82 83 MSPs appear in two types of places in a blockchain network: 84 85 * In channel configuration (**channel MSP**) 86 * Locally on an actor's node (**local MSP**) 87 88 **Local MSPs are defined for clients (users) and for nodes (peers and orderers)**. 89 Local MSPs define the permissions for that node (who the peer admins are, for example). 90 The local MSPs of the users allow the user side to authenticate itself in its transactions 91 as a member of a channel (e.g. in chaincode transactions), or as the owner of a 92 specific role into the system (an org admin, for example, in configuration transactions). 93 94 **Every node and user must have a local MSP defined**, as it defines who has 95 administrative or participatory rights at that level (peer admins will not necessarily 96 be channel admins, and vice versa). 97 98 In contrast, **channel MSPs define administrative and participatory rights at the 99 channel level**. Every organization participating in a channel must have an MSP 100 defined for it. Peers and orderers on a channel will all share the same view of channel 101 MSPs, and will therefore be able to correctly authenticate the channel participants. 102 This means that if an organization wishes to join the channel, an MSP incorporating 103 the chain of trust for the organization's members would need to be included in the 104 channel configuration. Otherwise transactions originating from this organization's 105 identities will be rejected. 106 107 The key difference here between local and channel MSPs is not how they function 108 --- both turn identities into roles --- but their **scope**. 109 110 <a name="msp2img"></a> 111 112 ![MSP2](./membership.diagram.4.png) 113 114 *Local and channel MSPs. The trust domain (e.g., the organization) of each 115 peer is defined by the peer's local MSP, e.g., ORG1 or ORG2. Representation 116 of an organization on a channel is achieved by adding the organization's MSP to 117 the channel configuration. For example, the channel of this figure is managed by 118 both ORG1 and ORG2. Similar principles apply for the network, orderers, and users, 119 but these are not shown here for simplicity.* 120 121 You may find it helpful to see how local and channel MSPs are used by seeing 122 what happens when a blockchain administrator installs and deploys a smart 123 contract, as shown in the [diagram above](#msp2img). 124 125 An administrator `B` connects to the peer with an identity issued by `RCA1` 126 and stored in their local MSP. When `B` tries to install a smart contract on 127 the peer, the peer checks its local MSP, `ORG1-MSP`, to verify that the identity 128 of `B` is indeed a member of `ORG1`. A successful verification will allow the 129 install command to complete successfully. Subsequently, `B` wishes 130 to deploy the smart contract on the channel. Because this is a channel 131 operation, all organizations on the channel must agree to it. Therefore, the 132 peer must check the MSPs of the channel before it can successfully commit this 133 command. (Other things must happen too, but concentrate on the above for now.) 134 135 **Local MSPs are only defined on the file system of the node or user** to which 136 they apply. Therefore, physically and logically there is only one local MSP per 137 node or user. However, as channel MSPs are available to all nodes in the 138 channel, they are logically defined once in the channel configuration. However, 139 **a channel MSP is also instantiated on the file system of every node in the 140 channel and kept synchronized via consensus**. So while there is a copy of each 141 channel MSP on the local file system of every node, logically a channel MSP 142 resides on and is maintained by the channel or the network. 143 144 ### MSP Levels 145 146 The split between channel and local MSPs reflects the needs of organizations 147 to administer their local resources, such as a peer or orderer nodes, and their 148 channel resources, such as ledgers, smart contracts, and consortia, which 149 operate at the channel or network level. It's helpful to think of these MSPs 150 as being at different **levels**, with **MSPs at a higher level relating to 151 network administration concerns** while **MSPs at a lower level handle 152 identity for the administration of private resources**. MSPs are mandatory 153 at every level of administration --- they must be defined for the network, 154 channel, peer, orderer, and users. 155 156 ![MSP3](./membership.diagram.2.png) 157 158 *MSP Levels. The MSPs for the peer and orderer are local, whereas the MSPs for a 159 channel (including the network configuration channel) are shared across all 160 participants of that channel. In this figure, the network configuration channel 161 is administered by ORG1, but another application channel can be managed by ORG1 162 and ORG2. The peer is a member of and managed by ORG2, whereas ORG1 manages the 163 orderer of the figure. ORG1 trusts identities from RCA1, whereas ORG2 trusts 164 identities from RCA2. Note that these are administration identities, reflecting 165 who can administer these components. So while ORG1 administers the network, 166 ORG2.MSP does exist in the network definition.* 167 168 * **Network MSP:** The configuration of a network defines who are the 169 members in the network --- by defining the MSPs of the participant organizations 170 --- as well as which of these members are authorized to perform 171 administrative tasks (e.g., creating a channel). 172 173 * **Channel MSP:** It is important for a channel to maintain the MSPs of its members 174 separately. A channel provides private communications between a particular set of 175 organizations which in turn have administrative control over it. Channel policies 176 interpreted in the context of that channel's MSPs define who has ability to 177 participate in certain action on the channel, e.g., adding organizations, or 178 instantiating chaincodes. Note that there is no necessary relationship between 179 the permission to administrate a channel and the ability to administrate the 180 network configuration channel (or any other channel). Administrative rights 181 exist within the scope of what is being administrated (unless the rules have 182 been written otherwise --- see the discussion of the `ROLE` attribute below). 183 184 * **Peer MSP:** This local MSP is defined on the file system of each peer and there is a 185 single MSP instance for each peer. Conceptually, it performs exactly the same function 186 as channel MSPs with the restriction that it only applies to the peer where it is defined. 187 An example of an action whose authorization is evaluated using the peer's local MSP is 188 the installation of a chaincode on the peer. 189 190 * **Orderer MSP:** Like a peer MSP, an orderer local MSP is also defined on the file system 191 of the node and only applies to that node. Like peer nodes, orderers are also owned by a single 192 organization and therefore have a single MSP to list the actors or nodes it trusts. 193 194 ### MSP Structure 195 196 So far, you've seen that the most important element of an MSP are the specification 197 of the root or intermediate CAs that are used to establish an actor's or node's 198 membership in the respective organization. There are, however, more elements that are 199 used in conjunction with these two to assist with membership functions. 200 201 ![MSP4](./membership.diagram.5.png) 202 203 *The figure above shows how a local MSP is stored on a local filesystem. Even though 204 channel MSPs are not physically structured in exactly this way, it's still a helpful 205 way to think about them.* 206 207 As you can see, there are nine elements to an MSP. It's easiest to think of these elements 208 in a directory structure, where the MSP name is the root folder name with each 209 subfolder representing different elements of an MSP configuration. 210 211 Let's describe these folders in a little more detail and see why they are important. 212 213 * **Root CAs:** This folder contains a list of self-signed X.509 certificates of 214 the Root CAs trusted by the organization represented by this MSP. 215 There must be at least one Root CA X.509 certificate in this MSP folder. 216 217 This is the most important folder because it identifies the CAs from 218 which all other certificates must be derived to be considered members of the 219 corresponding organization. 220 221 222 * **Intermediate CAs:** This folder contains a list of X.509 certificates of the 223 Intermediate CAs trusted by this organization. Each certificate must be signed by 224 one of the Root CAs in the MSP or by an Intermediate CA whose issuing CA chain ultimately 225 leads back to a trusted Root CA. 226 227 An intermediate CA may represent a different subdivision of the organization 228 (like `ORG1-MANUFACTURING` and `ORG1-DISTRIBUTION` do for `ORG1`), or the 229 organization itself (as may be the case if a commercial CA is leveraged for 230 the organization's identity management). In the latter case intermediate CAs 231 can be used to represent organization subdivisions. [Here](../msp.html) you 232 may find more information on best practices for MSP configuration. Notice, that 233 it is possible to have a functioning network that does not have an Intermediate 234 CA, in which case this folder would be empty. 235 236 Like the Root CA folder, this folder defines the CAs from which certificates must be 237 issued to be considered members of the organization. 238 239 240 * **Organizational Units (OUs):** These are listed in the `$FABRIC_CFG_PATH/msp/config.yaml` 241 file and contain a list of organizational units, whose members are considered 242 to be part of the organization represented by this MSP. This is particularly 243 useful when you want to restrict the members of an organization to the ones 244 holding an identity (signed by one of MSP designated CAs) with a specific OU 245 in it. 246 247 Specifying OUs is optional. If no OUs are listed, all the identities that are part of 248 an MSP --- as identified by the Root CA and Intermediate CA folders --- will be considered 249 members of the organization. 250 251 252 * **Administrators:** This folder contains a list of identities that define the 253 actors who have the role of administrators for this organization. For the standard MSP type, 254 there should be one or more X.509 certificates in this list. 255 256 It's worth noting that just because an actor has the role of an administrator it doesn't 257 mean that they can administer particular resources! The actual power a given identity has 258 with respect to administering the system is determined by the policies that manage system 259 resources. For example, a channel policy might specify that `ORG1-MANUFACTURING` 260 administrators have the rights to add new organizations to the channel, whereas the 261 `ORG1-DISTRIBUTION` administrators have no such rights. 262 263 Even though an X.509 certificate has a `ROLE` attribute (specifying, for example, that 264 an actor is an `admin`), this refers to an actor's role within its organization 265 rather than on the blockchain network. This is similar to the purpose of 266 the `OU` attribute, which --- if it has been defined --- refers to an actor's place in 267 the organization. 268 269 The `ROLE` attribute **can** be used to confer administrative rights at the channel level 270 if the policy for that channel has been written to allow any administrator from an organization 271 (or certain organizations) permission to perform certain channel functions (such as 272 instantiating chaincode). In this way, an organizational role can confer a network role. 273 274 275 * **Revoked Certificates:** If the identity of an actor has been revoked, 276 identifying information about the identity --- not the identity itself --- is held 277 in this folder. For X.509-based identities, these identifiers are pairs of strings known as 278 Subject Key Identifier (SKI) and Authority Access Identifier (AKI), and are checked 279 whenever the X.509 certificate is being used to make sure the certificate has not 280 been revoked. 281 282 This list is conceptually the same as a CA's Certificate Revocation List (CRL), 283 but it also relates to revocation of membership from the organization. As a result, 284 the administrator of an MSP, local or channel, can quickly revoke an actor or node 285 from an organization by advertising the updated CRL of the CA the revoked certificate 286 as issued by. This "list of lists" is optional. It will only become populated 287 as certificates are revoked. 288 289 290 * **Node Identity:** This folder contains the identity of the node, i.e., 291 cryptographic material that --- in combination to the content of `KeyStore` --- would 292 allow the node to authenticate itself in the messages that is sends to other 293 participants of its channels and network. For X.509 based identities, this 294 folder contains an **X.509 certificate**. This is the certificate a peer places 295 in a transaction proposal response, for example, to indicate that the peer has 296 endorsed it --- which can subsequently be checked against the resulting 297 transaction's endorsement policy at validation time. 298 299 This folder is mandatory for local MSPs, and there must be exactly one X.509 certificate 300 for the node. It is not used for channel MSPs. 301 302 303 * **`KeyStore` for Private Key:** This folder is defined for the local MSP of a peer or 304 orderer node (or in an client's local MSP), and contains the node's **signing key**. 305 This key matches cryptographically the node's identity included in **Node Identity** 306 folder and is used to sign data --- for example to sign a transaction proposal response, 307 as part of the endorsement phase. 308 309 This folder is mandatory for local MSPs, and must contain exactly one private key. 310 Obviously, access to this folder must be limited only to the identities of users who have 311 administrative responsibility on the peer. 312 313 Configuration of a **channel MSPs** does not include this folder, as channel MSPs 314 solely aim to offer identity validation functionalities and not signing abilities. 315 316 317 * **TLS Root CA:** This folder contains a list of self-signed X.509 certificates of the 318 Root CAs trusted by this organization **for TLS communications**. An example of a TLS 319 communication would be when a peer needs to connect to an orderer so that it can receive 320 ledger updates. 321 322 MSP TLS information relates to the nodes inside the network --- the peers and the 323 orderers, in other words, rather than the applications and administrations that 324 consume the network. 325 326 There must be at least one TLS Root CA X.509 certificate in this folder. 327 328 329 * **TLS Intermediate CA:** This folder contains a list intermediate CA certificates 330 CAs trusted by the organization represented by this MSP **for TLS communications**. 331 This folder is specifically useful when commercial CAs are used for TLS certificates of an 332 organization. Similar to membership intermediate CAs, specifying intermediate TLS CAs is 333 optional. 334 335 For more information about TLS, click [here](../enable_tls.html). 336 337 If you've read this doc as well as our doc on [Identity](../identity/identity.html)), you 338 should have a pretty good grasp of how identities and membership work in Hyperledger Fabric. 339 You've seen how a PKI and MSPs are used to identify the actors collaborating in a blockchain 340 network. You've learned how certificates, public/private keys, and roots of trust work, 341 in addition to how MSPs are physically and logically structured. 342 343 <!--- 344 Licensed under Creative Commons Attribution 4.0 International License https://creativecommons.org/licenses/by/4.0/ 345 -->