How to use the fabric-ca-client.newCryptoKeyStore 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-sdk-node / test / unit / fabric-ca-client.js View on Github external
const tlsOptions = {
		trustedRoots: [],
		verify: false
	};
	const CAClient = require('fabric-ca-client');

	let crypto = CAClient.newCryptoSuite({ software: true, keysize: 384 });
	const keyValStorePath = path.join(testutil.getTempDir(), 'kvsTemp');

	if (!crypto._cryptoKeyStore) {
		t.pass('cryptoKeyStore is not set on a new cryptoSuite');
	} else {
		t.fail('cryptoKeyStore should not be set on a new cryptoSuite');
	}

	const cks = CAClient.newCryptoKeyStore({ path: keyValStorePath });
	crypto.setCryptoKeyStore(cks);

	const client = new CAClient('http://localhost:7054', tlsOptions, 'peerOrg1', crypto);
	client.setCryptoSuite(crypto);

	crypto = client.getCryptoSuite();

	if (crypto && crypto._cryptoKeyStore) {
		t.pass('Successfully called getCryptoSuite() with cryptoKeyStore set');
	}
	else {
		if (!crypto) {
			t.fail('getCryptoSuite() did not return an object');
		} else {
			t.fail('getCryptoSuite() should contain a cryptoKeyStore');
		}