|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-05-13 10:49 UTC] samueld23 at live dot com
Description:
------------
When I run the test script I've pasted in the "test script" section of this bug
report, I get the warnings shown under "actual result" of this bug report.
I'm running this code on Windows Servef 2008 R2. I have tried running this exact
same code under both PHP 5.4.3 and PHP 5.3.13.
(However, the code works just fine on Mac OS X 10.7.4, using PHP version 5.3.10.)
Test script:
---------------
<?php
$privateKey = openssl_pkey_new(array(
'private_key_bits' => 1024,
'private_key_type' => OPENSSL_KEYTYPE_RSA,
));
openssl_pkey_export_to_file($privateKey, 'private_key', "somepassword");
$keyDetails = openssl_pkey_get_details($privateKey);
file_put_contents('public_key', $keyDetails['key']);
?>
Expected result:
----------------
I expect two files to get output, one with a private key and another with a
public key. In fact, this is exactly what happens on Mac OS X (as described in
the "description" section of this bug report). On Windows, it's for some reasons
not working, as described in the "actual result" section of this bug report.
Actual result:
--------------
When I run the script on the command prompt (using "cd <path to script>" and "
<path to php>\php.exe <path to script>\script.php"), I get the following output:
PHP Warning: openssl_pkey_export_to_file(): cannot get key from parameter 1 in
C:\Users\Administrator\Documents\script.php on line 8
PHP Warning: openssl_pkey_get_details() expects parameter 1 to be resource,
boolean given in C:\Users\Administrator\Documents\script.php on line 11
What ends up happening is that only one EMPTY file 'public_key' gets created.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 08 07:00:02 2025 UTC |
Is the directory writeable by PHP? (Not familiar with Windows environments) What happens if you do this? <?php $privateKey = openssl_pkey_new(array( 'private_key_bits' => 1024, 'private_key_type' => OPENSSL_KEYTYPE_RSA, )); var_dump($privateKey); if(openssl_pkey_export_to_file($privateKey, 'private_key', "somepassword")) { $keyDetails = openssl_pkey_get_details($privateKey); file_put_contents('public_key', $keyDetails['key']); } else { die("Error"); } ?>