ネットワークへの第三者証明書を使用する組織の追加
このトピックでは、第三者証明書を使用する組織のOracle Blockchain Platformネットワークへの参加について説明します。
サード・パーティ証明書を使用する組織をOracle Blockchain Platformネットワークに参加させる一般的なワークフロー
第三者認証局(CA)によって発行された証明書を持つ組織は、Oracle Blockchain Platformネットワークに参加者として参加できます。
クライアントのみの組織
このような参加者はクライアントのみの組織で、ピアやオーダラは含まれません。チャネルの作成、ピアへの参加またはチェーンコードのインストールはできません。
- クライアント組織管理者である場合、チェーンコードのデプロイ、呼出しおよび問合せを行います。
- クライアント組織の非管理者である場合、チェーンコードの呼出しおよび問合せを行います。
- チェーンコードをピアにインストールするチェーンコード所有者は、Hyperledger Fabricの
peer chaincode package -i
インスタンス化ポリシーを使用してチェーンコードのインスタンス化ポリシーを設定することで、チェーンコードをデプロイできるユーザーを決定できます。 - チェーンコード・インスタンス化者は、Hyperledger Fabricの
peer chaincode instantiate -P
エンドースメント・ポリシー・コマンドを使用して、チェーンコードを呼び出すことができるユーザーを制御するエンドースメント・ポリシーを設定できます。 - チャネル所有者は、チャネル提案を設定し、アクセス制御リストを問い合せることで、チェーンコードを呼び出すことができるユーザーまたはチェーンコードを問い合せることができるユーザーを決定できます。Hyperledger Fabricのアクセス制御リストを参照してください。
ワークフロー
第三者証明書を使用する組織およびOracle Blockchain Platformファウンダが組織をOracle Blockchain Platformネットワークに参加させるために実行する必要があるタスクは次のとおりです。
タスク | 実行者 | 説明 | その他の情報入手先 |
---|---|---|---|
第三者証明書の取得 | サードパーティ証明書(参加者)組織 | サード・パーティのCAサーバーに移動して必要な証明書ファイルを生成します。必要に応じて、ネットワークへのインポート用にファイルをフォーマットします。 | 第三者証明書の要件 |
インポート用の証明書ファイルを作成 | サードパーティ証明書(参加者)組織 | 参加者の管理者およびCA証明書情報を検索し、その情報を使用してJSON証明書ファイルを作成します。 | 組織の第三者証明書ファイルの作成 |
第三者(参加者)組織の証明書ファイルのアップロード | ファウンダ組織 | コンソールを使用して参加者の証明書ファイルをアップロードしてインポートし、参加者をネットワークに追加します。 | ネットワークに組織を追加するための証明書のインポート |
ネットワーク・創設者から注文サービス設定をエクスポートし、第三者(参加者)組織に提供 | ファウンダ組織 | ファウンダの順序付けサービス設定をJSONファイルに出力し、そのファイルを参加者に送信します。
オーダー・サービス設定ファイルをオープンし、オーダー・サービスのアドレスおよびポートを検索して、それらを参加者に渡します。たとえば次のようにします。
|
参加者またはスケールアウトされたOSNを創設者のオーダリング・サービスに参加 |
チャネルの作成 | 設立者 | 新しいチャネルを作成し、参加者を追加します。 | チャネルの作成 |
チェーンコードのインストールとデプロイ | 設立者 | ファウンダのインスタンスで、チェーンコードをアップロードしてインストールし、デプロイします。チェーンコードをインストールするネットワーク・ピアを選択します。 |
|
第三者(参加者)組織の環境の設定 | サードパーティ証明書(参加者)組織 | チェーンコードを問い合せるか呼び出すには、参加者は:
|
Oracle Blockchain Platformネットワークを使用するための第三者環境の準備 |
第三者証明書の要件
ネットワークに正常に参加するには、組織は必要なサード・パーティ証明書を生成する必要があります。これらの証明書内の情報は、組織の証明書ファイルを作成するために使用され、それがファウンダのインスタンスにインポートされます。
組織が提供する必要がある証明書
CAサーバーから次の証明書を生成する必要があります:
- クライアント・パブリック証明書
- CAルート証明書
これらの証明書の要件
証明書は次の要件を満たしている必要があります:
- 秘密キーの生成時に、Elliptic Curve Digital Signatureアルゴリズム(ECDSA)を使用する必要があります。このアルゴリズムは、Fabric MSPキーで受け入れられる唯一のアルゴリズムです。
- サブジェクト・キー識別子(SKI)は必須で、拡張ファイルでx509拡張子として指定する必要があります。
- キー・ファイルを.keyから.pem形式に変換する必要があります。
- 証明書を.crtから.pem形式に変換する必要があります。
証明書の作成
OpenSSLを使用して証明書を作成するには:
- 自己署名CA証明書/キーを作成します:
openssl ecparam -name prime256v1 -genkey -out ca.key openssl pkcs8 -topk8 -inform PEM -in ca.key -outform pem -nocrypt -out ca-key.pem openssl req -new -key ca-key.pem -out ca.csr openssl x509 -req -days 365 -in ca.csr -signkey ca-key.pem -out ca.crt -extensions x509_ext -extfile opensslca.conf openssl x509 -in ca.crt -out ca.pem -outform PEM
opensslca.conf
ファイルの例を次に示します:[ req ] default_bits = 2048 distinguished_name = subject req_extensions = req_ext x509_extensions = x509_ext string_mask = utf8only [ subject ] countryName = CN #countryName_default = US stateOrProvinceName = Beijing #stateOrProvinceName_default = NY localityName = Beijing #localityName_default = New York organizationName = thirdpartyca, LLC #organizationName_default = Example, LLC # Use a friendly name here because its presented to the user. The server's DNS # names are placed in Subject Alternate Names. Plus, DNS names here is deprecated # by both IETF and CA/Browser Forums. If you place a DNS name here, then you # must include the DNS name in the SAN too (otherwise, Chrome and others that # strictly follow the CA/Browser Baseline Requirements will fail). commonName = thirdpartyca #commonName_default = Example Company emailAddress = ca@thirdpartyca.com # Section x509_ext is used when generating a self-signed certificate. I.e., openssl req -x509 ... [ x509_ext ] subjectKeyIdentifier = hash authorityKeyIdentifier = keyid,issuer # You only need digitalSignature below. *If* you don't allow # RSA Key transport (i.e., you use ephemeral cipher suites), then # omit keyEncipherment because that's key transport. basicConstraints = CA:TRUE keyUsage = Certificate Sign, CRL Sign, digitalSignature, keyEncipherment subjectAltName = @alternate_names nsComment = "OpenSSL Generated Certificate" # RFC 5280, Section 4.2.1.12 makes EKU optional # CA/Browser Baseline Requirements, Appendix (B)(3)(G) makes me confused # In either case, you probably only need serverAuth. # extendedKeyUsage = serverAuth, clientAuth # Section req_ext is used when generating a certificate signing request. I.e., openssl req ... [ req_ext ] subjectKeyIdentifier = hash basicConstraints = CA:FALSE keyUsage = digitalSignature, keyEncipherment subjectAltName = @alternate_names nsComment = "OpenSSL Generated Certificate" # RFC 5280, Section 4.2.1.12 makes EKU optional # CA/Browser Baseline Requirements, Appendix (B)(3)(G) makes me confused # In either case, you probably only need serverAuth. # extendedKeyUsage = serverAuth, clientAuth [ alternate_names ] DNS.1 = localhost DNS.2 = thirdpartyca.com #DNS.3 = mail.example.com #DNS.4 = ftp.example.com # Add these if you need them. But usually you don't want them or # need them in production. You may need them for development. # DNS.5 = localhost # DNS.6 = localhost.localdomain # DNS.7 = 127.0.0.1
- 前述のCAキーを使用してユーザー証明書/キーを作成します:
openssl ecparam -name prime256v1 -genkey -out user.key openssl pkcs8 -topk8 -inform PEM -in user.key -outform pem -nocrypt -out user-key.pem openssl req -new -key user-key.pem -out user.csr openssl x509 -req -days 365 -sha256 -CA ca.pem -CAkey ca-key.pem -CAserial ca.srl -CAcreateserial -in user.csr -out user.crt -extensions x509_ext -extfile openssl.conf openssl x509 -in user.crt -out user.pem -outform PEM
openssl.conf
ファイルの例を次に示します:[ req ] default_bits = 2048 default_keyfile = tls-key.pem distinguished_name = subject req_extensions = req_ext x509_extensions = x509_ext string_mask = utf8only # The Subject DN can be formed using X501 or RFC 4514 (see RFC 4519 for a description). # Its sort of a mashup. For example, RFC 4514 does not provide emailAddress. [ subject ] countryName = CN #countryName_default = US stateOrProvinceName = Beijing #stateOrProvinceName_default = NY localityName = Beijing #localityName_default = New York organizationName = thirdpartyca, LLC #organizationName_default = Example, LLC # Use a friendly name here because its presented to the user. The server's DNS # names are placed in Subject Alternate Names. Plus, DNS names here is deprecated # by both IETF and CA/Browser Forums. If you place a DNS name here, then you # must include the DNS name in the SAN too (otherwise, Chrome and others that # strictly follow the CA/Browser Baseline Requirements will fail). commonName = admin@thirdpartyca.com #commonName_default = Example Company emailAddress = admin@thirdpartyca.com #emailAddress_default = test@example.com # Section x509_ext is used when generating a self-signed certificate. I.e., openssl req -x509 ... [ x509_ext ] subjectKeyIdentifier = hash authorityKeyIdentifier = keyid,issuer # You only need digitalSignature below. *If* you don't allow # RSA Key transport (i.e., you use ephemeral cipher suites), then # omit keyEncipherment because that's key transport. basicConstraints = CA:FALSE keyUsage = digitalSignature, keyEncipherment subjectAltName = @alternate_names nsComment = "OpenSSL Generated Certificate" # RFC 5280, Section 4.2.1.12 makes EKU optional # CA/Browser Baseline Requirements, Appendix (B)(3)(G) makes me confused # In either case, you probably only need serverAuth. #extendedKeyUsage = Any Extended Key Usage #extendedKeyUsage = serverAuth, clientAuth # Section req_ext is used when generating a certificate signing request. I.e., openssl req ... [ x509_ca_ext ] subjectKeyIdentifier = hash authorityKeyIdentifier = keyid,issuer # You only need digitalSignature below. *If* you don't allow # RSA Key transport (i.e., you use ephemeral cipher suites), then # omit keyEncipherment because that's key transport. basicConstraints = CA:TRUE keyUsage = Certificate Sign, CRL Sign, digitalSignature, keyEncipherment subjectAltName = @alternate_names nsComment = "OpenSSL Generated Certificate" # RFC 5280, Section 4.2.1.12 makes EKU optional # CA/Browser Baseline Requirements, Appendix (B)(3)(G) makes me confused # In either case, you probably only need serverAuth. #extendedKeyUsage = Any Extended Key Usage extendedKeyUsage = serverAuth, clientAuth # Section req_ext is used when generating a certificate signing request. I.e., openssl req ... [ req_ext ] subjectKeyIdentifier = hash basicConstraints = CA:FALSE keyUsage = digitalSignature, keyEncipherment subjectAltName = @alternate_names nsComment = "OpenSSL Generated Certificate" # RFC 5280, Section 4.2.1.12 makes EKU optional # CA/Browser Baseline Requirements, Appendix (B)(3)(G) makes me confused # In either case, you probably only need serverAuth. #extendedKeyUsage = Any Extended Key Usage #extendedKeyUsage = serverAuth, clientAuth [ alternate_names ] DNS.1 = localhost DNS.3 = 127.0.0.1 DNS.4 = 0.0.0.0 # Add these if you need them. But usually you don't want them or # need them in production. You may need them for development. # DNS.5 = localhost # DNS.6 = localhost.localdomain # DNS.7 = 127.0.0.1 # IPv6 localhost # DNS.8 = ::1
- Hyperledger Fabricキー・マテリアルを作成するには、次のcryptogenコマンドを使用します:
cryptogen generate --config=./crypto-config.yaml
crypto-config.yaml
ファイルの例を次に示します:# Copyright IBM Corp. All Rights Reserved. # # SPDX-License-Identifier: Apache-2.0 # # --------------------------------------------------------------------------- # "PeerOrgs" - Definition of organizations managing peer nodes # --------------------------------------------------------------------------- PeerOrgs: # --------------------------------------------------------------------------- # Org1 # --------------------------------------------------------------------------- - Name: Org1 Domain: org1.example.com EnableNodeOUs: true # --------------------------------------------------------------------------- # "Specs" # --------------------------------------------------------------------------- # Uncomment this section to enable the explicit definition of hosts in your # configuration. Most users will want to use Template, below # # Specs is an array of Spec entries. Each Spec entry consists of two fields: # - Hostname: (Required) The desired hostname, sans the domain. # - CommonName: (Optional) Specifies the template or explicit override for # the CN. By default, this is the template: # # "{{.Hostname}}.{{.Domain}}" # # which obtains its values from the Spec.Hostname and # Org.Domain, respectively. # --------------------------------------------------------------------------- # Specs: # - Hostname: foo # implicitly "foo.org1.example.com" # CommonName: foo27.org5.example.com # overrides Hostname-based FQDN set above # - Hostname: bar # - Hostname: baz # --------------------------------------------------------------------------- # "Template" # --------------------------------------------------------------------------- # Allows for the definition of 1 or more hosts that are created sequentially # from a template. By default, this looks like "peer%d" from 0 to Count-1. # You may override the number of nodes (Count), the starting index (Start) # or the template used to construct the name (Hostname). # # Note: Template and Specs are not mutually exclusive. You may define both # sections and the aggregate nodes will be created for you. Take care with # name collisions # --------------------------------------------------------------------------- Template: Count: 2 # Start: 5 # Hostname: {{.Prefix}}{{.Index}} # default # --------------------------------------------------------------------------- # "Users" # --------------------------------------------------------------------------- # Count: The number of user accounts _in addition_ to Admin # --------------------------------------------------------------------------- Users: Count: 1 # --------------------------------------------------------------------------- # Org2: See "Org1" for full specification # --------------------------------------------------------------------------- - Name: Org2 Domain: org2.example.com EnableNodeOUs: true Template: Count: 2 Users: Count: 1
次の手順
適切なファイルの出力および更新を確認したら、Oracle Blockchain Platformネットワークにインポートするための証明書ファイルを作成できます。「組織の第三者証明書ファイルの作成」を参照してください。
組織の第三者証明書ファイルの作成
Oracle Blockchain Platformネットワークに参加するには、組織はadmincertおよびcacert情報が含まれている証明書ファイルを作成する必要があります。ネットワーク・デザイナは、このファイルをインポートして組織をネットワークに追加します。
CAサーバーから生成した証明書ファイルに移動して、証明書ファイルの作成に必要な情報を確認します。「サード・パーティ証明書の要件」を参照してください。
証明書ファイルは、JSONで記述し、次のフィールドを含める必要があります:
- mspid — Specifies the name of the organization.
- type - 組織がネットワーク参加者であることを示します。この値は、Participantである必要があります。
- admincert - 組織の管理者証明書ファイルの内容が含まれます。JSONファイルに証明書情報をコピーする際、各改行文字を\nで置き換える必要があります。
- cacert - 組織のCA証明書ファイルの内容が含まれます。JSONファイルに証明書情報をコピーする際、各改行文字を\nで置き換える必要があります。
{
"mspID": "examplemspID",
"type": "Participant",
"certs": {
"admincert": "-----BEGIN CERTIFICATE-----\nexample_certificate\nexample_certificate==\n-----END CERTIFICATE-----\n",
"cacert": "-----BEGIN CERTIFICATE-----\nexample_certificate\nexample_certificate==\n-----END CERTIFICATE-----\n"
}
}
Oracle Blockchain Platformネットワークを使用するための第三者環境の準備
第三者組織がOracle Blockchain Platformネットワークを使用するには、第三者組織の環境を設定する必要があります。
次の前提条件タスクが完了していることを確認します。詳細は、「サードパーティ証明書を使用する組織をOracle Blockchain Platformネットワークに参加させるための一般的なワークフロー」を参照してください。
- 第三者組織の証明書ファイルが作成され、Oracle Blockchain Platformネットワーク創設者に送信されました。
- ネットワーク・創設者は証明書ファイルをアップロードして第三者組織をネットワークに追加しました。
- ネットワーク・創設者は、オーダラ・サービスの設定をエクスポートし、サービスのアドレスおよびポートを第三者組織に渡し、組織が環境に追加しました。
- ネットワーク・創設者は新しいチャネルを作成し、サードパーティ組織をそこに追加しました。
- ネットワーク・創設者はチェーンコードをインストールしてインスタンス化しました。
組織の環境の設定
サード・パーティ組織がOracle Blockchain Platformネットワークを正常に使用するには、サードパーティ組織がHyperledger Fabric CLIまたはSDKを使用するように環境を設定する必要があります。Hyperledger Fabricのドキュメントを参照してください。
チェーンコードのインストール
サードパーティ組織は、チェーンコードをピアにインストールする必要があります。これらのピアはその後、チェーンコードを起動できるようにチャネルに参加する必要があります。
チェーンコードのデプロイ
必要に応じて、第三者組織はチェーンコードをデプロイできます。たとえば次のようにします。
export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_TLS_ROOTCERT_FILE=$PWD/tls-ca.pem
export CORE_PEER_MSPCONFIGPATH=$PWD/crypto-config/peerOrganizations/customerorg1.com/users/Admin@customerorg1.com/msp
export CORE_PEER_LOCALMSPID="customerorg1"
### gets channel name from input###
CHANNEL_NAME=$1
echo "######### going to instantiate chaincode on channel ${CHANNEL_NAME} ##########"
CORE_PEER_ADDRESS=${peer_host}:${port} peer chaincode instantiate
-o ${peer_host}:${port} --tls $CORE_PEER_TLS_ENABLED --cafile
./tls-ca.pem -C ${CHANNEL_NAME} -n obcs-example02 -v v0 -c '{"Args":["init","a","100","b","200"]}'
チェーンコードの呼出し
サードパーティ組織は、Hyperledger Fabric CLIまたはSDKを使用してチェーンコードを起動します。たとえば次のようにします。
export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_TLS_ROOTCERT_FILE=$PWD/tls-ca.pem
export CORE_PEER_MSPCONFIGPATH=$PWD/crypto-config/peerOrganizations/customerorg1.com/users/User1@customerorg1.com/msp
export CORE_PEER_LOCALMSPID="customerorg1"
### gets channel name from input ###
CHANNEL_NAME=$1
#### do query or invoke on chaincode ####
CORE_PEER_ADDRESS=${peer_host}:${port} peer chaincode query -C
${CHANNEL_NAME} -n $2 -c '{"Args":["query","a"]}'
CORE_PEER_ADDRESS=${peer_host}:${port} peer chaincode invoke -o
${peer_host}:${port} --tls $CORE_PEER_TLS_ENABLED --cafile ./tls-
ca.pem -C ${CHANNEL_NAME} -n $2 -c '{"Args":["invoke","a","b","10"]}'