pharext\Openssl\PrivateKey::__construct PHP Method

__construct() public method

Read a private key
public __construct ( string $file, string $password )
$file string
$password string
    function __construct($file, $password)
    {
        /* 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() later 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"];
    }