Search code examples
hyperledger-fabrichyperledgerhyperledger-fabric-ca

fabric-ca request register failed | fabric-samples release-1.4 | balance-transfer network


I am trying to set up balance-transfer hyperledger fabric network. I have followed the steps in the README.md. While running ./runApp.sh, I got the following error.

Creating network "artifacts_default" with the default driver
Pulling ca.org1.example.com (hyperledger/fabric-ca:)...
ERROR: manifest for hyperledger/fabric-ca:latest not found: manifest unknown: manifest unknown

After googling the following steps, resolved the issue.

docker pull hyperledger/fabric-ca:x86_64-1.1.0-preview 
docker tag hyperledger/fabric-ca:x86_64-1.1.0-preview hyperledger/fabric-ca:latest
docker pull hyperledger/fabric-orderer:x86_64-1.1.0-preview 
docker tag hyperledger/fabric-orderer:x86_64-1.1.0-preview hyperledger/fabric-orderer:latest
docker pull hyperledger/fabric-peer:x86_64-1.1.0-preview
docker tag hyperledger/fabric-peer:x86_64-1.1.0-preview hyperledger/fabric-peer:latest

After this steps ./runApp.sh command is success. While running ./testAPIs.sh -l golang, I am getting the following error in REST Server.

[2020-08-25 09:08:41.463] [ERROR] Helper - Failed to get registered user: Barry with error: Error: fabric-ca request register failed with errors [[ { code: 20, message: 'Authorization failure' } ]]
[2020-08-25 09:08:41.463] [DEBUG] SampleWebApp - -- returned from registering the username Barry for organization Org2
[2020-08-25 09:08:41.463] [DEBUG] SampleWebApp - Failed to register the username Barry for organization Org2 with::failed Error: fabric-ca request register failed with errors [[ { code: 20, message: 'Authorization failure' } ]]
UnauthorizedError: jwt malformed
    at /var/www/html/fabric-samples/balance-transfer/node_modules/express-jwt/lib/index.js:102:22
    at Object.module.exports [as verify] (/var/www/html/fabric-samples/balance-transfer/node_modules/express-jwt/node_modules/jsonwebtoken/verify.js:63:12)
    at verifyToken (/var/www/html/fabric-samples/balance-transfer/node_modules/express-jwt/lib/index.js:100:13)
    at fn (/var/www/html/fabric-samples/balance-transfer/node_modules/async/lib/async.js:746:34)
    at /var/www/html/fabric-samples/balance-transfer/node_modules/async/lib/async.js:1213:16
    at /var/www/html/fabric-samples/balance-transfer/node_modules/async/lib/async.js:166:37
    at /var/www/html/fabric-samples/balance-transfer/node_modules/async/lib/async.js:706:43
    at /var/www/html/fabric-samples/balance-transfer/node_modules/async/lib/async.js:167:37
    at Immediate._onImmediate (/var/www/html/fabric-samples/balance-transfer/node_modules/async/lib/async.js:1206:34)
    at runCallback (timers.js:810:20)

I am getting the following error in fabric-ca.

2020/08/25 09:08:41 [INFO] 172.29.0.1:57476 POST /api/v1/enroll 200 0 "OK"
2020/08/25 09:08:41 [DEBUG] Received request for /api/v1/register
2020/08/25 09:08:41 [DEBUG] Received registration request from : { Name:Barry Type: Secret:**** MaxEnrollments:1 Affiliation:org2.department1 Attributes:[] CAName:ca-org2  }
2020/08/25 09:08:41 [DEBUG] Sent error for /api/v1/register: scode: 401, local code: 25, local msg: Invalid token in authorization header: Token signature validation failed, remote code: 20, remote msg: Authorization failure

github.com/hyperledger/fabric-ca/lib.newAuthErr
    /opt/gopath/src/github.com/hyperledger/fabric-ca/lib/servererror.go:145
github.com/hyperledger/fabric-ca/lib.(*serverRequestContext).TokenAuthentication
    /opt/gopath/src/github.com/hyperledger/fabric-ca/lib/serverrequestcontext.go:129
github.com/hyperledger/fabric-ca/lib.registerHandler
    /opt/gopath/src/github.com/hyperledger/fabric-ca/lib/serverregister.go:49
github.com/hyperledger/fabric-ca/lib.(*serverEndpoint).ServeHTTP
    /opt/gopath/src/github.com/hyperledger/fabric-ca/lib/serverendpoint.go:44
net/http.(*ServeMux).ServeHTTP
    /opt/go/src/net/http/server.go:2254
net/http.serverHandler.ServeHTTP
    /opt/go/src/net/http/server.go:2619
net/http.(*conn).serve
    /opt/go/src/net/http/server.go:1801
runtime.goexit
    /opt/go/src/runtime/asm_amd64.s:2337
2020/08/25 09:08:41 [INFO] 172.29.0.1:57480 POST /api/v1/register 401 25 "Invalid token in authorization header: Token signature validation failed"

Please help me to fix this issue.


Solution

  • Few issues with your question here:

    1. you are using a 3 years old hyperledger-fabric version. But in the question you have mentioned that you are using v1.4. check here your version info.
    2. You can use tag 1.4.8 for ca, peer,orderer instead of x86_64-1.1.0-preview.
    3. latest tag is misleading because now there are two hyperledger-fabric versions i.e fabric:v2.x and fabric:v1.4.x. hence better approach is to use specific tag instead of latest.