github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/docs/source/msp.rst (about) 1 Membership Service Providers (MSP) 2 ================================== 3 4 For a conceptual overview of the Membership Service Provider (MSP), check out 5 :doc:`membership/membership`. 6 7 This topic elaborates on the setup of the MSP implementation supported by 8 Hechain and discusses best practices concerning its use. 9 10 MSP configuration 11 ----------------- 12 13 To setup an instance of the MSP, its configuration needs to be specified 14 locally at each peer and orderer (to enable peer and orderer signing), 15 and on the channels to enable peer, orderer, client identity validation, and 16 respective signature verification (authentication) by and for all channel 17 members. 18 19 Firstly, for each MSP a name needs to be specified in order to reference that MSP 20 in the network (e.g. ``msp1``, ``org2``, and ``org3.divA``). This is the name under 21 which membership rules of an MSP representing a consortium, organization or 22 organization division is to be referenced in a channel. This is also referred 23 to as the *MSP Identifier* or *MSP ID*. MSP Identifiers are required to be unique per MSP 24 instance. 25 26 In the case of the default MSP implementation, a set of parameters need to be 27 specified to allow for identity (certificate) validation and signature 28 verification. These parameters are deduced by 29 `RFC5280 <http://www.ietf.org/rfc/rfc5280.txt>`_, and include: 30 31 - A list of self-signed (X.509) CA certificates to constitute the *root of 32 trust* 33 - A list of X.509 certificates to represent intermediate CAs this provider 34 considers for certificate validation; these certificates ought to be 35 certified by exactly one of the certificates in the root of trust; 36 intermediate CAs are optional parameters 37 - A list of X.509 certificates representing the administrators of this MSP with a 38 verifiable certificate path to exactly one of the CA certificates of the 39 root of trust; owners of these certificates are authorized to request changes 40 to this MSP configuration (e.g. root CAs, intermediate CAs) 41 - A list of Organizational Units that valid members of this MSP should 42 include in their X.509 certificate; this is an optional configuration 43 parameter, used when, e.g., multiple organizations leverage the same 44 root of trust, and intermediate CAs, and have reserved an OU field for 45 their members 46 - A list of certificate revocation lists (CRLs) each corresponding to 47 exactly one of the listed (intermediate or root) MSP Certificate 48 Authorities; this is an optional parameter 49 - A list of self-signed (X.509) certificates to constitute the *TLS root of 50 trust* for TLS certificates. 51 - A list of X.509 certificates to represent intermediate TLS CAs this provider 52 considers; these certificates ought to be 53 certified by exactly one of the certificates in the TLS root of trust; 54 intermediate CAs are optional parameters. 55 56 *Valid* identities for this MSP instance are required to satisfy the following conditions: 57 58 - They are in the form of X.509 certificates with a verifiable certificate path to 59 exactly one of the root of trust certificates; 60 - They are not included in any CRL; 61 - And they *list* one or more of the Organizational Units of the MSP configuration 62 in the ``OU`` field of their X.509 certificate structure. 63 64 For more information on the validity of identities in the current MSP implementation, 65 we refer the reader to :doc:`msp-identity-validity-rules`. 66 67 In addition to verification related parameters, for the MSP to enable 68 the node on which it is instantiated to sign or authenticate, one needs to 69 specify: 70 71 - The signing key used for signing by the node (currently only ECDSA keys are 72 supported), and 73 - The node's X.509 certificate, that is a valid identity under the 74 verification parameters of this MSP. 75 76 It is important to note that MSP identities never expire; they can only be revoked 77 by adding them to the appropriate CRLs. Additionally, there is currently no 78 support for enforcing revocation of TLS certificates. 79 80 How to generate MSP certificates and their signing keys? 81 -------------------------------------------------------- 82 83 `Openssl <https://www.openssl.org/>`_ can be used to generate X.509 84 certificates and keys. Please note that Hechain does not support 85 RSA key and certificates. 86 87 The Hechain CA can also be used to generate the keys and certificates 88 needed to configure an MSP. Check out 89 `Registering and enrolling identities with a CA <https://hyperledger-fabric-ca.readthedocs.io/en/latest/deployguide/use_CA.html>`_ 90 for more information about how to generate MSPs for nodes and organizations. 91 92 Organizational Units 93 -------------------- 94 95 In order to configure the list of Organizational Units that valid members of this MSP should 96 include in their X.509 certificate, the ``config.yaml`` file 97 needs to specify the organizational unit (OU, for short) identifiers. You can find an example 98 below: 99 100 :: 101 102 OrganizationalUnitIdentifiers: 103 - Certificate: "cacerts/cacert1.pem" 104 OrganizationalUnitIdentifier: "commercial" 105 - Certificate: "cacerts/cacert2.pem" 106 OrganizationalUnitIdentifier: "administrators" 107 108 The above example declares two organizational unit identifiers: **commercial** and **administrators**. 109 An MSP identity is valid if it carries at least one of these organizational unit identifiers. 110 The ``Certificate`` field refers to the CA or intermediate CA certificate path 111 under which identities, having that specific OU, should be validated. 112 The path is relative to the MSP root folder and cannot be empty. 113 114 Identity classification 115 ----------------------- 116 117 The default MSP implementation allows organizations to further classify identities into clients, 118 admins, peers, and orderers based on the OUs of their x509 certificates. 119 120 * An identity should be classified as a **client** if it transacts on the network. 121 * An identity should be classified as an **admin** if it handles administrative tasks such as 122 joining a peer to a channel or signing a channel configuration update transaction. 123 * An identity should be classified as a **peer** if it endorses or commits transactions. 124 * An identity should be classified as an **orderer** if belongs to an ordering node. 125 126 In order to define the clients, admins, peers, and orderers of a given MSP, the ``config.yaml`` file 127 needs to be set appropriately. You can find an example NodeOU section of the ``config.yaml`` file 128 below: 129 130 :: 131 132 NodeOUs: 133 Enable: true 134 # For each identity classification that you would like to utilize, specify 135 # an OU identifier. 136 # You can optionally configure that the OU identifier must be issued by a specific CA 137 # or intermediate certificate from your organization. However, it is typical to NOT 138 # configure a specific Certificate. By not configuring a specific Certificate, you will be 139 # able to add other CA or intermediate certs later, without having to reissue all credentials. 140 # For this reason, the sample below comments out the Certificate field. 141 ClientOUIdentifier: 142 # Certificate: "cacerts/cacert.pem" 143 OrganizationalUnitIdentifier: "client" 144 AdminOUIdentifier: 145 # Certificate: "cacerts/cacert.pem" 146 OrganizationalUnitIdentifier: "admin" 147 PeerOUIdentifier: 148 # Certificate: "cacerts/cacert.pem" 149 OrganizationalUnitIdentifier: "peer" 150 OrdererOUIdentifier: 151 # Certificate: "cacerts/cacert.pem" 152 OrganizationalUnitIdentifier: "orderer" 153 154 Identity classification is enabled when ``NodeOUs.Enable`` is set to ``true``. Then the client 155 (admin, peer, orderer) organizational unit identifier is defined by setting the properties of 156 the ``NodeOUs.ClientOUIdentifier`` (``NodeOUs.AdminOUIdentifier``, ``NodeOUs.PeerOUIdentifier``, 157 ``NodeOUs.OrdererOUIdentifier``) key: 158 159 a. ``OrganizationalUnitIdentifier``: Is the OU value that the x509 certificate needs to contain 160 to be considered a client (admin, peer, orderer respectively). If this field is empty, then the classification 161 is not applied. 162 b. ``Certificate``: (Optional) Set this to the path of the CA or intermediate CA certificate 163 under which client (peer, admin or orderer) identities should be validated. 164 The field is relative to the MSP root folder. Only a single Certificate can be specified. 165 If you do not set this field, then the identities are validated under any CA defined in 166 the organization's MSP configuration, which could be desirable in the future if you need 167 to add other CA or intermediate certificates. 168 169 Notice that if the ``NodeOUs.ClientOUIdentifier`` section (``NodeOUs.AdminOUIdentifier``, 170 ``NodeOUs.PeerOUIdentifier``, ``NodeOUs.OrdererOUIdentifier``) is missing, then the classification 171 is not applied. If ``NodeOUs.Enable`` is set to ``true`` and no classification keys are defined, 172 then identity classification is assumed to be disabled. 173 174 Identities can use organizational units to be classified as either a client, an admin, a peer, or an 175 orderer. The four classifications are mutually exclusive. 176 The 1.1 channel capability needs to be enabled before identities can be classified as clients 177 or peers. The 1.4.3 channel capability needs to be enabled for identities to be classified as an 178 admin or orderer. 179 180 Classification allows identities to be classified as admins (and conduct administrator actions) 181 without the certificate being stored in the ``admincerts`` folder of the MSP. Instead, the 182 ``admincerts`` folder can remain empty and administrators can be created by enrolling identities 183 with the admin OU. Certificates in the ``admincerts`` folder will still grant the role of 184 administrator to their bearer, provided that they possess the client or admin OU. 185 186 Adding MSPs to channels 187 ----------------------- 188 189 For information about how to add MSPs to a channel (including the decision of 190 whether to bootstrap ordering nodes with a system channel genesis block), check 191 out :doc:`create_channel/create_channel_overview`. 192 193 Best practices 194 -------------- 195 196 In this section we elaborate on best practices for MSP 197 configuration in commonly met scenarios. 198 199 **1) Mapping between organizations/corporations and MSPs** 200 201 We recommend that there is a one-to-one mapping between organizations and MSPs. 202 If a different type of mapping is chosen, the following needs to be to 203 considered: 204 205 - **One organization employing various MSPs.** This corresponds to the 206 case of an organization including a variety of divisions each represented 207 by its MSP, either for management independence reasons, or for privacy reasons. 208 In this case a peer can only be owned by a single MSP, and will not recognize 209 peers with identities from other MSPs as peers of the same organization. The 210 implication of this is that peers may share through gossip organization-scoped 211 data with a set of peers that are members of the same subdivision, and NOT with 212 the full set of providers constituting the actual organization. 213 - **Multiple organizations using a single MSP.** This corresponds to a 214 case of a consortium of organizations that are governed by similar 215 membership architecture. One needs to know here that peers would propagate 216 organization-scoped messages to the peers that have an identity under the 217 same MSP regardless of whether they belong to the same actual organization. 218 This is a limitation of the granularity of MSP definition, and/or of the peer’s 219 configuration. 220 221 **2) One organization has different divisions (say organizational units), to** 222 **which it wants to grant access to different channels.** 223 224 Two ways to handle this: 225 226 - **Define one MSP to accommodate membership for all organization’s members**. 227 Configuration of that MSP would consist of a list of root CAs, 228 intermediate CAs and admin certificates; and membership identities would 229 include the organizational unit (``OU``) a member belongs to. Policies can then 230 be defined to capture members of a specific ``role`` (should be one of: peer, admin, 231 client, orderer, member), and these policies may constitute the read/write policies 232 of a channel or endorsement policies of a chaincode. Specifying custom OUs in 233 the profile section of ``configtx.yaml`` is currently not configured. 234 A limitation of this approach is that gossip peers would 235 consider peers with membership identities under their local MSP as 236 members of the same organization, and would consequently gossip 237 with them organization-scoped data (e.g. their status). 238 - **Defining one MSP to represent each division**. This would involve specifying for each 239 division, a set of certificates for root CAs, intermediate CAs, and admin 240 Certs, such that there is no overlapping certification path across MSPs. 241 This would mean that, for example, a different intermediate CA per subdivision 242 is employed. Here the disadvantage is the management of more than one 243 MSPs instead of one, but this circumvents the issue present in the previous 244 approach. One could also define one MSP for each division by leveraging an OU 245 extension of the MSP configuration. 246 247 **3) Separating clients from peers of the same organization.** 248 249 In many cases it is required that the “type” of an identity is retrievable 250 from the identity itself (e.g. it may be needed that endorsements are 251 guaranteed to have derived by peers, and not clients or nodes acting solely 252 as orderers). 253 254 There is limited support for such requirements. 255 256 One way to allow for this separation is to create a separate intermediate 257 CA for each node type - one for clients and one for peers/orderers; and 258 configure two different MSPs - one for clients and one for peers/orderers. 259 Channels this organization should be accessing would need to include 260 both MSPs, while endorsement policies will leverage only the MSP that 261 refers to the peers. This would ultimately result in the organization 262 being mapped to two MSP instances, and would have certain consequences 263 on the way peers and clients interact. 264 265 Gossip would not be drastically impacted as all peers of the same organization 266 would still belong to one MSP. Peers can restrict the execution of certain 267 system chaincodes to local MSP based policies. For 268 example, peers would only execute “joinChannel” request if the request is 269 signed by the admin of their local MSP who can only be a client (end-user 270 should be sitting at the origin of that request). We can go around this 271 inconsistency if we accept that the only clients to be members of a 272 peer/orderer MSP would be the administrators of that MSP. 273 274 Another point to be considered with this approach is that peers 275 authorize event registration requests based on membership of request 276 originator within their local MSP. Clearly, since the originator of the 277 request is a client, the request originator is always deemed to belong 278 to a different MSP than the requested peer and the peer would reject the 279 request. 280 281 **4) Admin and CA certificates.** 282 283 It is important to set MSP admin certificates to be different than any of the 284 certificates considered by the MSP for ``root of trust``, or intermediate CAs. 285 This is a common (security) practice to separate the duties of management of 286 membership components from the issuing of new certificates, and/or validation of existing ones. 287 288 **5) Blocking an intermediate CA.** 289 290 As mentioned in previous sections, reconfiguration of an MSP is achieved by 291 reconfiguration mechanisms (manual reconfiguration for the local MSP instances, 292 and via properly constructed ``config_update`` messages for MSP instances of a channel). 293 Clearly, there are two ways to ensure an intermediate CA considered in an MSP is no longer 294 considered for that MSP's identity validation: 295 296 1. Reconfigure the MSP to no longer include the certificate of that 297 intermediate CA in the list of trusted intermediate CA certs. For the 298 locally configured MSP, this would mean that the certificate of this CA is 299 removed from the ``intermediatecerts`` folder. 300 2. Reconfigure the MSP to include a CRL produced by the root of trust 301 which denounces the mentioned intermediate CA's certificate. 302 303 In the current MSP implementation we only support method (1) as it is simpler 304 and does not require blocking the no longer considered intermediate CA. 305 306 **6) CAs and TLS CAs** 307 308 MSP identities' root CAs and MSP TLS certificates' root CAs (and relative intermediate CAs) 309 need to be declared in different folders. This is to avoid confusion between 310 different classes of certificates. It is not forbidden to reuse the same 311 CAs for both MSP identities and TLS certificates but best practices suggest 312 to avoid this in production. 313 314 .. Licensed under Creative Commons Attribution 4.0 International License 315 https://creativecommons.org/licenses/by/4.0/