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