访问Fabric CA服务器REST Api(涉及授权的方法)

时间:2018-12-15 11:49:54

标签: hyperledger-fabric hyperledger hyperledger-fabric-ca

https://github.com/hyperledger/fabric-ca/blob/release-1.2/swagger/swagger-fabric-ca.json
使用以上链接作为参考,我成功使用cainfo方法(使用localhost:7054 / api / v1 / cainfo)。但是,使用需要身份验证标头的从属关系(get)等其他方法,我将失败(该方法说需要2个以句点分隔的base 64编码密钥)。我的问题是实际需要什么密钥(管理证书和私钥/签名?),我是否应该同时对它们进行编码(通过https://www.base64encode.org/进行编码)

注意:-这是预期的

  {
        "name": "Authorization",
        "in": "header",
        "description": "An HTTP basic authorization header where:  \n*  *user* is the enrollment ID;  \n*  *password* is the enrollment secret.",
        "required": true,
        "type": "string"
      },

2 个答案:

答案 0 :(得分:1)

您可以通过在终端中运行以下命令来获取授权标头:

      echo -n admin:adminpw | openssl base64

这会输出应该在CURL请求中使用的令牌(如果需要,也可以通过邮递员使用)。

答案 1 :(得分:0)

您需要在base64中单独创建名称和密码

echo -n admin | openssl base64

YWRtaW4 =

echo -n adminpw | openssl base64

YWRtaW5wdw ==

字段授权将为 YWRtaW4 = .YWRtaW5wdw ==

别忘了“。”在名称和密码之间!