Unbundles a file composed of several certificates.
http://www.benjiegillam.com/2012/06/node-dot-js-ssl-certificate-chain/
9468
function unbundleCert(bundle) {
  var chain = bundle.trim().split('\n');

  var ca = [];
  var cert = [];

  for (var i = 0, len = chain.length; i < len; i++) {
    var line = chain[i].trim();
    if (!(line.length !== 0)) {
      continue;
    }
    cert.push(line);
    if (line.match(/-END CERTIFICATE-/)) {
      var joined = cert.join('\n');
      ca.push(joined);
      cert = [];
    }
  }
  return ca;
}
262642
function bundleJsFiles () {
  return concat(jsFiles)
    .then((output) => {
      const uglified = UglifyJS.minify(output)
      if (uglified.error) {
        throw new Error(uglified.error)
      }
      return uglified.code
    })
}
728313
function () {
        var obj = PropertyBase.toJSON(this);

        _.unset(obj, 'key.value');
        _.unset(obj, 'cert.value');
        _.unset(obj, 'pfx.value');

        return obj;
    }
658863
private void doSave() {
		if (txt_PubCert.getDocument().getLength() < MIN_CERT_LENGTH) {
			logger.error("Illegal state! There seems to be no certificate available.");
			bt_save.setEnabled(false);
		}
		final JFileChooser fc = new JFileChooser(System.getProperty("user.home"));
		fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
		fc.setMultiSelectionEnabled(false);
		fc.setSelectedFile(new File(OWASP_ZAP_ROOT_CA_FILENAME));
		if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
			final File f = fc.getSelectedFile();
			if (logger.isInfoEnabled()) {
				logger.info("Saving Root CA certificate to " + f);
			}
			try {
				writePubCertificateToFile(f);
			} catch (final Exception e) {
				logger.error("Error while writing certificate data to file " + f, e);
			}
		}
	}
242850
function unzip(src, dst) {
  return load(src).then(zip => {
    let promisedDirs = new Map;
    let promises = [];

    zip.z_.forEach((relPath, file) => {
      let p;
      if (file.dir) {
        p = createDir(relPath);
      } else {
        let dirname = path.dirname(relPath);
        if (dirname === '.') {
          p = writeFile(relPath, file);
        } else {
          p = createDir(dirname).then(() => writeFile(relPath, file));
        }
      }
      promises.push(p);
    });

    return Promise.all(promises).then(() => dst);

    function createDir(dir) {
      let p = promisedDirs.get(dir);
      if (!p) {
        p = io.mkdirp(path.join(dst, dir));
        promisedDirs.set(dir, p);
      }
      return p;
    }

    function writeFile(relPath, file) {
      return file.async('nodebuffer')
          .then(buffer => io.write(path.join(dst, relPath), buffer));
    }
  });
}
615568
private byte[] encodePKIPATH() throws CertificateEncodingException {

        ListIterator<X509Certificate> li = certs.listIterator(certs.size());
        try {
            DerOutputStream bytes = new DerOutputStream();
            // encode certs in reverse order (trust anchor to target)
            // according to PkiPath format
            while (li.hasPrevious()) {
                X509Certificate cert = li.previous();
                // check for duplicate cert
                if (certs.lastIndexOf(cert) != certs.indexOf(cert)) {
                    throw new CertificateEncodingException
                        ("Duplicate Certificate");
                }
                // get encoded certificates
                byte[] encoded = cert.getEncoded();
                bytes.write(encoded);
            }

            // Wrap the data in a SEQUENCE
            DerOutputStream derout = new DerOutputStream();
            derout.write(DerValue.tag_SequenceOf, bytes);
            return derout.toByteArray();

        } catch (IOException ioe) {
           throw new CertificateEncodingException("IOException encoding " +
                   "PkiPath data: " + ioe, ioe);
        }
    }
