[PHP-DOC] #20705 [Fbk->Opn]: openssl_pkey_new does not seem to generate a new key From: wez <email protected>
Date: 12/11/02

 ID: 20705
 Updated by: wez <email protected>
 Reported By: Troublegum <email protected>
-Status: Feedback
+Status: Open
-Bug Type: OpenSSL related
+Bug Type: Documentation problem
 Operating System: Windows 2000 Professional
 PHP Version: 4.2.3
-Assigned To:
+Assigned To: wez
 New Comment:

It seems that you need to have a valid openssl.cnf file for this to
work correctly.
You can obtain this file from one of the packages at:
http://www.openssl.org/source/

The default path is C:\usr\local\ssl\openssl.cnf, but
you can override this path like this:
$key = openssl_pkey_new(
   array("config" => "path/to/openssl.cnf")
);

We are currently investigating including a file for this purpose in our
win32 binary distributions.

Making this a documentation problem (I already added more information,
but this has yet to filter through to the online docs).

Previous Comments:
------------------------------------------------------------------------

[2002-12-11 01:04:41] sniper <email protected>

Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip

------------------------------------------------------------------------

[2002-12-10 18:31:32] Troublegum <email protected>

openssl_error_string() returns different messages when I reload the
page. I used the following test script:
----------
<?php
$privkey = openssl_pkey_new();
if(empty($privkey))
{
        echo "error: no key was generated by openssl_pkey_new()";
}
else
{
        echo "a private key was generated by openssl_pkey_new()";
}
echo "<br>Error Message: ".openssl_error_string()."<br>";
exit;
?>
--------------------

These are the error messages openssl_error_string() returned:

1. request) error:02001003:system library:fopen:No such process
2. request) error:2006D002:BIO routines:BIO_new_file:system lib
3. request) error:02001003:system library:fopen:No such process

Thanks..

------------------------------------------------------------------------

[2002-12-10 13:30:05] wez <email protected>

And what error messages does openssl_error_string() return?

------------------------------------------------------------------------

[2002-12-10 11:27:12] Troublegum <email protected>

Yes, you are right. But even with the correct variable and the latest
win32 snapshot (downloaded at 07/12/2002) it did not work for me.

The problem is the following:
<?php
/** generate key */
$privkey = openssl_pkey_new();

if(empty($privkey))
{
        die("error: no key was generated by openssl_pkey_new()");
}
else
{
        echo "a private key was generated by openssl_pkey_new()";
}
?>

produces
"error: no key was generated by openssl_pkey_new()".

------------------------------------------------------------------------

[2002-12-10 04:36:57] wez <email protected>

Your test script is wrong:
/** read in key */
$loaded_key = openssl_pkey_get_private($key_content, $pass);

$pass is not set to anything; you meant $password, in which case this
works fine.
 

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/20705

-- 
Edit this bug report at http://bugs.php.net/?id=20705&edit=1

-- PHP Documentation Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php