github.com/kaituanwang/hyperledger@v2.0.1+incompatible/docs/source/identity/identity.md (about) 1 # Identity 2 3 ## What is an Identity? 4 5 The different actors in a blockchain network include peers, orderers, client 6 applications, administrators and more. Each of these actors --- active elements 7 inside or outside a network able to consume services --- has a digital identity 8 encapsulated in an X.509 digital certificate. These identities really matter 9 because they **determine the exact permissions over resources and access to 10 information that actors have in a blockchain network.** 11 12 A digital identity furthermore has some additional attributes that Fabric uses 13 to determine permissions, and it gives the union of an identity and the associated 14 attributes a special name --- **principal**. Principals are just like userIDs or 15 groupIDs, but a little more flexible because they can include a wide range of 16 properties of an actor's identity, such as the actor's organization, organizational 17 unit, role or even the actor's specific identity. When we talk about principals, 18 they are the properties which determine their permissions. 19 20 For an identity to be **verifiable**, it must come from a **trusted** authority. 21 A [membership service provider](../membership/membership.html) 22 (MSP) is that trusted authority in Fabric. More specifically, an MSP is a component 23 that defines the rules that govern the valid identities for this organization. 24 The default MSP implementation in Fabric uses X.509 certificates as identities, 25 adopting a traditional Public Key Infrastructure (PKI) hierarchical model (more 26 on PKI later). 27 28 ## A Simple Scenario to Explain the Use of an Identity 29 30 Imagine that you visit a supermarket to buy some groceries. At the checkout you see 31 a sign that says that only Visa, Mastercard and AMEX cards are accepted. If you try to 32 pay with a different card --- let's call it an "ImagineCard" --- it doesn't matter whether 33 the card is authentic and you have sufficient funds in your account. It will be not be 34 accepted. 35 36 ![Scenario](./identity.diagram.6.png) 37 38 *Having a valid credit card is not enough --- it must also be accepted by the store! PKIs 39 and MSPs work together in the same way --- a PKI provides a list of identities, 40 and an MSP says which of these are members of a given organization that participates in 41 the network.* 42 43 PKI certificate authorities and MSPs provide a similar combination of functionalities. 44 A PKI is like a card provider --- it dispenses many different types of verifiable 45 identities. An MSP, on the other hand, is like the list of card providers accepted 46 by the store, determining which identities are the trusted members (actors) 47 of the store payment network. **MSPs turn verifiable identities into the members 48 of a blockchain network**. 49 50 Let's drill into these concepts in a little more detail. 51 52 ## What are PKIs? 53 54 **A public key infrastructure (PKI) is a collection of internet technologies that provides 55 secure communications in a network.** It's PKI that puts the **S** in **HTTPS** --- and if 56 you're reading this documentation on a web browser, you're probably using a PKI to make 57 sure it comes from a verified source. 58 59 ![PKI](./identity.diagram.7.png) 60 61 *The elements of Public Key Infrastructure (PKI). A PKI is comprised of Certificate 62 Authorities who issue digital certificates to parties (e.g., users of a service, service 63 provider), who then use them to authenticate themselves in the messages they exchange 64 in their environment. A CA's Certificate Revocation List (CRL) constitutes a reference 65 for the certificates that are no longer valid. Revocation of a certificate can happen for 66 a number of reasons. For example, a certificate may be revoked because the cryptographic 67 private material associated to the certificate has been exposed.* 68 69 Although a blockchain network is more than a communications network, it relies on the 70 PKI standard to ensure secure communication between various network participants, and to 71 ensure that messages posted on the blockchain are properly authenticated. 72 It's therefore important to understand the basics of PKI and then why MSPs are 73 so important. 74 75 There are four key elements to PKI: 76 77 * **Digital Certificates** 78 * **Public and Private Keys** 79 * **Certificate Authorities** 80 * **Certificate Revocation Lists** 81 82 Let's quickly describe these PKI basics, and if you want to know more details, 83 [Wikipedia](https://en.wikipedia.org/wiki/Public_key_infrastructure) is a good 84 place to start. 85 86 ## Digital Certificates 87 88 A digital certificate is a document which holds a set of attributes relating to 89 the holder of the certificate. The most common type of certificate is the one 90 compliant with the [X.509 standard](https://en.wikipedia.org/wiki/X.509), which 91 allows the encoding of a party's identifying details in its structure. 92 93 For example, Mary Morris in the Manufacturing Division of Mitchell Cars in Detroit, 94 Michigan might have a digital certificate with a `SUBJECT` attribute of `C=US`, 95 `ST=Michigan`, `L=Detroit`, `O=Mitchell Cars`, `OU=Manufacturing`, `CN=Mary Morris /UID=123456`. 96 Mary's certificate is similar to her government identity card --- it provides 97 information about Mary which she can use to prove key facts about her. There are 98 many other attributes in an X.509 certificate, but let's concentrate on just these 99 for now. 100 101 ![DigitalCertificate](./identity.diagram.8.png) 102 103 *A digital certificate describing a party called Mary Morris. Mary is the `SUBJECT` of the 104 certificate, and the highlighted `SUBJECT` text shows key facts about Mary. The 105 certificate also holds many more pieces of information, as you can see. Most importantly, 106 Mary's public key is distributed within her certificate, whereas her private signing key 107 is not. This signing key must be kept private.* 108 109 What is important is that all of Mary's attributes can be recorded using a mathematical 110 technique called cryptography (literally, "*secret writing*") so that tampering will 111 invalidate the certificate. Cryptography allows Mary to present her certificate to others 112 to prove her identity so long as the other party trusts the certificate issuer, known 113 as a **Certificate Authority** (CA). As long as the CA keeps certain cryptographic 114 information securely (meaning, its own **private signing key**), anyone reading the 115 certificate can be sure that the information about Mary has not been tampered with --- 116 it will always have those particular attributes for Mary Morris. Think of Mary's X.509 117 certificate as a digital identity card that is impossible to change. 118 119 ## Authentication, Public keys, and Private Keys 120 121 Authentication and message integrity are important concepts in secure 122 communications. Authentication requires that parties who exchange messages 123 are assured of the identity that created a specific message. For a message to have 124 "integrity" means that cannot have been modified during its transmission. 125 For example, you might want to be sure you're communicating with the real Mary 126 Morris rather than an impersonator. Or if Mary has sent you a message, you might want 127 to be sure that it hasn't been tampered with by anyone else during transmission. 128 129 Traditional authentication mechanisms rely on **digital signatures** that, 130 as the name suggests, allow a party to digitally **sign** its messages. Digital 131 signatures also provide guarantees on the integrity of the signed message. 132 133 Technically speaking, digital signature mechanisms require each party to 134 hold two cryptographically connected keys: a public key that is made widely available 135 and acts as authentication anchor, and a private key that is used to produce 136 **digital signatures** on messages. Recipients of digitally signed messages can verify 137 the origin and integrity of a received message by checking that the 138 attached signature is valid under the public key of the expected sender. 139 140 **The unique relationship between a private key and the respective public key is the 141 cryptographic magic that makes secure communications possible**. The unique 142 mathematical relationship between the keys is such that the private key can be used to 143 produce a signature on a message that only the corresponding public key can match, and 144 only on the same message. 145 146 ![AuthenticationKeys](./identity.diagram.9.png) 147 148 In the example above, Mary uses her private key to sign the message. The signature 149 can be verified by anyone who sees the signed message using her public key. 150 151 ## Certificate Authorities 152 153 As you've seen, an actor or a node is able to participate in the blockchain network, 154 via the means of a **digital identity** issued for it by an authority trusted by the 155 system. In the most common case, digital identities (or simply **identities**) have 156 the form of cryptographically validated digital certificates that comply with X.509 157 standard and are issued by a Certificate Authority (CA). 158 159 CAs are a common part of internet security protocols, and you've probably heard of 160 some of the more popular ones: Symantec (originally Verisign), GeoTrust, DigiCert, 161 GoDaddy, and Comodo, among others. 162 163 ![CertificateAuthorities](./identity.diagram.11.png) 164 165 *A Certificate Authority dispenses certificates to different actors. These certificates 166 are digitally signed by the CA and bind together the actor with the actor's public key 167 (and optionally with a comprehensive list of properties). As a result, if one trusts 168 the CA (and knows its public key), it can trust that the specific actor is bound 169 to the public key included in the certificate, and owns the included attributes, 170 by validating the CA's signature on the actor's certificate.* 171 172 Certificates can be widely disseminated, as they do not include either the 173 actors' nor the CA's private keys. As such they can be used as anchor of 174 trusts for authenticating messages coming from different actors. 175 176 CAs also have a certificate, which they make widely available. This allows the 177 consumers of identities issued by a given CA to verify them by checking that the 178 certificate could only have been generated by the holder of the corresponding 179 private key (the CA). 180 181 In a blockchain setting, every actor who wishes to interact with the network 182 needs an identity. In this setting, you might say that **one or more CAs** can be used 183 to **define the members of an organization's from a digital perspective**. It's 184 the CA that provides the basis for an organization's actors to have a verifiable 185 digital identity. 186 187 ### Root CAs, Intermediate CAs and Chains of Trust 188 189 CAs come in two flavors: **Root CAs** and **Intermediate CAs**. Because Root CAs 190 (Symantec, Geotrust, etc) have to **securely distribute** hundreds of millions 191 of certificates to internet users, it makes sense to spread this process out 192 across what are called *Intermediate CAs*. These Intermediate CAs have their 193 certificates issued by the root CA or another intermediate authority, allowing 194 the establishment of a "chain of trust" for any certificate that is issued by 195 any CA in the chain. This ability to track back to the Root CA not only allows 196 the function of CAs to scale while still providing security --- allowing 197 organizations that consume certificates to use Intermediate CAs with confidence 198 --- it limits the exposure of the Root CA, which, if compromised, would endanger 199 the entire chain of trust. If an Intermediate CA is compromised, on the other 200 hand, there will be a much smaller exposure. 201 202 ![ChainOfTrust](./identity.diagram.1.png) 203 204 *A chain of trust is established between a Root CA and a set of Intermediate CAs 205 as long as the issuing CA for the certificate of each of these Intermediate CAs is 206 either the Root CA itself or has a chain of trust to the Root CA.* 207 208 Intermediate CAs provide a huge amount of flexibility when it comes to the issuance 209 of certificates across multiple organizations, and that's very helpful in a 210 permissioned blockchain system (like Fabric). For example, you'll see that 211 different organizations may use different Root CAs, or the same Root CA with 212 different Intermediate CAs --- it really does depend on the needs of the network. 213 214 ### Fabric CA 215 216 It's because CAs are so important that Fabric provides a built-in CA component to 217 allow you to create CAs in the blockchain networks you form. This component --- known 218 as **Fabric CA** is a private root CA provider capable of managing digital identities of 219 Fabric participants that have the form of X.509 certificates. 220 Because Fabric CA is a custom CA targeting the Root CA needs of Fabric, 221 it is inherently not capable of providing SSL certificates for general/automatic use 222 in browsers. However, because **some** CA must be used to manage identity 223 (even in a test environment), Fabric CA can be used to provide and manage 224 certificates. It is also possible --- and fully appropriate --- to use a 225 public/commercial root or intermediate CA to provide identification. 226 227 If you're interested, you can read a lot more about Fabric CA 228 [in the CA documentation section](http://hyperledger-fabric-ca.readthedocs.io/). 229 230 ## Certificate Revocation Lists 231 232 A Certificate Revocation List (CRL) is easy to understand --- it's just a list of 233 references to certificates that a CA knows to be revoked for one reason or another. 234 If you recall the store scenario, a CRL would be like a list of stolen credit cards. 235 236 When a third party wants to verify another party's identity, it first checks the 237 issuing CA's CRL to make sure that the certificate has not been revoked. A 238 verifier doesn't have to check the CRL, but if they don't they run the risk of 239 accepting a compromised identity. 240 241 ![CRL](./identity.diagram.12.png) 242 243 *Using a CRL to check that a certificate is still valid. If an impersonator tries to 244 pass a compromised digital certificate to a validating party, it can be first 245 checked against the issuing CA's CRL to make sure it's not listed as no longer valid.* 246 247 Note that a certificate being revoked is very different from a certificate expiring. 248 Revoked certificates have not expired --- they are, by every other measure, a fully 249 valid certificate. For more in-depth information about CRLs, click [here](https://hyperledger-fabric-ca.readthedocs.io/en/latest/users-guide.html#generating-a-crl-certificate-revocation-list). 250 251 Now that you've seen how a PKI can provide verifiable identities through a chain of 252 trust, the next step is to see how these identities can be used to represent the 253 trusted members of a blockchain network. That's where a Membership Service Provider 254 (MSP) comes into play --- **it identifies the parties who are the members of a 255 given organization in the blockchain network**. 256 257 To learn more about membership, check out the conceptual documentation on [MSPs](../membership/membership.html). 258 259 <!--- 260 Licensed under Creative Commons Attribution 4.0 International License https://creativecommons.org/licenses/by/4.0/ 261 -->