CakeFest 2024: The Official CakePHP Conference

PharData::setSignatureAlgorithm

(No version information available, might only be in Git)

PharData::setSignatureAlgorithmphar のシグネチャのアルゴリズムを設定する

説明

public PharData::setSignatureAlgorithm(int $algo, ?string $privateKey = null): void

注意:

このメソッドは、php.iniphar.readonly0 でないと Phar オブジェクトで動作しません。それ以外の場合は PharException がスローされます。

phar のシグネチャのアルゴリズムを設定します。 シグネチャのアルゴリズムは Phar::MD5Phar::SHA1Phar::SHA256Phar::SHA512 あるいは Phar::OPENSSL のいずれかでなければなりません

パラメータ

algo

Phar::MD5Phar::SHA1Phar::SHA256Phar::SHA512 あるいは Phar::OPENSSL のいずれか。

戻り値

値を返しません。

エラー / 例外

さまざまなエラーが発生した場合に UnexpectedValueException をスローします。 zip 形式や tar 形式の phar アーカイブに対してコールした場合は BadMethodCallException をスローします。 変更内容をディスクに書き込むときにエラーが発生した場合は PharException をスローします。

変更履歴

バージョン 説明
8.0.0 privateKey は、nullable になりました。

参考

add a note

User Contributed Notes 1 note

up
3
obsidian[at-nospam]codebite[dot]net
12 years ago
As a note, the docs don't show the (optional) second parameter nor mention the existence of the Phar::OPENSSL class constant also available for use with this method.

To sign a phar with OpenSSL, for example...

<?php

$phar
= new Phar('somephar.phar');
// ... add your files and such
$phar->setSignatureAlgorithm(Phar::OPENSSL, file_get_contents('private_key_here.pem'));
// ... do whatever else you want afterwards here ...
?>

Hope this proves useful to someone.
To Top