From e3ff870fe1f8a3b3eb8f55eea68f6f61d99e640c Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Tue, 10 Mar 2015 11:38:16 +0100 Subject: [PATCH] release v2.0.1 --- bin/pharext | Bin 41888 -> 42187 bytes src/pharext/Openssl/PrivateKey.php | 24 +++++++++++++++++------- src/pharext/Packager.php | 2 +- src/pharext/Version.php | 2 +- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/bin/pharext b/bin/pharext index 857729d99cf60390120f8ced0d7d413535239f9b..1c9fdea865b157fe467168f3c9a09b8f3fb780cd 100755 GIT binary patch delta 1029 zcmYL|e@q)?7{`y639ZOVXx0AYr7KD=?V8OBk|N;7k8IfwkQLL;g!WqGg;7OLqXoa%-X(97J?A6E4$E91F0F$ zCJ5OmtFz-+0XkvSqBl)>`V#$3hpdjq-o&{qBJ=6d6Gq)V4UD*%r}^;>x3aMgE_yDb zRRfu+LFW_1@a_+q5p8tpWPTj;|M|IcVI8Bx7%l2G<;valH?HmKL!X#RGKL><)U*8b89YNF@|X)`^d2)Q z_4}(zrHbNW3wpux0<52Cv) z$9r5P5NRktK=C}JgcuMx5X2`Cj7LC%5osX6wh$L*ML<(*xSe4mfNR4!OiZnkxdM!F zaUldfAVEV`hTS#+CI(_6C%`bEVt^Mo9tvWY127^8Q7p@eAn1iRDb^4NF(fRPr*P=) zS*(C#0ZwFNvG&#&6Jbm3fNB?^02mffn1P!I2cbxF;S9-zR~tHQ*{hT<;%l!3b^FxF zRirOdty6gHX@#9UCy1psymtVbJdU#p@9p@`RJV@!ionCD9~kpw$9^kbtp_|(eNkQ3 z#{Wa?AejVc3K-G6*MyeADan4MS|deYWO7lbzYzJWYb3>7-T zi?_Txl~{4-e|yKo;EpHlP(T0r$;LqV?ejGwb4}-)E`*O9pKRh5eHWBtkIn=R`}_w< z?Y`NL*Yf`S?aZ%hI!8|5{DXyGY%R0Hn*G(u&4b3Rqr})VtI|?xZs0)9&KF*#>x575 zztn^J*2ZS9mjAF*%so1GsP&wghUJe3YR{%O{=r3qQ`YoLAANPIBKh1eONO%goa@}` zwO!wxMTh^oB!z7Y((=+zfA9U~<>(tz4%+_NzYk3(hf{~H*Q2V$#VeB^I^VAtiI%um t=$1;-Hs^hMrTN|TCaPt2{Nl+`|MuGF-P>>EkERLyPBi$(Z`ihb+kY-riWUF> delta 795 zcmX?ol4-$lrVZIrljq7v^W?Ms3o&6}VEDQF4$EXUX)S>+W(Ee3Ac%gsWNzN%uTrXD zRmyS<3`Hz9m6MN3Yk>ta_!t=G`tA&#JV9C$EU<%>fnnBt>j#s6OY4FKN?8~fem%0e zGdV$8WOAj909bGi69a>*epm@uuv|)jDW7$6r<5Ux+9Rb4qFzhMP4?$Q0nZ>$xldq)ub3&LPnGJI_ zCi|sHZa$Xg%s6>onv@w_N;6sss6Z)JlZ%tHriN3oC^auJH&sJPB`q^2Rj(wsKuJdd z%myi#ym79~WdDp+o8{bg%5KhSU%|KeOXDuq&0^E!Sr`>2Pc#$W>@;UK)8-0UJB`iW zvmP@}j%XL&+?TORfSD7hyRlYuvu|Yx$7GR3H#h&Dr@}n>&!WTiC-<|z*VAUn-Q;9H z|7Gb$!_siec`AR3mQ@P7R)6u=Db`?)m)&b9>H4zsuDeg=!Ux5<=NDP(Ow5n)79^+NKvefG61-;$o+>_6KI2b%> z^3H$$XQll6&-!h4itlj5EY*j!3N8e7-*}Usdv?{*QNes^9Cc%R6<+uB`hT z+eVkEzq*&2UozY`XTyo;?G=UwBC8^AoVfnzbn5iUQnhA{n=U+Mu-e@Et~k1DC*Qv) P24I2_045f9CtoK3>`FC0 diff --git a/src/pharext/Openssl/PrivateKey.php b/src/pharext/Openssl/PrivateKey.php index 470983d..35c596a 100644 --- a/src/pharext/Openssl/PrivateKey.php +++ b/src/pharext/Openssl/PrivateKey.php @@ -5,10 +5,16 @@ namespace pharext\Openssl; class PrivateKey { /** - * OpenSSL pkey resource - * @var resource + * Private key + * @var string */ private $key; + + /** + * Public key + * @var string + */ + private $pub; /** * Read a private key @@ -17,10 +23,16 @@ class PrivateKey * @throws \Exception */ function __construct($file, $password) { - $this->key = openssl_pkey_get_private("file://$file", $password); - if (!is_resource($this->key)) { + /* there appears to be a bug with refcount handling of this + * resource; when the resource is stored as property, it cannot be + * "coerced to a private key" on openssl_sign() alter in another method + */ + $key = openssl_pkey_get_private("file://$file", $password); + if (!is_resource($key)) { throw new \Exception("Could not load private key"); } + openssl_pkey_export($key, $this->key); + $this->pub = openssl_pkey_get_details($key)["key"]; } /** @@ -37,9 +49,7 @@ class PrivateKey * @throws \Exception */ function exportPublicKey($file) { - if (!file_put_contents("$file.tmp", openssl_pkey_get_details($this->key)["key"]) - || !rename("$file.tmp", $file) - ) { + if (!file_put_contents("$file.tmp", $this->pub) || !rename("$file.tmp", $file)) { throw new \Exception(error_get_last()["message"]); } } diff --git a/src/pharext/Packager.php b/src/pharext/Packager.php index f268765..4d432ed 100644 --- a/src/pharext/Packager.php +++ b/src/pharext/Packager.php @@ -159,7 +159,7 @@ class Packager implements Command $this->info("Creating phar %s ...%s", $pkgtemp, $this->args->verbose ? "\n" : " "); try { $package = new Phar($pkgtemp); - + if ($this->args->sign) { $this->info("\nUsing private key to sign phar ... \n"); $privkey = new Openssl\PrivateKey(realpath($this->args->sign), $this->askpass()); diff --git a/src/pharext/Version.php b/src/pharext/Version.php index 50a2875..747aec6 100644 --- a/src/pharext/Version.php +++ b/src/pharext/Version.php @@ -2,4 +2,4 @@ namespace pharext; -const VERSION = "@PHAREXT_VERSION@"; +const VERSION = "2.0.1"; -- 2.30.2