Skip to content

Commit

Permalink
[FABN-1280] Support gencrl in revoke
Browse files Browse the repository at this point in the history
Support gencrl in revoke

Change-Id: I76d12fe2600c8fe1819fa99b0c1ab9c0fb3463a0
Signed-off-by: GuillaumeCisco <[email protected]>
  • Loading branch information
GuillaumeCisco authored and harrisob committed Oct 3, 2019
1 parent d9c7e0d commit 73405ac
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions fabric-ca-client/lib/FabricCAClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,12 @@ const FabricCAClient = class {
* @param {string} serial Serial number string, hex encoded, for the specific certificate to revoke
* @param {string} reason The reason for revocation. See https://godoc.org/golang.org/x/crypto/ocsp
* for valid values
* @param {bool} gencrl GenCRL specifies whether to generate a CRL
* @param {SigningIdentity} signingIdentity The instance of a SigningIdentity encapsulating the
* signing certificate, hash algorithm and signature algorithm
* @returns {Promise} The revocation results
*/
revoke(enrollmentID, aki, serial, reason, signingIdentity) {
revoke(enrollmentID, aki, serial, reason, gencrl, signingIdentity) {

const self = this;

Expand All @@ -164,7 +165,8 @@ const FabricCAClient = class {
'id': enrollmentID,
'aki': aki,
'serial': serial,
'reason': reason
'reason': reason,
'gencrl': gencrl,
};

return self.post('revoke', regRequest, signingIdentity)
Expand Down
2 changes: 2 additions & 0 deletions fabric-ca-client/lib/FabricCAServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ const FabricCAServices = class extends BaseClient {
* <br> - aki {string}. Authority Key Identifier string, hex encoded, for the specific certificate to revoke
* <br> - serial {string}. Serial number string, hex encoded, for the specific certificate to revoke
* <br> - reason {string}. The reason for revocation. See https://godoc.org/golang.org/x/crypto/ocsp
* <br> - gencrl {bool}. GenCRL specifies whether to generate a CRL
* for valid values. The default value is 0 (ocsp.Unspecified).
* @param {User} registrar The identity of the registrar (i.e. who is performing the revocation)
* @returns {Promise} The revocation results
Expand All @@ -356,6 +357,7 @@ const FabricCAServices = class extends BaseClient {
request.aki,
request.serial,
(request.reason) ? request.reason : null,
(request.gencrl) ? request.gencrl : false,
registrar.getSigningIdentity());
}

Expand Down
5 changes: 3 additions & 2 deletions fabric-ca-client/test/FabricCAClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ describe('FabricCAClient', () => {
revert = FabricCAClientRewire.__set__('FabricCAClient.prototype.post', postStub);

const client = new FabricCAClientRewire(connect_opts, cryptoPrimitives);
client.revoke('enrollmentID', 'aki', 'serial', 'reason', 'signingIdentity');
client.revoke('enrollmentID', 'aki', 'serial', 'reason', false, 'signingIdentity');

// should call post
sinon.assert.calledOnce(postStub);
Expand All @@ -349,7 +349,8 @@ describe('FabricCAClient', () => {
id: 'enrollmentID',
aki: 'aki',
serial: 'serial',
reason: 'reason'
reason: 'reason',
gencrl: false
});
callArgs[2].should.equal('signingIdentity');
});
Expand Down
5 changes: 3 additions & 2 deletions fabric-ca-client/test/FabricCAServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,8 @@ describe('FabricCAServices', () => {
callArgs.args[1].should.equal('aki');
callArgs.args[2].should.equal('serial');
callArgs.args[3].should.equal('de-friended');
callArgs.args[4].should.equal('myID');
callArgs.args[4].should.equal(false);
callArgs.args[5].should.equal('myID');
});

it('should call the revoke function on the FabricCAClient object with conditional reasoning', () => {
Expand All @@ -661,7 +662,7 @@ describe('FabricCAServices', () => {
callArgs.args[1].should.equal('aki');
callArgs.args[2].should.equal('serial');
should.not.exist(callArgs.args[3]);
callArgs.args[4].should.equal('myID');
callArgs.args[5].should.equal('myID');
});
});

Expand Down

0 comments on commit 73405ac

Please sign in to comment.