584264
function unbundle(argv, config, args, packagerInstance) {
  return bundleWithOutput(argv, config, args, outputUnbundle, packagerInstance);
}
238547
function bundle (ids = []) {
      ids.forEach((id) => {
        if (!muted.has(id)) {
          console.info(chalk.cyan('change:'), path.relative(process.cwd(), id))
          muted.add(id)
        }
      })

      const exampleName = path.basename(path.dirname(file))
      const output = dstPattern.replace('**', exampleName)
      const parentDir = path.dirname(output)

      mkdirp.sync(parentDir)

      console.info(chalk.grey(`⏳ building: ${path.relative(process.cwd(), file)}`))

      b
        .bundle()
        .on('error', onError)
        .pipe(createStream(output))
        .on('finish', () => {
          console.info(chalk.green(`✓ built: ${path.relative(process.cwd(), file)}`))
        })
    }
1067607
function strip(file) {
      file.fingerprint = file.fingerprint.slice(0, -3);
      delete file.source;
      delete file.sourcemap;
      delete file.shrinkwrap;
      return file;
    }
476836
function remove (from, what) {
  // TODO array coerce trick
  if (!_.isArray(what)) { what = [what] }
  return W.map(what, (p) => {
    return fs.unlinkSync(path.resolve(from, p))
  }
  )
}
1228778
function Bundler(file, cb) {

    var bundler = this, bundle,
        watchMsg = format('Watching bundle %s...', chalk.magenta(file));

    // set entry file for this bundler
    options.browserify.entries = [path.join(options.cwd, file)];

    // initiate bundle
    bundle = watchify(browserify(options.browserify), options.watchify);

    /**
     * on update, log to console and bundle
     * @param  {Array} ev  array of event files
     * @return {undefined}
     */
    bundle.on('update', function(ev) {
      log(format('%s File %s updated. Bundling %s ...',
        chalk.yellow('☀'),
        chalk.magenta(path.relative(options.cwd, ev[0])),
        chalk.magenta(file)
      ));
      bundler.outputBundle();
    });

    /**
     * when bundling, log infos to console
     * @param  {String} msg  bundling info
     * @return {undefined}
     */
    bundle.on('log', function(msg) {
      if (options.watch && !watchMsg) {
        log(format('%s Bundled %s %s',
          chalk.green('✓'),
          chalk.magenta(file),
          chalk.gray(msg)
        ));
      }
    });

    /**
     * bundle and transform to stream
     * @return {Object} gulp stream
     */
    this.outputBundle = function() {
      return streamHandler(
        bundle.bundle()
          .on('error', function(err) {
            log(chalk.red(format('✖ Bundling failed for %s %s',
              chalk.magenta(file),
              chalk.gray('(' + String(err) + ')')
            )));
            this.emit('end');
          })
          .pipe(source(file))
          .pipe(buffer())
          .on('end', function() {
            if (!options.watch) {
              bundle.close();
              return cb();
            } else if (watchMsg) {
              log(watchMsg);
              watchMsg = false;
            }
          })
      );
    };

  }
1180657
def process_js_certs(self, data, name, idx, sub_idx):
        
        from cryptography.x509.base import load_der_x509_certificate

        ret = []
        for crt_hex in data:
            try:
                bindata = base64.b64decode(crt_hex)
                x509 = load_der_x509_certificate(bindata, self.get_backend())

                self.num_ldiff_cert += 1
                sub = self.process_x509(x509, name=name, pem=False, source='ldiff-cert')
                ret.append(sub)

            except Exception as e:
                logger.debug('Error in line JSON cert file processing %s, idx %s, subidx %s : %s'
                             % (name, idx, sub_idx, e))
                self.trace_logger.log(e)
        return ret
1318239
function(cert) {
      // convert from PEM
      if(typeof cert === 'string') {
        cert = forge.pki.certificateFromPem(cert);
      }
      msg.certificates.push(cert);
    }
