fabric-sdk-node
fabric-sdk-node copied to clipboard
Use the existing public and private keys when reenrolling a user
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.
@bestbeforetoday I'd like to take this issue up if it's not being currently worked on by someone else.