Search code examples
hyperledger-fabrichyperledgerhyperledger-fabric-ca

Accessing Fabric CA server REST Api (Methods that involve Authorization)


https://github.com/hyperledger/fabric-ca/blob/release-1.2/swagger/swagger-fabric-ca.json
Using the above link as reference,I have success with the cainfo method (using localhost:7054/api/v1/cainfo). However with other methods like affiliations (get) that require an auth header I fail (the method says requires 2 base 64 encoded keys separated by a period ). My question is what keys are actually required (admin certificate and private key/sign ?) and whether I should actually encode them both (Encoding done via https://www.base64encode.org/)

Note:- This is what is expected

  {
        "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"
      },

Solution

  • You can obtain the authorization header by running the following in a terminal :

          echo -n admin:adminpw | openssl base64
    

    This outputs a token that should be used in a CURL request ( or through postman if required) .