|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-11-28 14:25 UTC] Troublegum at woltlab dot de
OS: Windows 2000 Professional
PHP version: 4.2.3
Apache version: 1.3.24 Win32
openssl: 0.9.6c
Problem: openssl_pkey_new does not seem to generate a new key
how to reproduces the problem:
I have the following script to test openssl..
--------------------------------------------------
<?php
/** generate key */
$privkey = openssl_pkey_new();
/** export key to file */
$password = "test";
$dest_file = "./key.pem";
openssl_pkey_export_to_file($privkey,$dest_file, $password);
/** read in keyfile */
$fp = fopen($dest_file, "r");
$key_content = fread($fp, filesize($dest_file));
fclose($fp);
/** read in key */
$loaded_key = openssl_pkey_get_private($key_content, $pass);
/** check key */
if ($loaded_key === false)
{
die("not correct");
}
else
{
echo "correct";
}
openssl_pkey_free($loaded_key);
?>
--------------------------------------------------
The output is the following:
Warning: cannot get key from parameter 1 in c:\dev\htdocs\openssl\test.php on line 9
not correct
--------------------------------------------------
I first compiled openssl 0.9.6c using Visual C++ and copied libeay32.dll and ssley32.dll to c:/winnt/system32.
Then I upgraded to php 4.2.3 and replaced the two files with ones in the folder "dlls".
Openssl seems to be installed:
> OpenSSL support enabled
> OpenSSL Version OpenSSL 0.9.6c 21 dec 2001
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 11:00:02 2025 UTC |
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()".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..