How to use the fabric-ca-client/lib/FabricCAServices.js function in fabric-ca-client

To help you get started, we’ve selected a few fabric-ca-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hyperledger / fabric-test / tools / PTE / pte-util.js View on Github external
}

                var member = new User(username);
                var cryptoSuite = client.getCryptoSuite();
                if (!cryptoSuite) {
                    cryptoSuite = hfc.newCryptoSuite();
                    if (userOrg) {
                        cryptoSuite.setCryptoKeyStore(Client.newCryptoKeyStore({ path: module.exports.storePathForOrg(nid, cpOrgs[userOrg].name) }));
                        client.setCryptoSuite(cryptoSuite);
                    }
                }
                member.setCryptoSuite(cryptoSuite);

                // need to enroll it with CA server
                var orgCA = cpOrgs[userOrg].certificateAuthorities[0];
                var cop = new copService(caUrl, tlsOptions, cpCAs[orgCA].caName, cryptoSuite);

                return cop.enroll({
                    enrollmentID: username,
                    enrollmentSecret: password
                }).then((enrollment) => {
                    logger.info('[getMember] Successfully enrolled user \'' + username + '\'');

                    return member.setEnrollment(enrollment.key, enrollment.certificate, cpOrgs[userOrg].mspid);
                }).then(() => {
                    var skipPersistence = false;
                    if (!client.getStateStore()) {
                        skipPersistence = true;
                    }
                    return client.setUserContext(member, skipPersistence);
                }).then(() => {
                    return resolve(member);
github hyperledger / fabric-sdk-node / test / integration / util.js View on Github external
return resolve(user);
				}

				const member = new User(username);
				let cryptoSuite = client.getCryptoSuite();
				if (!cryptoSuite) {
					cryptoSuite = Client.newCryptoSuite();
					if (userOrg) {
						cryptoSuite.setCryptoKeyStore(Client.newCryptoKeyStore({path: module.exports.storePathForOrg(ORGS[userOrg].name)}));
						client.setCryptoSuite(cryptoSuite);
					}
				}
				member.setCryptoSuite(cryptoSuite);

				// need to enroll it with CA server
				const cop = new copService(caUrl, tlsOptions, ORGS[userOrg].ca.name, cryptoSuite);

				return cop.enroll({
					enrollmentID: username,
					enrollmentSecret: password
				}).then((enrollment) => {
					t.pass('Successfully enrolled user \'' + username + '\'');
					return member.setEnrollment(enrollment.key, enrollment.certificate, ORGS[userOrg].mspid);
				}).then(() => {
					let skipPersistence = false;
					if (!client.getStateStore()) {
						skipPersistence = true;
					}
					return client.setUserContext(member, skipPersistence);
				}).then(() => {
					return resolve(member);
				}).catch((err) => {