From ea00937713ae192fcd62ad8d7b01761055dc6a8b Mon Sep 17 00:00:00 2001 From: Zhao Chaoyi Date: Tue, 22 May 2018 04:50:50 +0000 Subject: [PATCH] Revert "[FAB-10241]" Fabric ca removed the token changes at https://gerrit.hyperledger.org/r/#/c/22067/ This reverts commit 19d3dddcb5d21fd1c688998ac11a2f6da238fc9c. Change-Id: Idf08d0260910a8142d3b2cf03782d718acb5ed78 Signed-off-by: zhaochy --- fabric-ca-client/lib/FabricCAClientImpl.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/fabric-ca-client/lib/FabricCAClientImpl.js b/fabric-ca-client/lib/FabricCAClientImpl.js index b1c11b7c94..191e0715fc 100644 --- a/fabric-ca-client/lib/FabricCAClientImpl.js +++ b/fabric-ca-client/lib/FabricCAClientImpl.js @@ -709,7 +709,7 @@ var FabricCAClient = class { path: self._baseAPI + api_method, method: http_method, headers: { - Authorization: self.generateAuthToken(http_method, self._baseAPI + api_method, requestObj, signingIdentity) + Authorization: self.generateAuthToken(requestObj, signingIdentity) }, ca: self._tlsOptions.trustedRoots, rejectUnauthorized: self._tlsOptions.verify, @@ -777,17 +777,16 @@ var FabricCAClient = class { /* * Generate authorization token required for accessing fabric-ca APIs */ - generateAuthToken(method, uri, reqBody, signingIdentity) { + generateAuthToken(reqBody, signingIdentity) { // specific signing procedure is according to: - // https://github.com/hyperledger/fabric-ca/blob/master/util/util.go#L271 + // https://github.com/hyperledger/fabric-ca/blob/master/util/util.go#L213 let cert = Buffer.from(signingIdentity._certificate).toString('base64'); - let b64Uri = Buffer.from(uri).toString('base64'); - let bodyAndcert = method + '.' + b64Uri + '.'; + let bodyAndcert; if (reqBody) { let body = Buffer.from(JSON.stringify(reqBody)).toString('base64'); - bodyAndcert += body + '.' + cert; + bodyAndcert = body + '.' + cert; } else { - bodyAndcert += '.' + cert; + bodyAndcert = '.' + cert; } let sig = signingIdentity.sign(bodyAndcert, { hashFunction: this._cryptoPrimitives.hash.bind(this._cryptoPrimitives) });