Skip to content

Commit

Permalink
Merge pull request #577 from stone-ch/release-2.0
Browse files Browse the repository at this point in the history
translation finished #480
  • Loading branch information
greatcyang committed Feb 11, 2020
2 parents 92f5ee3 + cfdc1b0 commit da95446
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 93 deletions.
112 changes: 29 additions & 83 deletions docs/source/hsm.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,24 @@
# Using a Hardware Security Module (HSM)

You can use a Hardware Security Module (HSM) to generate and store the private
keys used by your Fabric nodes. An HSM protects your private keys and handles
cryptographic operations, which allows your peers and ordering nodes to sign and
endorse transactions without exposing their private keys. Currently, Fabric only
supports the PKCS11 standard to communicate with an HSM.

## Configuring an HSM

To use an HSM with your Fabric node, you need to update the BCCSP (Crypto Service
Provider) section of the node configuration file such as core.yaml or
orderer.yaml. In BCCSP section, you need to select PKCS11 as the provider and
provide the path to the PKCS11 library that you would like to use. You also need
to provide the label and pin of the token that you created for your cryptographic
operations. You can use one token to generate and store multiple keys.

The prebuilt Hyperledger Fabric Docker images are not enabled to use PKCS11. If
you are deploying Fabric using docker, you need to build your own images and
enable PKCS11 using the following command:
# 使用硬件安全模块(Hardware Security Module,HSM)

你可以使用硬件安全模块(HSM)来生成和存储 Fabric 节点使用的私钥。HSM 可以保护你的私钥并处理密码学操作,它可以让 Peer 节点和排序节点在不暴露私钥的情况下进行签名和背书。目前,Fabric 只支持按照 PKCS11 标准和 HSM 进行通信。

## 配置 HSM

要在 Fabric 节点中使用 HSM,你需要更在节点配置文件(比如 core.yaml 或者 orderer.yaml)中更新 BCCSP (Crypto Service Provider,加密服务提供者) 部分。在 BCCSP 部分中,你需要选择 PKCS11 作为提供者,并且要选择你要使用的 PKCS11 库所在的路径。你还需要提供你创建秘钥文件的 label 和 pin。你可以使用一个秘钥生成和保存多个秘钥。

预编译的 Hyperledger Fabric Docker 镜像不支持使用 PKCS11。如果你使用 docker 部署 Fabric,你需要重新编译镜像并启用 PKCS11,编译命令如下:
```
make docker GO_TAGS=pkcs11
```
You also need to ensure that the PKCS11 library is available to be used by the
node by installing it or mounting it inside the container.
你需要确保 PKCS11 库可用,你可以在节点上安装它,也可以把它挂在到容器里。

### Example
### 示例

The following example demonstrates how to configure a Fabric node to use an HSM.
下边的示例演示了如何配置 Fabric 节点使用 HSM

