我想将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对应的here和auth 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)))
。
有人可以帮忙吗?