• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/web/jwk.php
  • Класс: BitrixMainWebJWK
  • Вызов: JWK::parseKey
static function parseKey($source)
{
	if (!is_array($source))
		$source = (array)$source;
	if (!empty($source) && isset($source['kty']) && isset($source['n']) && isset($source['e'])) {
		switch ($source['kty']) {
			case 'RSA':
				if (array_key_exists('d', $source))
					throw new UnexpectedValueException('Failed to parse JWK: RSA private key is not supported');

				$pem = self::createPemFromModulusAndExponent($source['n'], $source['e']);
				$pKey = openssl_pkey_get_public($pem);
				if ($pKey !== false)
					return $pKey;
				break;
			default:
				//Currently only RSA is supported
				break;
		}
	}

	throw new UnexpectedValueException('Failed to parse JWK');
}