First, you will need to install an implementation of the PKCS11 interface. This
example uses the [softhsm](https://github.com/opendnssec/SoftHSMv2) open source
implementation. After downloading and configuring softhsm, you will need to set
the SOFTHSM2_CONF environment variable to point to the softhsm2 configuration
file.
首先,你需要安装 PKCS11 接口的实现。本示例使用开源实现 [softhsm](https://github.com/opendnssec/SoftHSMv2)。下载并配置 softhsm 之后,你需要将环境变量 SOFTHSM2_CONF 设置为 softhsm2 的配置文件。

You can then use softhsm to create the token that will handle the cryptographic
operations of your Fabric node inside an HSM slot. In this example, we create a
token labelled "fabric" and set the pin to "71811222". After you have created
the token, update the configuration file to use PKCS11 and your token as the
crypto service provider. You can find an example BCCSP section below:
然后你就可以使用 softhsm 来创建秘钥并在 Fabric 节点内部的 HSM slot 中处理密码学操作。在本示例中,我们创建了一个标记为 “fabric” 并把 pin 设置为 “71811222” 的秘钥。你创建秘钥之后,将配置文件修改为使用 PKCS11 和你的秘钥作为加密服务提供者。下边是一个 BCCSP 部分的示例:

```
#############################################################################
Expand All @@ -55,9 +35,7 @@ bccsp:
security: 256
```

You can also use environment variables to override the relevant fields of the
configuration file. If you are connecting to an HSM using the Fabric CA server,
you need to set the following environment variables:
你也可以使用环境变量覆盖配置文件中相关字段。如果你使用 Fabric CA 服务端链接 HSM,你需要设置如下环境变量:

```
FABRIC_CA_SERVER_BCCSP_DEFAULT=PKCS11
Expand All @@ -66,11 +44,7 @@ FABRIC_CA_SERVER_BCCSP_PKCS11_PIN=71811222
FABRIC_CA_SERVER_BCCSP_PKCS11_LABEL=fabric
```

If you are deploying your nodes using docker compose, after building your own
images, you can update your docker compose files to mount the softhsm library
and configuration file inside the container using volumes. As an example, you
would add the following environment and volumes variables to your docker compose
file:
如果你编译了 docker 镜像并使用 docker compose 部署节点,你可以修改 docker compose 配置文件的 volumes 部分来挂载 softhsm 库和配置文件。下边的示例演示了如何在docker compose 配置文件中设置环境变量和 volumes:
```
environment:
- SOFTHSM2_CONF=/etc/hyperledger/fabric/config.file
Expand All @@ -79,59 +53,31 @@ file:
- /usr/local/Cellar/softhsm/2.1.0/lib/softhsm/libsofthsm2.so:/etc/hyperledger/fabric/libsofthsm2.so
```

## Setting up a network using HSM
## 设置一个使用 HSM 的网络

If you are deploying Fabric nodes using an HSM, your private keys need to be
generated inside the HSM rather than inside the `keystore` folder of the node's
local MSP folder. The `keystore` folder of the MSP will remain empty. Instead,
the Fabric node will use the subject key identifier of the signing certificate
in the `signcerts` folder to retrieve the private key from inside the HSM.
The process for creating the MSP folders will be different depending on if you
are using a Fabric Certificate Authority (CA) your own CA.
如果你使用 HSM 部署 Fabric 节点,你需要在 HSM 中生成私钥而不是在节点本地 MSP 目录的 `keystore` 目录中。MSP 的 `keystore` 目录置空。另外,Fabric 节点会使用 `signcerts` 目录中签名证书的主体密钥标识符(subject key identifier)来检索 HSM 中的私钥。根据你使用 Fabric CA(Certificate Authority)还是你自己的 CA 的情况,创建 MSP 目录的操作是不一样的。

### Using a Fabric CA
### 使用 Fabric CA

You can set up a Fabric CA to use an HSM by making the same edits to the
configuration file as you would make to a peer or ordering node. Because you can
use Fabric CA to generate keys inside an HSM, the process of creating the local
MSP folders is straightforward. Use the following steps:
你可以像 Peer 节点或者排序节点一样,通过修改配置文件让 Fabric CA 使用 HSM。因为你可以使用 Fabric CA 在 HSM 内部生成秘钥,所以创建本地 MSP 目录的过程就很简单。按照下边的步骤:

1. Create an HSM token and point to it in the Fabric CA server configuration
file. When the Fabric CA server starts, it will generate the CA signing
certificate inside your HSM. If you are not concerned about exposing your CA
signing certificate, you can skip this step.
1. 创建一个 HSM 秘钥并把它指向 Fabric CA 服务端配置文件。当 Fabric CA 服务端启动时,它就会在 HSM 内部生成 CA 签名证书。如果你不想暴露你的 CA 签名证书,你可以跳过这一步。

2. Use the Fabric CA client to register the peer or ordering node identities
with your CA.
2. 使用 Fabrci CA 客户端,用你的 CA 来注册 Peer 节点或者排序几点的身份。

3. Edit the Fabric CA client config file or environment variables to use your
HSM as the crypto service provider. Then for each node, use the Fabric CA client
to generate the component MSP folder by enrolling against the node identity. The
enroll command will generate the private key inside your HSM.
3. 编辑 Fabric CA 客户端配置文件或者环境变量来使用你的 HSM 作为加密服务提供者。然后,对于每一个节点,都根据节点身份信息使用 Fabric CA 客户端生成相关的 MSP 目录。 enroll 命令会在你的 HSM 中生成私钥。

3. Update the BCCSP section of the peer or orderer configuration file to use
PKCS11 and your token as the crypto service provider. Point to the MSP that was
generated using the Fabric CA client. Once it is deployed, the peer or orderer
node will be able sign and endorse transactions with the private key protected by
the HSM.
4. 将 Peer 节点或排序节点配置文件的 BCCSP 部分设置为使用你的秘钥作为加密服务提供者。指向 Fabric CA 客户端生成的 MSP 目录。完成部署后,Peer 节点或排序节点就会使用被 HSM 保护的私钥来签名和背书交易了。

### Using an HSM with your own CA
### 在你自己的 CA 上使用 HSM

If you are using your own Certificate Authority to deploy Fabric components, you
can use an HSM using the following steps:
如果你使用你自己的 CA 来部署 Fabric 组件,你可以按如下步骤使用 HSM:

1. Configure your CA to communicate with an HSM using PKCS11 and create a token.
Then use your CA to generate the private key and signing certificate for each
node, with the private key generated inside the HSM.
1. 将你的 CA 配置为通过 PKCS11 和 HSM 进行通信并且创建秘钥。然后用你的 CA 为每个节点生成私钥和签名证书,生成的私钥会保存在 HSM 中。

2. Use your CA to build the node MSP folder. Place the signing certificate that
you generated in step 1 inside the `signcerts` folder. You can leave the
`keystore` folder empty.
2. 使用你的 CA 构建节点 MSP 目录。将第 1 步生成的签名证书放入 `signcerts` 目录。`keystore` 目录为空。

3. Update the peer or orderer configuration file to use PKCS11 and your token as
the crypto service provider. Point to the MSP folder that you created with the
signing certificate inside. Once it has deployed, the peer or ordering node will
be able to sign and endorse transactions using the HSM.
3. 将 Peer 节点或排序节点配置文件设置为使用你的秘钥作为加密服务提供者。指向你创建的包含签名证书的 MSP 目录。完成部署后,Peer 节点或排序节点就可以使用 HSM 保来签名和背书交易了。

<!--- Licensed under Creative Commons Attribution 4.0 International License
https://creativecommons.org/licenses/by/4.0/ -->
20 changes: 10 additions & 10 deletions docs/source/whatsnew.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Fabric v2.0 引入了智能合约的去中心化治理,它提供了一个新
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

对于现有的 Fabric 部署,您可以继续使用 Fabric v2.0 之前的链码生命周期。新的链码生命周期只有在通道应用程序功能更新到 v2.0 时才会生效。
关于新的链码生命周期完整细节教程请看 :文档:`chaincode4noah`
关于新的链码生命周期完整细节教程请看 :doc:`chaincode4noah`

用于协作和共识的新链码应用程序模式
------------------------------------------------------------------
Expand All @@ -40,7 +40,7 @@ Fabric v2.0 引入了智能合约的去中心化治理,它提供了一个新

* **自动检查** 如上所述,组织可以在链码功能中添加自动检查,以便在背书事务提案之前验证附加信息。

* **去中心化协议** 链码可能要求来自不同组织的参与者在账本交易中指明他们的协议条款和条件。然后,最终的链码提案可以验证来自所有单个交易者的条件是否得到满足,并最终在所有通道成员之间“解决”业务交易。有关以非公开方式指示条款和条件的具体示例,请参见资产转移场景,于文档中 :文档:`private-data/private-data`.
* **去中心化协议** 链码可能要求来自不同组织的参与者在账本交易中指明他们的协议条款和条件。然后,最终的链码提案可以验证来自所有单个交易者的条件是否得到满足,并最终在所有通道成员之间“解决”业务交易。有关以非公开方式指示条款和条件的具体示例,请参见资产转移场景,于文档中 :doc:`private-data/private-data`.

私有数据增强
-------------------------
Expand All @@ -49,13 +49,13 @@ Fabric v2.0还支持使用和共享私有数据的新模式,而不需要为所

Fabric v2.0 中的几个增强使得这些新的私有数据模式成为可能:

* **共享和验证私有数据** 当私有数据与不是集合成员的通道成员共享时,或者与包含一个或多个通道成员的另一个私有数据集合共享时(通过向该集合写入密钥),接收方可以利用 GetPrivateDataHash()链码 API 验证私有数据是否与以前交易中被创建的来自私有数据的链上哈希匹配。
* **共享和验证私有数据** 当私有数据与不是集合成员的通道成员共享时,或者与包含一个或多个通道成员的另一个私有数据集合共享时(通过向该集合写入密钥),接收方可以利用 GetPrivateDataHash() 链码 API 验证私有数据是否与以前交易中被创建的来自私有数据的链上哈希匹配。

* **集合水平的背书策略** 现在可以选择使用背书策略来定义私有数据集合,该背书策略覆盖集合内密钥的链码级别背书策略。该特性可用于限制哪些组织可以将数据写入集合,并且正是它启用了前面提到的新的链码生命周期和链码应用程序模式。例如,您可能有一个链码背书策略,该策略要求大多数组织背书,但对于任何给定的交易,您可能需要两个交易处理组织在它们自己的私有数据集合中单独背书它们的协议。

* **每个组织的隐式集合** 如果您想利用每个组织的私有数据模式,那么在 Fabric v2.0 中部署链码时甚至不需要定义集合。不需要任何前期定义就可以使用隐式的特定组织集合。

了解更多关于新的私有数据模式请看 :文旦:`private-data/private-data` (概念文档). 更多关于私有数据集合配置和隐式集合请看 :文档:`private-data-arch` (参考文档).
了解更多关于新的私有数据模式请看 :doc:`private-data/private-data` (概念文档). 更多关于私有数据集合配置和隐式集合请看 :doc:`private-data-arch` (参考文档).

外部的链码启动器
---------------------------
Expand All @@ -68,9 +68,9 @@ Fabric v2.0 中的几个增强使得这些新的私有数据模式成为可能:

* **外部构建器可执行文件** 操作员可以提供一组外部构建器可执行文件,以覆盖 Peer 节点构建和启动链码方式。

* **作为外部服务的链码** 传统上,链码由 Peer 节点启动,然后连接回 Peer 节点。现在可以将链码作为外部服务运行,例如在 Kubernetes pod 中, Peer 节点可以连接到该 pod,并利用该 pod 执行链码。了解更多信息请看 :文档:`cc_service`
* **作为外部服务的链码** 传统上,链码由 Peer 节点启动,然后连接回 Peer 节点。现在可以将链码作为外部服务运行,例如在 Kubernetes pod 中, Peer 节点可以连接到该 pod,并利用该 pod 执行链码。了解更多信息请看 :doc:`cc_service`

了解更多关于外部链码启动功能请看 :文档:`cc_launcher` 。
了解更多关于外部链码启动功能请看 :doc:`cc_launcher` 。

用于提高 CouchDB 性能的状态数据库缓存
--------------------------------------------------------
Expand All @@ -82,22 +82,22 @@ Fabric v2.0 中的几个增强使得这些新的私有数据模式成为可能:
基于 Alpine 的 docker 镜像
--------------------------

从 v2.0 开始,Hyperledger Fabric Docker 镜像将使用 Alpine Linux,这是一个面向安全的轻量级 Linux 发行版。这意味着 Docker 镜像现在要小得多,提供更快的下载和启动时间,以及占用主机系统上更少的磁盘空间。Alpine Linux 的设计从一开始就考虑到了安全性,Alpine 发行版的最小化特性大大降低了安全漏洞的风险。
从 v2.0 开始,Hyperledger Fabric Docker 镜像将使用 Alpine Linux 作为基础镜像,这是一个面向安全的轻量级 Linux 发行版。这意味着 Docker 镜像现在要小得多,提供更快的下载和启动时间,以及占用主机系统上更少的磁盘空间。Alpine Linux 的设计从一开始就考虑到了安全性,Alpine 发行版的最小化特性大大降低了安全漏洞的风险。

示例测试网络
-------------------

Fabric-Samples 仓库现在包括一个新的 Fabric 测试网络。测试网络被构建为模块化的和用户友好的示例 Fabric 网络,这使测试您的应用程序和智能合约变得容易。除了 Cryptogen 之外,该网络还支持使用 Certificate Authorities 部署网络的能力。

了解更多关于这个网络的信息,请查看 :文档:`test_network`.
了解更多关于这个网络的信息,请查看 :doc:`test_network`.

升级到 Fabric v2.0
------------------------

一个主要的新版本带来了一些额外的升级注意事项。不过请放心,我们支持从 v1.4.x 到 v2.0 的滚动升级,因此可以一次升级一个网络组件而不会停机。

升级文档得到了显著的扩展和修改,现在在文档中有了一个独立的主页 :文档:`upgrade`. 这里您将会发现文档
:文档:`upgrading_your_components` 和 :文档:`updating_capabilities`, 以及对升级到 v2.0 的注意事项的具体了解, :文档:`upgrade_to_newest_version`。
升级文档得到了显著的扩展和修改,现在在文档中有了一个独立的主页 :doc:`upgrade`. 这里您将会发现文档
:doc:`upgrading_your_components` 和 :doc:`updating_capabilities`, 以及对升级到 v2.0 的注意事项的具体了解, :doc:`upgrade_to_newest_version`。

发行说明
=============
Expand Down

0 comments on commit da95446

Please sign in to comment.