How to use the fabric-ca-client/lib/FabricCAServices.normalizeX509 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 / integration / fabric-ca-services-tests.js View on Github external
}).then((enrollment) => {

			let cert;
			try {
				cert = X509.parseCert(FabricCAServices.normalizeX509(enrollment.certificate));
			} catch (err) {
				t.fail(util.format('Failed to parse enrollment cert\n%s\n. Error: %s', enrollment.certificate, err));
			}

			if (!cert.extensions || !cert.extensions.authorityKeyIdentifier) {
				t.fail(util.format('Parsed certificate does not contain Authority Key Identifier needed for revoke(): %j', cert));
			}

			// convert the raw AKI string in the form of 'keyid:HX:HX....' (HX represents a hex-encoded byte) to a hex string
			const akiString = cert.extensions.authorityKeyIdentifier;
			const arr = akiString.split(':');
			if (arr[0] !== 'keyid') {
				t.fail(util.format('Found an Autheority Key Identifier we do not understand: first segment is not "keyid": %s', akiString));
			}

			arr.shift(); // remove the 'keyid'
github hyperledger / fabric-sdk-node / test / integration / fabric-ca-services-tests.js View on Github external
.then((enrollResponse) => {
			t.pass('Successfully invoked enroll API with enrollmentID \'' + enrollmentID + '\'');
			// check that we got back the expected certificate
			let subject;
			try {
				subject = X509.getSubject(FabricCAServices.normalizeX509(enrollResponse.enrollmentCert));
			} catch (err) {
				t.fail(util.format('Failed to parse enrollment cert\n%s\n. Error: %s', enrollResponse.enrollmentCert, err));
			}
			t.equal(subject.commonName, enrollmentID, 'Subject should be /CN=' + enrollmentID);
			t.end();
		})
		.catch((err) => {
github hyperledger / fabric-sdk-node / test / integration / fabric-ca-services-tests.js View on Github external
.then((enrollment) => {
			t.pass('Successfully enrolled \'' + req.enrollmentID + '\'.');
			eResult = enrollment;

			// check that we got back the expected certificate
			let subject;
			try {
				subject = X509.getSubject(FabricCAServices.normalizeX509(enrollment.certificate));
			} catch (err) {
				t.fail(util.format('Failed to parse enrollment cert\n%s\n. Error: %s', enrollment.certificate, err));
			}

			t.equal(subject.commonName, req.enrollmentID, 'Subject should be /CN=' + req.enrollmentID);

			return caService.getCryptoSuite().importKey(enrollment.certificate);
		}, (err) => {
			t.fail('Failed to enroll the admin. Can not progress any further. Exiting. ' + err.stack ? err.stack : err);