fabric-sdk-node icon indicating copy to clipboard operation
fabric-sdk-node copied to clipboard

Use the existing public and private keys when reenrolling a user

Open ih8d8 opened this issue 4 years ago • 1 comments

If I want to reenroll a user using fabric-ca-client CLI, it has this flag [--csr.keyrequest.reusekey] that makes the reenrolling process use the existing key pair of the user. However, the fabric-sdk-node doesn't seem to provide a similar option. The below snippet is taken from the reenroll function of FabricCAServices class:

// generate enrollment certificate pair for signing
let privateKey;
try {
	privateKey = await this.getCryptoSuite().generateKey();
} catch (e) {
	throw Error(`Failed to generate key for enrollment due to error [${e}]: ${e.stack}`);
}

// generate CSR using the subject of the current user's certificate
let csr;
try {
	csr = privateKey.generateCSR('CN=' + subject);
} catch (e) {
	throw Error(`Failed to generate CSR for enrollment due to error [${e}]`);
}

const response = await this._fabricCAClient.reenroll(csr, currentUser.getSigningIdentity(), attrReqs);

It generates a new pub/priv key for user when reenrolling. I suggest that the reenroll function accepts another parameter for specifying if the existing key pair need to be used or not.

ih8d8 avatar Oct 11 '21 08:10 ih8d8

@bestbeforetoday I'd like to take this issue up if it's not being currently worked on by someone else.

hs2361 avatar Jan 25 '22 17:01 hs2361