1d3aed1e6d3d2a035ce2a7e1933e0d1590a88f7d
3 namespace pharext\Openssl
;
9 function __construct($file, $password) {
10 $this->key
= openssl_pkey_get_private("file://$file", $password);
11 if (!is_resource($this->key
)) {
12 throw new \
Exception("Could not load private key");
16 function sign(\Phar
$package) {
17 $package->setSignatureAlgorithm(\Phar
::OPENSSL
, $this->key
);
20 function exportPublicKey($file) {
21 if (!file_put_contents("$file.tmp", openssl_pkey_get_details($this->key
)["key"])
22 ||
!rename("$file.tmp", $file)
24 throw new \
Exception(error_get_last()["message"]);