예제 #1
0
 public static function createFromPems(array $pems)
 {
     $chain = new Janus_OpenSsl_Certificate_Chain();
     foreach ($pems as $pem) {
         $certificate = new Janus_OpenSsl_Certificate($pem);
         // Root CA?
         if (isset(self::$s_rootCertificates[$certificate->getIssuerDn()])) {
             $certificate->setTrustedRootCertificateAuthority(true);
         }
         $chain->addCertificate($certificate);
     }
     return $chain;
 }
예제 #2
0
 /**
  * Look for PEM encoded certs in text (like Mozillas CA bundle).
  *
  * @static
  * @param  string $text
  * @return array  Certificates found (array of Janus_OpenSsl_Certificate objects)
  */
 public static function getCertificatesFromText($text)
 {
     $inputLines = explode(PHP_EOL, $text);
     $certificatesFound = array();
     $recording = false;
     $certificate = "";
     foreach ($inputLines as $inputLine) {
         if (trim($inputLine) === "-----BEGIN CERTIFICATE-----") {
             $certificate = "";
             $recording = true;
         }
         if ($recording) {
             $certificate .= $inputLine . PHP_EOL;
         }
         if (trim($inputLine) === "-----END CERTIFICATE-----") {
             $certificate = new Janus_OpenSsl_Certificate($certificate);
             $certificatesFound[$certificate->getSubjectDN()] = $certificate;
             $recording = false;
         }
     }
     return $certificatesFound;
 }