github.com/yacovm/fabric@v2.0.0-alpha.0.20191128145320-c5d4087dc723+incompatible/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 Hyperledger Fabric component that offers
     7  an abstraction of membership operations.
     8  
     9  In particular, MSP abstracts away all cryptographic mechanisms and protocols
    10  behind issuing certificates, 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) CA 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 representing the administrators of this MSP with a
    52    verifiable certificate path to exactly one of the CA certificates of the
    53    root of trust; owners of these certificates are authorized to request changes
    54    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 organizations 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 emphasize 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 configure the supported Organizational Units
   121     and identity classifications (see respective sections below).
   122  5. (optional) a folder ``crls`` to include the considered CRLs
   123  6. a folder ``keystore`` to include a PEM file with the node's signing key;
   124     we emphasise that currently RSA keys are not supported
   125  7. a folder ``signcerts`` to include a PEM file with the node's X.509
   126     certificate
   127  8. (optional) a folder ``tlscacerts`` to include PEM files each corresponding to a TLS root
   128     CA's certificate
   129  9. (optional) a folder ``tlsintermediatecerts`` to include PEM files each
   130     corresponding to an intermediate TLS CA's certificate
   131  
   132  In the configuration file of the node (core.yaml file for the peer, and
   133  orderer.yaml for the orderer), one needs to specify the path to the
   134  mspconfig folder, and the MSP Identifier of the node's MSP. The path to the
   135  mspconfig folder is expected to be relative to FABRIC_CFG_PATH and is provided
   136  as the value of parameter ``mspConfigPath`` for the peer, and ``LocalMSPDir``
   137  for the orderer. The identifier of the node's MSP is provided as a value of
   138  parameter ``localMspId`` for the peer and ``LocalMSPID`` for the orderer.
   139  These variables can be overridden via the environment using the CORE prefix for
   140  peer (e.g. CORE_PEER_LOCALMSPID) and the ORDERER prefix for the orderer (e.g.
   141  ORDERER_GENERAL_LOCALMSPID). Notice that for the orderer setup, one needs to
   142  generate, and provide to the orderer the genesis block of the system channel.
   143  The MSP configuration needs of this block are detailed in the next section.
   144  
   145  *Reconfiguration* of a "local" MSP is only possible manually, and requires that
   146  the peer or orderer process is restarted. In subsequent releases we aim to
   147  offer online/dynamic reconfiguration (i.e. without requiring to stop the node
   148  by using a node managed system chaincode).
   149  
   150  Organizational Units
   151  --------------------
   152  
   153  In order to configure the list of Organizational Units that valid members of this MSP should
   154  include in their X.509 certificate, the ``config.yaml`` file
   155  needs to specify the organizational unit (OU, for short) identifiers. You can find an example
   156  below:
   157  
   158  ::
   159  
   160     OrganizationalUnitIdentifiers:
   161       - Certificate: "cacerts/cacert1.pem"
   162         OrganizationalUnitIdentifier: "commercial"
   163       - Certificate: "cacerts/cacert2.pem"
   164         OrganizationalUnitIdentifier: "administrators"
   165  
   166  The above example declares two organizational unit identifiers: **commercial** and **administrators**.
   167  An MSP identity is valid if it carries at least one of these organizational unit identifiers.
   168  The ``Certificate`` field refers to the CA or intermediate CA certificate path
   169  under which identities, having that specific OU, should be validated.
   170  The path is relative to the MSP root folder and cannot be empty.
   171  
   172  Identity Classification
   173  -----------------------
   174  
   175  The default MSP implementation allows organizations to further classify identities into clients,
   176  admins, peers, and orderers based on the OUs of their x509 certificates.
   177  
   178  * An identity should be classified as a **client** if it transacts on the network.
   179  * An identity should be classified as an **admin** if it handles administrative tasks such as
   180    joining a peer to a channel or signing a channel configuration update transaction.
   181  * An identity should be classified as a **peer** if it endorses or commits transactions.
   182  * An identity should be classified as an **orderer** if belongs to an ordering node.
   183  
   184  In order to define the clients, admins, peers, and orderers of a given MSP, the ``config.yaml`` file
   185  needs to be set appropriately. You can find an example NodeOU section of the ``config.yaml`` file
   186  below:
   187  
   188  ::
   189  
   190     NodeOUs:
   191       Enable: true
   192       ClientOUIdentifier:
   193         Certificate: "cacerts/cacert.pem"
   194         OrganizationalUnitIdentifier: "client"
   195       AdminOUIdentifier:
   196         Certificate: "cacerts/cacert.pem"
   197         OrganizationalUnitIdentifier: "admin"
   198       PeerOUIdentifier:
   199         Certificate: "cacerts/cacert.pem"
   200         OrganizationalUnitIdentifier: "peer"
   201       OrdererOUIdentifier:
   202         Certificate: "cacerts/cacert.pem"
   203         OrganizationalUnitIdentifier: "orderer"
   204  
   205  Identity classification is enabled when ``NodeOUs.Enable`` is set to ``true``. Then the client
   206  (admin, peer, orderer) organizational unit identifier is defined by setting the properties of
   207  the ``NodeOUs.ClientOUIdentifier`` (``NodeOUs.AdminOUIdentifier``, ``NodeOUs.PeerOUIdentifier``,
   208  ``NodeOUs.OrdererOUIdentifier``) key:
   209  
   210  a. ``OrganizationalUnitIdentifier``: Is the OU value that the x509 certificate needs to contain
   211     to be considered a client (admin, peer, orderer respectively). If this field is empty, then the classification
   212     is not applied.
   213  b. ``Certificate``: Set this to the path of the CA or intermediate CA certificate under which client
   214     (peer, admin or orderer) identities should be validated. The field is relative to the MSP root
   215     folder. This field is optional. You can leave this field blank and allow the certificate to be
   216     validated under any CA defined in the MSP configuration.
   217  
   218  Notice that if the ``NodeOUs.ClientOUIdentifier`` section (``NodeOUs.AdminOUIdentifier``,
   219  ``NodeOUs.PeerOUIdentifier``, ``NodeOUs.OrdererOUIdentifier``) is missing, then the classification
   220  is not applied. If ``NodeOUs.Enable`` is set to ``true`` and no classification keys are defined,
   221  then identity classification is assumed to be disabled.
   222  
   223  Identities can use organizational units to be classified as either a client, an admin, a peer, or an
   224  orderer. The four classifications are mutually exclusive.
   225  The 1.1 channel capability needs to be enabled before identities can be classified as clients
   226  or peers. The 1.4.3 channel capability needs to be enabled for identities to be classified as an
   227  admin or orderer.
   228  
   229  Classification allows identities to be classified as admins (and conduct administrator actions)
   230  without the certificate being stored in the ``admincerts`` folder of the MSP. Instead, the
   231  ``admincerts`` folder can remain empty and administrators can be created by enrolling identities
   232  with the admin OU. Certificates in the ``admincerts`` folder will still grant the role of
   233  administrator to their bearer, provided that they possess the client or admin OU.
   234  
   235  Channel MSP setup
   236  -----------------
   237  
   238  At the genesis of the system, verification parameters of all the MSPs that
   239  appear in the network need to be specified, and included in the system
   240  channel's genesis block. Recall that MSP verification parameters consist of
   241  the MSP identifier, the root of trust certificates, intermediate CA and admin
   242  certificates, as well as OU specifications and CRLs.
   243  The system genesis block is provided to the orderers at their setup phase,
   244  and allows them to authenticate channel creation requests. Orderers would
   245  reject the system genesis block, if the latter includes two MSPs with the same
   246  identifier, and consequently the bootstrapping of the network would fail.
   247  
   248  For application channels, the verification components of only the MSPs that
   249  govern a channel need to reside in the channel's genesis block. We emphasize
   250  that it is **the responsibility of the application** to ensure that correct
   251  MSP configuration information is included in the genesis blocks (or the
   252  most recent configuration block) of a channel prior to instructing one or
   253  more of their peers to join the channel.
   254  
   255  When bootstrapping a channel with the help of the configtxgen tool, one can
   256  configure the channel MSPs by including the verification parameters of MSP
   257  in the mspconfig folder, and setting that path in the relevant section in
   258  ``configtx.yaml``.
   259  
   260  *Reconfiguration* of an MSP on the channel, including announcements of the
   261  certificate revocation lists associated to the CAs of that MSP is achieved
   262  through the creation of a ``config_update`` object by the owner of one of the
   263  administrator certificates of the MSP. The client application managed by the
   264  admin would then announce this update to the channels in which this MSP appears.
   265  
   266  Best Practices
   267  --------------
   268  
   269  In this section we elaborate on best practices for MSP
   270  configuration in commonly met scenarios.
   271  
   272  **1) Mapping between organizations/corporations and MSPs**
   273  
   274  We recommend that there is a one-to-one mapping between organizations and MSPs.
   275  If a different type of mapping is chosen, the following needs to be to
   276  considered:
   277  
   278  - **One organization employing various MSPs.** This corresponds to the
   279    case of an organization including a variety of divisions each represented
   280    by its MSP, either for management independence reasons, or for privacy reasons.
   281    In this case a peer can only be owned by a single MSP, and will not recognize
   282    peers with identities from other MSPs as peers of the same organization. The
   283    implication of this is that peers may share through gossip organization-scoped
   284    data with a set of peers that are members of the same subdivision, and NOT with
   285    the full set of providers constituting the actual organization.
   286  - **Multiple organizations using a single MSP.** This corresponds to a
   287    case of a consortium of organizations that are governed by similar
   288    membership architecture. One needs to know here that peers would propagate
   289    organization-scoped messages to the peers that have an identity under the
   290    same MSP regardless of whether they belong to the same actual organization.
   291    This is a limitation of the granularity of MSP definition, and/or of the peer’s
   292    configuration.
   293  
   294  **2) One organization has different divisions (say organizational units), to**
   295  **which it wants to grant access to different channels.**
   296  
   297  Two ways to handle this:
   298  
   299  - **Define one MSP to accommodate membership for all organization’s members**.
   300    Configuration of that MSP would consist of a list of root CAs,
   301    intermediate CAs and admin certificates; and membership identities would
   302    include the organizational unit (``OU``) a member belongs to. Policies can then
   303    be defined to capture members of a specific ``OU``, and these policies may
   304    constitute the read/write policies of a channel or endorsement policies of
   305    a chaincode. A limitation of this approach is that gossip peers would
   306    consider peers with membership identities under their local MSP as
   307    members of the same organization, and would consequently gossip
   308    with them organization-scoped data (e.g. their status).
   309  - **Defining one MSP to represent each division**.  This would involve specifying for each
   310    division, a set of certificates for root CAs, intermediate CAs, and admin
   311    Certs, such that there is no overlapping certification path across MSPs.
   312    This would mean that, for example, a different intermediate CA per subdivision
   313    is employed. Here the disadvantage is the management of more than one
   314    MSPs instead of one, but this circumvents the issue present in the previous
   315    approach.  One could also define one MSP for each division by leveraging an OU
   316    extension of the MSP configuration.
   317  
   318  **3) Separating clients from peers of the same organization.**
   319  
   320  In many cases it is required that the “type” of an identity is retrievable
   321  from the identity itself (e.g. it may be needed that endorsements are
   322  guaranteed to have derived by peers, and not clients or nodes acting solely
   323  as orderers).
   324  
   325  There is limited support for such requirements.
   326  
   327  One way to allow for this separation is to create a separate intermediate
   328  CA for each node type - one for clients and one for peers/orderers; and
   329  configure two different MSPs - one for clients and one for peers/orderers.
   330  Channels this organization should be accessing would need to include
   331  both MSPs, while endorsement policies will leverage only the MSP that
   332  refers to the peers. This would ultimately result in the organization
   333  being mapped to two MSP instances, and would have certain consequences
   334  on the way peers and clients interact.
   335  
   336  Gossip would not be drastically impacted as all peers of the same organization
   337  would still belong to one MSP. Peers can restrict the execution of certain
   338  system chaincodes to local MSP based policies. For
   339  example, peers would only execute “joinChannel” request if the request is
   340  signed by the admin of their local MSP who can only be a client (end-user
   341  should be sitting at the origin of that request). We can go around this
   342  inconsistency if we accept that the only clients to be members of a
   343  peer/orderer MSP would be the administrators of that MSP.
   344  
   345  Another point to be considered with this approach is that peers
   346  authorize event registration requests based on membership of request
   347  originator within their local MSP. Clearly, since the originator of the
   348  request is a client, the request originator is always deemed to belong
   349  to a different MSP than the requested peer and the peer would reject the
   350  request.
   351  
   352  **4) Admin and CA certificates.**
   353  
   354  It is important to set MSP admin certificates to be different than any of the
   355  certificates considered by the MSP for ``root of trust``, or intermediate CAs.
   356  This is a common (security) practice to separate the duties of management of
   357  membership components from the issuing of new certificates, and/or validation of existing ones.
   358  
   359  **5) Blacklisting an intermediate CA.**
   360  
   361  As mentioned in previous sections, reconfiguration of an MSP is achieved by
   362  reconfiguration mechanisms (manual reconfiguration for the local MSP instances,
   363  and via properly constructed ``config_update`` messages for MSP instances of a channel).
   364  Clearly, there are two ways to ensure an intermediate CA considered in an MSP is no longer
   365  considered for that MSP's identity validation:
   366  
   367  1. Reconfigure the MSP to no longer include the certificate of that
   368     intermediate CA in the list of trusted intermediate CA certs. For the
   369     locally configured MSP, this would mean that the certificate of this CA is
   370     removed from the ``intermediatecerts`` folder.
   371  2. Reconfigure the MSP to include a CRL produced by the root of trust
   372     which denounces the mentioned intermediate CA's certificate.
   373  
   374  In the current MSP implementation we only support method (1) as it is simpler
   375  and does not require blacklisting the no longer considered intermediate CA.
   376  
   377  **6) CAs and TLS CAs**
   378  
   379  MSP identities' root CAs and MSP TLS certificates' root CAs (and relative intermediate CAs)
   380  need to be declared in different folders. This is to avoid confusion between
   381  different classes of certificates. It is not forbidden to reuse the same
   382  CAs for both MSP identities and TLS certificates but best practices suggest
   383  to avoid this in production.
   384  
   385  .. Licensed under Creative Commons Attribution 4.0 International License
   386     https://creativecommons.org/licenses/by/4.0/