Jose\KeyConverter\KeyConverter::loadKeyFromCertificate PHP Method

loadKeyFromCertificate() public static method

public static loadKeyFromCertificate ( string $certificate ) : array
$certificate string
return array
    public static function loadKeyFromCertificate($certificate)
    {
        try {
            $res = openssl_x509_read($certificate);
        } catch (\Exception $e) {
            $certificate = self::convertDerToPem($certificate);
            $res = openssl_x509_read($certificate);
        }
        Assertion::false(false === $res, 'Unable to load the certificate');
        $values = self::loadKeyFromX509Resource($res);
        openssl_x509_free($res);
        return $values;
    }

Usage Example

示例#1
0
 /**
  * @return \Jose\Object\JWKInterface[]
  */
 public function getKeys()
 {
     $content = json_decode($this->getContent(), true);
     Assertion::isArray($content, 'Invalid content.');
     $jwkset = new JWKSet();
     foreach ($content as $kid => $cert) {
         $jwk = KeyConverter::loadKeyFromCertificate($cert);
         Assertion::notEmpty($jwk, 'Invalid content.');
         if (is_string($kid)) {
             $jwk['kid'] = $kid;
         }
         $jwkset->addKey(new JWK($jwk));
     }
     return $jwkset->getKeys();
 }
All Usage Examples Of Jose\KeyConverter\KeyConverter::loadKeyFromCertificate