您可以使用治理作業,從 Azure 受控 CCF (受控 CCF) 資源新增及移除成員。 本教學課程以 快速入門:使用 Azure 入口網站建立 Azure 受控 CCF 資源 中的受控 CCF 資源為基礎。
先決條件
- Python 3+。
- 最新版的 CCF Python 套件。
下載服務識別
Azure 受控 CCF 資源具有稱為服務識別的唯一身分識別,由憑證表示,並在資源建立期間建立。 屬於 Azure 受控 CCF 資源的每個個別節點都有其自我簽署憑證,並由服務身分識別背書,以對其建立信任。
建議客戶下載服務身分識別憑證,並在與服務互動時使用它來建立 TLS 連線。 下列命令會下載憑證,並將它儲存至 service_cert.pem。
curl https://identity.confidential-ledger.core.azure.com/ledgerIdentity/confidentialbillingapp --silent | jq ' .ledgerTlsCertificate' | xargs echo -e > service_cert.pem
備註
在 Mac 執行命令時,請將 取代 date -Is
為 date +%FT%T%z
。
新增成員
為成員生成一組金鑰對。 在下列命令完成之後,成員的公開金鑰會儲存在 member0_cert.pem
中,而私密金鑰則儲存在 member0_privk.pem
中。
openssl ecparam -out "member0_privk.pem" -name "secp384r1" -genkey
openssl req -new -key "member0_privk.pem" -x509 -nodes -days 365 -out "member0_cert.pem" -"sha384" -subj=/CN="member0"
- 提交提案以新增成員。
$cat set_member.json { "actions": [ { "name": "set_member", "args": { "cert": "-----BEGIN CERTIFICATE-----\nMIIBtDCCATqgAwIBAgIUV...sy93h74oqHk=\n-----END CERTIFICATE-----", "encryption_pub_key": "" } } ] } $ proposal_id=$( (ccf_cose_sign1 --content set_member.json --signing-cert member0_cert.pem --signing-key member0_privk.pem --ccf-gov-msg-type proposal --ccf-gov-msg-created_at `date -Is` | curl https://confidentialbillingapp.confidential-ledger.azure.com/gov/proposals -H 'Content-Type: application/cose' --data-binary @- --cacert service_cert.pem) )
- 提交投票以接受提案。 針對資源中的所有成員重複此步驟。
cat vote_accept.json { "ballot": "export function vote (proposal, proposerId) { return true }" } ccf_cose_sign1 --content vote_accept.json --signing-cert member0_cert.pem --signing-key member0_privk.pem --ccf-gov-msg-type ballot --ccf-gov-msg-created_at `date -Is` --ccf-gov-msg-proposal_id $proposal_id | curl https://confidentialbillingapp.confidential-ledger.azure.com/gov/proposals/$proposal_id/ballots -H 'Content-Type: application/cose' --data-binary @- --cacert service_cert.pem
- 當命令完成時,成員會新增至Managed CCF資源中。 但是,除非它們已啟用,否則它們無法參與治理作業。 請參閱快速入門教學課程 啟動成員 以啟動成員。
- 使用下列命令檢視網路中的成員。
curl --cacert service_cert.pem https://confidentialbillingapp.confidential-ledger.azure.com/gov/members | jq
{
"710c4d7ce6a70a89137b39170cd5c48f94b4756a66e66b2242370111c1c47564": {
"cert": "-----BEGIN CERTIFICATE-----\nMIIB9zCCAX2gAwIBAgIQW20I1iR...l8Uv8rRce\n-----END CERTIFICATE-----",
"member_data": {
"is_operator": true,
"owner": "Microsoft Azure"
},
"public_encryption_key": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMI...n3QIDAQAB\n-----END PUBLIC KEY-----\n",
"status": "Active"
},
"f9ea379051e5292b538ff2a3dc97f1bb4d5046f12e2bdbf5b8e3acc4516f34e3": {
"cert": "-----BEGIN CERTIFICATE-----\nMIIBuzCCAUKgAwIBAgIURuSESLma...yyK1EHhxx\n-----END CERTIFICATE-----",
"member_data": {
"group": "",
"identifier": "member0"
},
"public_encryption_key": null,
"status": "Active"
}
}
移除成員
- 提交提案以移除成員。 成員會透過其公開憑證來識別。
$cat remove_member.json { "actions": [ { "name": "remove_member", "args": { "cert": "-----BEGIN CERTIFICATE-----\nMIIBtDCCATqgAwIBAgIUV...sy93h74oqHk=\n-----END CERTIFICATE-----", } } ] } $ proposal_id=$( (ccf_cose_sign1 --content remove_member.json --signing-cert member0_cert.pem --signing-key member0_privk.pem --ccf-gov-msg-type proposal --ccf-gov-msg-created_at `date -Is` | curl https://confidentialbillingapp.confidential-ledger.azure.com/gov/proposals -H 'Content-Type: application/cose' --data-binary @- --cacert service_cert.pem) )
- 提交投票以接受提案。 針對資源中的所有成員重複此步驟。
cat vote_accept.json { "ballot": "export function vote (proposal, proposerId) { return true }" } ccf_cose_sign1 --content vote_accept.json --signing-cert member0_cert.pem --signing-key member0_privk.pem --ccf-gov-msg-type ballot --ccf-gov-msg-created_at `date -Is` --ccf-gov-msg-proposal_id $proposal_id | curl https://confidentialbillingapp.confidential-ledger.azure.com/gov/proposals/$proposal_id/ballots -H 'Content-Type: application/cose' --data-binary @- --cacert service_cert.pem
- 當命令完成時,成員會從受控 CCF 資源中移除,且無法再參與治理作業。
- 使用下列命令檢視網路中的成員。
curl --cacert service_cert.pem https://confidentialbillingapp.confidential-ledger.azure.com/gov/members | jq
{
"710c4d7ce6a70a89137b39170cd5c48f94b4756a66e66b2242370111c1c47564": {
"cert": "-----BEGIN CERTIFICATE-----\nMIIB9zCCAX2gAwIBAgIQW20I1iR...l8Uv8rRce\n-----END CERTIFICATE-----",
"member_data": {
"is_operator": true,
"owner": "Microsoft Azure"
},
"public_encryption_key": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMI...n3QIDAQAB\n-----END PUBLIC KEY-----\n",
"status": "Active"
},
"f9ea379051e5292b538ff2a3dc97f1bb4d5046f12e2bdbf5b8e3acc4516f34e3": {
"cert": "-----BEGIN CERTIFICATE-----\nMIIBuzCCAUKgAwIBAgIURuSESLma...yyK1EHhxx\n-----END CERTIFICATE-----",
"member_data": {
"group": "",
"identifier": "member0"
},
"public_encryption_key": null,
"status": "Active"
}
}