lib/information.js
function (cert, cb) {
    var infoObject = {},
        subjectElements = [],
        err;

  	var openssl = spawn('openssl', ['req', '-noout', '-subject', '-nameopt', 'RFC2253']);

    // Catch stderr
    openssl.stderr.on('data', function (out) {
      err = new Error(out);

      // Callback and return array
  		return cb(err, infoObject);
    });

    openssl.stdout.on('data', function (out) {
      var data = out.toString();

      // Put each line into an array
      var lineArray = data.split('\n');

      // Filter out empty ones
      lineArray = lineArray.filter(function(n){ return n !== undefined && n !== '' });

      /* Construct infoObject */

      // Certificate
      infoObject.certificate = cert;

      // Subject
      infoObject.subject = {};
      // Split by "/" prefix
      subjectElements = lineArray[0].replace('subject=', '').split(',');
      // For each elements
      for (var iS = 0; iS < subjectElements.length; iS++) {
        // Split keys and values by "=" separator
        var subjectKeyValue = subjectElements[iS].split('=');
        infoObject.subject[subjectKeyValue[0]] = subjectKeyValue[1];
      }

      // Callback and return array
  		return cb(err, infoObject);
  	});

  	openssl.stdin.write(cert);
  	openssl.stdin.end();
  }
function (cert, cb) {
    var infoObject = {},
        subjectElements = [],
        err;

  	var openssl = spawn('openssl', ['req', '-noout', '-subject', '-nameopt', 'RFC2253']);

    // Catch stderr
    openssl.stderr.on('data', function (out) {
      err = new Error(out);

      // Callback and return array
  		return cb(err, infoObject);
    });

    openssl.stdout.on('data', function (out) {
      var data = out.toString();

      // Put each line into an array
      var lineArray = data.split('\n');

      // Filter out empty ones
      lineArray = lineArray.filter(function(n){ return n !== undefined && n !== '' });

      /* Construct infoObject */

      // Certificate
      infoObject.certificate = cert;

      // Subject
      infoObject.subject = {};
      // Split by "/" prefix
      subjectElements = lineArray[0].replace('subject=', '').split(',');
      // For each elements
      for (var iS = 0; iS < subjectElements.length; iS++) {
        // Split keys and values by "=" separator
        var subjectKeyValue = subjectElements[iS].split('=');
        infoObject.subject[subjectKeyValue[0]] = subjectKeyValue[1];
      }

      // Callback and return array
  		return cb(err, infoObject);
  	});

  	openssl.stdin.write(cert);
  	openssl.stdin.end();
  }
function ( cert , cb ) { var infoObject = { } , subjectElements = [ ] , err ; var openssl = spawn ( 'openssl' , [ 'req' , '-noout' , '-subject' , '-nameopt' , 'RFC2253' ] ) ; // Catch stderr openssl . stderr . on ( 'data' , function ( out ) { err = new Error ( out ) ; // Callback and return array return cb ( err , infoObject ) ; } ) ; openssl . stdout . on ( 'data' , function ( out ) { var data = out . toString ( ) ; // Put each line into an array var lineArray = data . split ( '\n' ) ; // Filter out empty ones lineArray = lineArray . filter ( function ( n ) { return n !== undefined && n !== '' } ) ; /* Construct infoObject */ // Certificate infoObject . certificate = cert ; // Subject infoObject . subject = { } ; // Split by "/" prefix subjectElements = lineArray [ 0 ] . replace ( 'subject=' , '' ) . split ( ',' ) ; // For each elements for ( var iS = 0 ; iS < subjectElements . length ; iS ++ ) { // Split keys and values by "=" separator var subjectKeyValue = subjectElements [ iS ] . split ( '=' ) ; infoObject . subject [ subjectKeyValue [ 0 ] ] = subjectKeyValue [ 1 ] ; } // Callback and return array return cb ( err , infoObject ) ; } ) ; openssl . stdin . write ( cert ) ; openssl . stdin . end ( ) ; }
Decodes information from the provided certificate
sign request.
@param  {String|Buffer} cert       Input certificate
@param  {Function} cb              Callback
@return {Error} err, {Object} info Error and information object
Decodes information from the provided certificate sign request .