678213
function unlink(args, config) {
  const packageName = args[0];

  var project;
  var dependency;

  try {
    project = config.getProjectConfig();
  } catch (err) {
    log.error(
      'ERRPACKAGEJSON',
      'No package found. Are you sure it\'s a React Native project?'
    );
    return Promise.reject(err);
  }

  try {
    dependency = config.getDependencyConfig(packageName);
  } catch (err) {
    log.warn(
      'ERRINVALIDPROJ',
      `Project ${packageName} is not a react-native library`
    );
    return Promise.reject(err);
  }

  const allDependencies = getDependencyConfig(config, getProjectDependencies());
  const otherDependencies = filter(allDependencies, d => d.name !== packageName);
  const thisDependency = find(allDependencies, d => d.name === packageName);
  const iOSDependencies = compact(otherDependencies.map(d => d.config.ios));

  const tasks = [
    () => promisify(thisDependency.config.commands.preunlink || commandStub),
    () => unlinkDependencyAndroid(project.android, dependency, packageName),
    () => unlinkDependencyIOS(project.ios, dependency, packageName, iOSDependencies),
    () => promisify(thisDependency.config.commands.postunlink || commandStub)
  ];

  return promiseWaterfall(tasks)
    .then(() => {
      const assets = difference(
        dependency.assets,
        flatten(allDependencies, d => d.assets)
      );

      if (isEmpty(assets)) {
        return Promise.resolve();
      }

      if (project.ios) {
        log.info('Unlinking assets from ios project');
        unlinkAssetsIOS(assets, project.ios);
      }

      if (project.android) {
        log.info('Unlinking assets from android project');
        unlinkAssetsAndroid(assets, project.android.assetsPath);
      }

      log.info(
        `${packageName} assets has been successfully unlinked from your project`
      );
    })
    .catch(err => {
      log.error(
        `It seems something went wrong while unlinking. Error: ${err.message}`
      );
      throw err;
    });
}
234616
function proprietaryCertificate() {
	var self = {
		__TYPE__ : CertificateType.CERT_CHAIN_VERSION_1,
		dwSigAlgId : new type.UInt32Le(0x00000001, { constant : true }),
        dwKeyAlgId : new type.UInt32Le(0x00000001, { constant : true }),
        wPublicKeyBlobType : new type.UInt16Le(0x0006, { constant : true }),
        wPublicKeyBlobLen : new type.UInt16Le(function() {
        	return self.PublicKeyBlob.size();
        }),
        PublicKeyBlob : rsaPublicKey({ readLength : new type.CallableValue(function() {
        	return self.wPublicKeyBlobLen.value;
        }) }),
        wSignatureBlobType : new type.UInt16Le(0x0008, { constant : true }),
        wSignatureBlobLen : new type.UInt16Le(function() {
        	return self.SignatureBlob.size() + self.padding.size();
        }),
        SignatureBlob : new type.BinaryString(null, { readLength : new type.CallableValue(function() {
        	return self.wSignatureBlobLen.value - self.padding.size;
        }) }),
        padding : new type.BinaryString(Array(8 + 1).join('\x00'), { readLength : new type.CallableValue(8) }),
        /**
         * @return {object} rsa.publicKey
         */
        getPublicKey : function() {
        	return rsa.publicKey(self.PublicKeyBlob.obj.modulus.value, self.PublicKeyBlob.obj.pubExp.value);
        }
	};
	
	return new type.Component(self);
}
588068
function _extractBER($str)
    {
        /* X.509 certs are assumed to be base64 encoded but sometimes they'll have additional things in them
         * above and beyond the ceritificate.
         * ie. some may have the following preceding the -----BEGIN CERTIFICATE----- line:
         *
         * Bag Attributes
         *     localKeyID: 01 00 00 00
         * subject=/O=organization/OU=org unit/CN=common name
         * issuer=/O=organization/CN=common name
         */
        $temp = preg_replace('#.*?^-+[^-]+-+[\r\n ]*$#ms', '', $str, 1);
        // remove the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- stuff
        $temp = preg_replace('#-+[^-]+-+#', '', $temp);
        // remove new lines
        $temp = str_replace(array("\r", "\n", ' '), '', $temp);
        $temp = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $temp) ? base64_decode($temp) : false;
        return $temp != false ? $temp : $str;
    }
1309520
function unlinkIfExistsSync(filePath: string) {
  try {
    fs.unlinkSync(filePath);
  } catch (error) {
    if (error.code === 'ENOENT') {
      return;
    }
    throw error;
  }
}