release v2.0.1 v2.0.1
authorMichael Wallner <mike@php.net>
Tue, 10 Mar 2015 10:38:16 +0000 (11:38 +0100)
committerMichael Wallner <mike@php.net>
Tue, 10 Mar 2015 10:38:16 +0000 (11:38 +0100)
bin/pharext
src/pharext/Openssl/PrivateKey.php
src/pharext/Packager.php
src/pharext/Version.php

index 857729d99cf60390120f8ced0d7d413535239f9b..1c9fdea865b157fe467168f3c9a09b8f3fb780cd 100755 (executable)
Binary files a/bin/pharext and b/bin/pharext differ
index 470983da3972ccf8c21634c7602a7a3e9a000730..35c596acf57b9ba5fb7379dec203e7fdbfcf07c8 100644 (file)
@@ -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"]);
                }
        }
index f2687654f673a8623bc2e2ed8a704ea42b6a86d4..4d432ed5bc7edbe81679667e6cd46f0c1ea49985 100644 (file)
@@ -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());
index 50a28750d7af7e6115498aa859cf2219594cc570..747aec6c432038120a6363001e67c528933ff962 100644 (file)
@@ -2,4 +2,4 @@
 
 namespace pharext;
 
-const VERSION = "@PHAREXT_VERSION@";
+const VERSION = "2.0.1";