github.com/tenywen/fabric@v1.0.0-beta.0.20170620030522-a5b1ed380643/docs/source/msp.rst (about) 1 Membership Service Providers (MSP) 2 ================================== 3 4 The document serves to provide details on the setup and best practices for MSPs. 5 6 Membership service provider (MSP) is a component that aims to offer an 7 abstraction of a membership operation architecture. 8 9 In particular, MSP abstracts away all cryptographic mechanisms and protocols 10 behind issuing and validating certificates, and user authentication. An 11 MSP may define their own notion of identity, and the rules by which those 12 identities are governed (identity validation) and authenticated (signature 13 generation and verification). 14 15 A Fabric blockchain network can be governed by one or more MSPs. In this 16 way Fabric offers modularity of membership operations, and interoperability 17 across different membership standards and architectures. 18 19 In the rest of this document we elaborate on the setup of the MSP 20 implementation supported by Fabric, and discuss best practices concerning 21 its use. 22 23 MSP Configuration 24 ----------------- 25 26 To setup an instance of the MSP, its configuration needs to be specified 27 locally at each peer and orderer (to enable peer, and orderer signing), 28 and on the channels to enable peer, orderer, client identity validation, and 29 respective signature verification (authentication) by and for all channel 30 members. 31 32 Firstly, for each MSP a name needs to be specified in order to reference that MSP 33 in the network (e.g. ``msp1``, ``org2``, and ``org3.divA``). This is the name under 34 which membership rules of an MSP representing a consortium, organisation or 35 organisation division is to be referenced in a channel. This is also referred 36 to as the *MSP Identifier* or *MSP ID*. MSP Identifiers are required to be unique per MSP 37 instance. For example, shall two MSP instances with the same identifier be 38 detected at the system channel genesis, orderer setup will fail. 39 40 In the case of default implementation of MSP, a set of parameters need to be 41 specified to allow for identity (certificate) validation and signature 42 verification. These parameters are deduced by 43 `RFC5280 <http://www.ietf.org/rfc/rfc5280.txt>`_, and include: 44 45 - A list of self-signed (X.509) certificates to constitute the *root of 46 trust* 47 - A list of X.509 certificates to represent intermediate CAs this provider 48 considers for certificate validation; these certificates ought to be 49 certified by exactly one of the certificates in the root of trust; 50 intermediate CAs are optional parameters 51 - A list of X.509 certificates with a verifiable certificate path to 52 exactly one of the certificates of the root of trust to represent the 53 administrators of this MSP; owners of these certificates are authorized 54 to request changes to this MSP configuration (e.g. root CAs, intermediate CAs) 55 - A list of Organizational Units that valid members of this MSP should 56 include in their X.509 certificate; this is an optional configuration 57 parameter, used when, e.g., multiple organisations leverage the same 58 root of trust, and intermediate CAs, and have reserved an OU field for 59 their members 60 - A list of certificate revocation lists (CRLs) each corresponding to 61 exactly one of the listed (intermediate or root) MSP Certificate 62 Authorities; this is an optional parameter 63 64 *Valid* identities for this MSP instance are required to satisfy the following conditions: 65 66 - They are in the form of X.509 certificates with a verifiable certificate path to 67 exactly one of the root of trust certificates 68 - They are not included in any CRL 69 - And they *list* one or more of the Organizational Units of the MSP configuration 70 in the ``OU`` field of their X.509 certificate structure. 71 72 For more information on the validity of identities in the current MSP implementation 73 we refer the reader to the identity validation 74 rules :doc:`msp-identity-validity-rules`. 75 76 In addition to verification related parameters, for the MSP to enable 77 the node on which it is instantiated to sign or authenticate, one needs to 78 specify: 79 80 - The signing key used for signing by the node, and 81 - The node's X.509 certificate, that is a valid identity under the 82 verification parameters of this MSP 83 84 How to generate MSP certificates and their signing keys? 85 -------------------------------------------------------- 86 87 To generate X.509 certificates to feed its MSP configuration, the application 88 can use `Openssl <https://www.openssl.org/>`_. 89 90 Alternatively one can use ``cryptogen`` tool, whose operation is explained in 91 :doc:`getting_started`. 92 93 For fabric-ca related certificate generation, we refer the reader to the 94 fabric-ca related documentation - :doc:`Setup/ca-setup`. 95 96 MSP setup on the peer & orderer side 97 ------------------------------------ 98 99 To set up a local MSP (for either a peer or an orderer), the administrator 100 should create a folder (e.g. ``$MY_PATH/mspconfig``) that contains six subfolders 101 and a file: 102 103 1. a folder ``admincerts`` to include PEM files each corresponding to an 104 administrator certificate 105 2. a folder ``cacerts`` to include PEM files each corresponding to a root 106 CA's certificate 107 3. (optional) a folder ``intermediatecerts`` to include PEM files each 108 corresponding to an intermediate CA's certificate 109 4. (optional) a file ``config.yaml`` to include information on the 110 considered OUs; the latter are defined as pairs of 111 ``<Certificate, OrganizationalUnitIdentifier>`` entries of a yaml array 112 called ``OrganizationalUnitIdentifiers``, where ``Certificate`` represents 113 the relative path to the certificate of the certificate authority (root or 114 intermediate) that should be considered for certifying members of this 115 organizational unit (e.g. ./cacerts/cacert.pem), and 116 ``OrganizationalUnitIdentifier`` represents the actual string as 117 expected to appear in X.509 certificate OU-field (e.g. "COP") 118 5. (optional) a folder ``crls`` to include the considered CRLs 119 6. a folder ``keystore`` to include a PEM file with the node's signing key 120 7. a folder ``signcerts`` to include a PEM file with the node's X.509 121 certificate 122 123 In the configuration file of the node (core.yaml file for the peer, and 124 orderer.yaml for the orderer), one needs to specify the path to the 125 mspconfig folder, and the MSP Identifier of the node's MSP. The path to the 126 mspconfig folder is expected to be relative to FABRIC_CFG_PATH and is provided 127 as the value of parameter ``mspConfigPath`` for the peer, and ``LocalMSPDir`` 128 for the orderer. The identifier of the node's MSP is provided as a value of 129 parameter ``localMspId`` for the peer and ``LocalMSPID`` for the orderer. 130 These variables can be overriden via the environment using the CORE prefix for 131 peer (e.g. CORE_PEER_LOCALMSPID) and the ORDERER prefix for the orderer (e.g. 132 ORDERER_GENERAL_LOCALMSPID). Notice that for the orderer setup, one needs to 133 generate, and provide to the orderer the genesis block of the system channel. 134 The MSP configuration needs of this block are detailed in the next section. 135 136 *Reconfiguration* of a "local" MSP is only possible manually, and requires that 137 the peer or orderer process is restarted. In subsequent releases we aim to 138 offer online/dynamic reconfiguration (i.e. without requiring to stop the node 139 by using a node managed system chaincode). 140 141 Channel MSP setup 142 ----------------- 143 144 At the genesis of the system, verification parameters of all the MSPs that 145 appear in the network need to be specified, and included in the system 146 channel's genesis block. Recall that MSP verification parameters consist of 147 the MSP identifier, the root of trust certificates, intermediate CA and admin 148 certificates, as well as OU specifications and CRLs. 149 The system genesis block is provided to the orderers at their setup phase, 150 and allows them to authenticate channel creation requests. Orderers would 151 reject the system genesis block, if the latter includes two MSPs with the same 152 identifier, and consequently the bootstrapping of the network would fail. 153 154 For application channels, the verification components of only the MSPs that 155 govern a channel need to reside in the channel's genesis block. We emphasise 156 that it is **the responsibility of the application** to ensure that correct 157 MSP configuration information is included in the genesis blocks (or the 158 most recent configuration block) of a channel prior to instructing one or 159 more of their peers to join the channel. 160 161 When bootstrapping a channel with the help of the configtxgen tool, one can 162 configure the channel MSPs by including the verification parameters of MSP 163 in the mspconfig folder, and setting that path in the relevant section in 164 ``configtx.yaml``. 165 166 *Reconfiguration* of an MSP on the channel, including announcements of the 167 certificate revocation lists associated to the CAs of that MSP is achieved 168 through the creation of a ``config_update`` object by the owner of one of the 169 administrator certificates of the MSP. The client application managed by the 170 admin would then announce this update to the channels in which this MSP appears. 171 172 Best Practices 173 -------------- 174 175 In this section we elaborate on best practices for MSP 176 configuration in commonly met scenarios. 177 178 **1) Mapping between organizations/corporations and MSPs** 179 180 We recommend that there is a one-to-one mapping between organizations and MSPs. 181 If a different mapping type of mapping is chosen, the following needs to be to 182 considered: 183 184 - **One organization employing various MSPs.** This corresponds to the 185 case of an organization including a variety of divisions each represented 186 by its MSP, either for management independence reasons, or for privacy reasons. 187 In this case a peer can only be owned by a single MSP, and will not recognize 188 peers with identities from other MSPs as peers of the same organization. The 189 implication of this is that peers may share through gossip organization-scoped 190 data with a set of peers that are members of the same subdivision, and NOT with 191 the full set of providers constituting the actual organization. 192 - **Multiple organizations using a single MSP.** This corresponds to a 193 case of a consortium of organisations that are governed by similar 194 membership architecture. One needs to know here that peers would propagate 195 organization-scoped messages to the peers that have an identity under the 196 same MSP regardless of whether they belong to the same actual organization. 197 This is a limitation of the granularity of MSP definition, and/or of the peer’s 198 configuration. In future versions of Fabric, this can change as we move 199 towards (i) an identity channel that contains all membership related 200 information of the network, (ii) peer notion of “trust-zone” being 201 configurable, where a peer’s administrator specifying at peer setup time whose 202 MSP members should be treated by peers as authorized to receive 203 organization-scoped messages. 204 205 **2) One organization has different divisions (say organizational units), to** 206 **which it wants to grant access to different channels.** 207 208 Two ways to handle this: 209 210 - **Define one MSP to accommodate membership for all organization’s members**. 211 Configuration of that MSP would consist of a list of root CAs, 212 intermediate CAs and admin certificates; and membership identities would 213 include the organizational unit (``OU``) a member belongs to. Policies can then 214 be defined to capture members of a specific ``OU``, and these policies may 215 constitute the read/write policies of a channel or endorsement policies of 216 a chaincode. A limitation of this approach is that gossip peers would 217 consider peers with membership identities under their local MSP as 218 members of the same organization, and would consequently gossip 219 with them organisation-scoped data (e.g. their status). 220 - **Defining one MSP to represent each division**. This would involve specifying for each 221 division, a set of certificates for root CAs, intermediate CAs, and admin 222 Certs, such that there is no overlapping certification path across MSPs. 223 This would mean that, for example, a different intermediate CA per subdivision 224 is employed. Here the disadvantage is the management of more than one 225 MSPs instead of one, but this circumvents the issue present in the previous 226 approach. One could also define one MSP for each division by leveraging an OU 227 extension of the MSP configuration. 228 229 **3) Separating clients from peers of the same organization.** 230 231 In many cases it is required that the “type” of an identity is retrievable 232 from the identity itself (e.g. it may be needed that endorsements are 233 guaranteed to have derived by peers, and not clients or nodes acting solely 234 as orderers). 235 236 There is limited support for such requirements. 237 238 One way to allow for this separation is to to create a separate intermediate 239 CA for each node type - one for clients and one for peers/orderers; and 240 configure two different MSPs - one for clients and one for peers/orderers. 241 Channels this organization should be accessing would need to include 242 both MSPs, while endorsement policies will leverage only the MSP that 243 refers to the peers. This would ultimately result in the organization 244 being mapped to two MSP instances, and would have certain consequences 245 on the way peers and clients interact. 246 247 Gossip would not be drastically impacted as all peers of the same organization 248 would still belong to one MSP. Peers can restrict the execution of certain 249 system chaincodes to local MSP based policies. For 250 example, peers would only execute “joinChannel” request if the request is 251 signed by the admin of their local MSP who can only be a client (end-user 252 should be sitting at the origin of that request). We can go around this 253 inconsistency if we accept that the only clients to be members of a 254 peer/orderer MSP would be the administrators of that MSP. 255 256 Another point to be considered with this approach is that peers 257 authorize event registration requests based on membership of request 258 originator within their local MSP. Clearly, since the originator of the 259 request is a client, the request originator is always doomed to belong 260 to a different MSP than the requested peer and the peer would reject the 261 request. 262 263 **4) Admin and CA certificates.** 264 265 It is important to set MSP admin certificates to be different than any of the 266 certificates considered by the MSP for ``root of trust``, or intermediate CAs. 267 This is a common (security) practice to separate the duties of management of 268 membership components from the issuing of new certificates, and/or validation of existing ones. 269 270 **5) Blacklisting an intermediate CA.** 271 272 As mentioned in previous sections, reconfiguration of an MSP is achieved by 273 reconfiguration mechanisms (manual reconfiguration for the local MSP instances, 274 and via properly constructed ``config_update`` messages for MSP instances of a channel). 275 Clearly, there are two ways to ensure an intermediate CA considered in an MSP is no longer 276 considered for that MSP's identity validation: 277 278 1. Reconfigure the MSP to no longer include the certificate of that 279 intermediate CA in the list of trusted intermediate CA certs. For the 280 locally configured MSP, this would mean that the certificate of this CA is 281 removed from the ``intermediatecerts`` folder. 282 2. Reconfigure the MSP to include a CRL produced by the root of trust 283 which denounces the mentioned intermediate CA's certificate. 284 285 In the current MSP implementation we only support method (1) as it is simpler 286 and does not require blacklisting the no longer considered intermediate CA. 287 288 .. Licensed under Creative Commons Attribution 4.0 International License 289 https://creativecommons.org/licenses/by/4.0/ 290