fabric-ca
簡要說明
- fabric-ca server端默認端口7054,支持REST、命令行兩種方式進行交互,在fabric-ca中的三種證書類型
- 登記證書(ECert):對實體身份進行檢驗
- 通信證書(TLSCert):保證通信鏈路安全,對遠端身份校驗
- 交易證書(TCert):頒發給用戶,控制每個交易的權限
- 啓動時需要先 init 再 start 進行啓動server端服務
- init 操作 :fabric-ca-server init -b admin:password (-b 參數是不適用LDAP)
- init 操作 :fabric-ca-server start -b admin:password
fabric-ca-client 命令交互
fabric-ca-client命令可以與服務端進行交互, 包括五個子命令:
- enroll: 登錄獲取ECert
- getcacert: 獲取CA服務的證書鏈
- reenroll: 再次登錄
- register: 註冊用戶實體
- revoke: 吊銷簽發的實體證書
數字證書
關於數字證書:
- X509官方包目前只支持p256、224、384、521四種p系列橢圓算法,對於國密和s256比特幣等橢圓算法不支持
- x509.CreateCertificate是本地進行創建證書,並不與ca進行交互
- x509.CreateCertificateRequest是創建證書請求文件CSR給ca,讓ca進行證書的頒發,兩者都需要生成私鑰
證書吊銷列表CRL並不是一成不變的,會自動更新的
CRL並不會主動、被動更新到fabric 組織裏面去, 需要對 channel 進行手動 update
更新通道後,CRL 纔會在 fabric 中生效
註冊中間CA.
爲了爲中間CA創建CA簽名證書,中間CA必須以與Fabric-ca-client註冊CA相同的方式向父CA註冊。這是通過使用-u選項指定父CA的URL以及註冊ID和密碼來完成的。與此註冊ID關聯的標識必須具有名稱爲“hf.IntermediateCA”且值爲“true”的屬性。已頒發證書的CN(或通用名稱)將設置爲註冊ID。如果中間CA嘗試顯式指定CN值,則會發生錯誤。
通過命令
fabric-ca-server start -b admin:password -p 7064 -u http://admin:pass@localhost:7054
可進行多級ca配置進行頒發證書給用戶,當設置多級ca成功後會生成ca-chain.pem文件
關於ca-chain.pem 會把根CA和中間CA證書寫入進去,根證書在最下面。
使用工具openssl verify -CAfile 命令可驗證 兩個證書的證書鏈關係
配置LDAP
Fabric CA服務器可以配置爲從LDAP服務器讀取。
特別是,Fabric CA服務器可以連接到LDAP服務器以執行以下操作:
- 在註冊之前驗證身份
- 檢索用於授權的標識屬性值。
修改Fabric CA服務器配置文件的LDAP部分,以將服務器配置爲連接到LDAP服務器。
ldap:
# Enables or disables the LDAP client (default: false)
enabled: false
# The URL of the LDAP server
url: <scheme>://<adminDN>:<adminPassword>@<host>:<port>/<base>
userfilter: <filter>
attribute:
# 'names' is an array of strings that identify the specific attributes
# which are requested from the LDAP server.
names: <LDAPAttrs>
# The 'converters' section is used to convert LDAP attribute values
# to fabric CA attribute values.
#
# For example, the following converts an LDAP 'uid' attribute
# whose value begins with 'revoker' to a fabric CA attribute
# named "hf.Revoker" with a value of "true" (because the expression
# evaluates to true).
# converters:
# - name: hf.Revoker
# value: attr("uid") =~ "revoker*"
#
# As another example, assume a user has an LDAP attribute named
# 'member' which has multiple values of "dn1", "dn2", and "dn3".
# Further assume the following configuration.
# converters:
# - name: myAttr
# value: map(attr("member"),"groups")
# maps:
# groups:
# - name: dn1
# value: orderer
# - name: dn2
# value: peer
# The value of the user's 'myAttr' attribute is then computed to be
# "orderer,peer,dn3". This is because the value of 'attr("member")' is
# "dn1,dn2,dn3", and the call to 'map' with a 2nd argument of
# "group" replaces "dn1" with "orderer" and "dn2" with "peer".
converters:
- name: <fcaAttrName>
value: <fcaExpr>
maps:
<mapName>:
- name: <from>
value: <to>
scheme
是ldap或ldaps之一 ;adminDN
是admin用戶的區別名稱;pass
是admin用戶的密碼;host
是LDAP服務器的主機名或IP地址;port
是可選的端口號,其中,默認389爲LDAP 和636爲LDAPS ;base
是用於搜索的LDAP樹的可選根;filter
是搜索將登錄用戶名轉換爲可分辨名稱時使用的過濾器。例如,(uid=%s)
搜索LDAP條目的值,uid
其值爲屬性,其值爲登錄用戶名。同樣,(email=%s)
可用於使用電子郵件地址登錄。LDAPAttrs
是一個LDAP屬性名稱數組,代表用戶從LDAP服務器請求;
設置多個CA.
fabric-ca服務器默認包含一個默認CA. 但是,可以使用cafiles或cacount配置選項將其他CA添加到單個服務器。每個額外的CA都有自己的主目錄。
cacount:
該cacount提供了一種快速啓動的默認額外的CA X號。主目錄將相對於服務器目錄。使用此選項,目錄結構如下:
- < 服務器 主頁>
| - ca
| - ca1
| - ca2
每個額外的CA都將獲得在其主目錄中生成的默認配置文件,在配置文件中它將包含唯一的CA名稱。
例如,以下命令將啓動2個默認CA實例:
fabric - ca - 服務器 啓動 - b admin :adminpw - cacount 2