使用Python SDK进行开发时调用函数出现问题
在ChainMaker网页端构建了一个4节点(2组织)的区块链随后在本地进行部署;
节点名->IP地址->RPC端口->P2P端口
V1 192.168.3.80 10000 - 11000
V2 192.168.3.80 10001 - 11001
E2 192.168.3.80 10002 - 11002
E1 192.168.3.80 10003 - 11003
随后,我在本地编写Python程序query.py进行开发,在构建ChainClient对象时出现问题,代码如下(代码中的证书地址都是正确的):
def create_chainclient():
# 创建用户,以Edge端为例子
user = User('Edge',
sign_key_bytes=file_utils.read_file_bytes('/home/blockchain-node/release/Edge-E1/config/Edge/certs/user/EdgeAdmin/EdgeAdmin.sign.key'),
sign_cert_bytes=file_utils.read_file_bytes('/home/blockchain-node/release/Edge-E1/config/Edge/certs/user/EdgeAdmin/EdgeAdmin.sign.crt'),
tls_key_bytes=file_utils.read_file_bytes('/home/blockchain-node/release/Edge-E1/config/Edge/certs/user/EdgeAdmin/EdgeAdmin.tls.key'),
tls_cert_bytes=file_utils.read_file_bytes('/home/blockchain-node/release/Edge-E1/config/Edge/certs/user/EdgeAdmin/EdgeAdmin.tls.crt')
)
# 创建节点,以Edge-E1为例子
node = Node(
node_addr='192.168.3.80:10003',
conn_cnt=1,
enable_tls=True,
trust_cas=[
file_utils.read_file_bytes('/home/blockchain-node/release/Edge-E1/config/Edge/certs/ca/Edge/ca.crt'),
file_utils.read_file_bytes('/home/blockchain-node/release/Edge-E1/config/Edge/certs/ca/Vehicle/ca.crt')
],
tls_host_name='VNCManager'
)
cc = ChainClient(chain_id='VNCManager',user=user,nodes=[node])
print(cc.get_chainmaker_server_version())
return cc
if __name__=='__main__':
create_chainclient()
在本地运行python3 query.py
后报错:
blockchain-node@blockchain-node:~$ python3 query.py
E0506 10:43:23.817198835 75750 ssl_transport_security.cc:1501] Handshake failed with fatal error SSL_ERROR_SSL: error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED.
Traceback (most recent call last):
File "/home/blockchain-node/query.py", line 72, in <module>
create_chainclient()
File "/home/blockchain-node/query.py", line 41, in create_chainclient
print(cc.get_chainmaker_server_version())
File "/home/blockchain-node/.local/lib/python3.10/site-packages/chainmaker/chain_client.py", line 364, in get_chainmaker_server_version
res = client.GetChainMakerVersion(req)
File "/home/blockchain-node/.local/lib/python3.10/site-packages/grpc/_channel.py", line 946, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "/home/blockchain-node/.local/lib/python3.10/site-packages/grpc/_channel.py", line 849, in _end_unary_response_blocking
raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "failed to connect to all addresses; last error: UNKNOWN: ipv4:192.168.3.80:10003: Ssl handshake failed: SSL_ERROR_SSL: error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED"
debug_error_string = "UNKNOWN:failed to connect to all addresses; last error: UNKNOWN: ipv4:192.168.3.80:10003: Ssl handshake failed: SSL_ERROR_SSL: error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED {created_time:"2023-05-06T10:43:23.81736585+08:00", grpc_status:14}"
经过测试,在cc = ChainClient(chain_id='VNCManager',user=user,nodes=[node])
这一部没有报错,说明ChainClient对象成功建立了,但是在cc.get_chainmaker_server_version()
中出现错误,如上报错;请问问题出在哪里,非常感谢解答!
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information