Python Fabric SDK,CA注册用户

时间:2019-01-07 18:53:23

标签: hyperledger-fabric hyperledger

我想将register方法添加到Fabric CA(此处为swagger定义)中,类似于enroll函数here

CA文档指出:

Authorization:
An enrollment token consisting of two base 64 encoded parts separated by a period:

- an enrollment certificate;
- a signature over the certificate and body of request.

在查看NodeJS对应的hereauth header代时,我得到了以下python代码:

 def register(self, enrollment_id, enrollment_secret, enrollment, crypto):

        req = {
            "caname": self._ca_name,
            "id": enrollment_id,
            "secret": enrollment_secret
        }

        signature = base64.encode(crypto.sign(enrollment.private_key, str(enrollment.cert) +'.'+ json.dumps(req, ensure_ascii=False)))

        response = self._send_ca_post(path="register", json=req,
                headers={'Authorization' : base64.encode(str(enrollment.cert) + '.' + str(signature))},
                verify=self._ca_certs_path)

我在此TypeError: data must be bytes.行中收到了signature = base64.encode(crypto.sign(enrollment.private_key, str(enrollment.cert) +'.'+ json.dumps(req, ensure_ascii=False)))

有人可以帮忙吗?

0 个答案:

没有答案
相关问题