|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #65176 openssl_pkey_new / openssl_pkey_get_public
Submitted: 2013-07-01 14:52 UTC Modified: 2021-01-13 12:47 UTC
Avg. Score:5.0 ± 0.0
Reproduced:7 of 7 (100.0%)
Same Version:3 (42.9%)
Same OS:1 (14.3%)
From: Assigned: cmb (profile)
Status: Closed Package: OpenSSL related
PHP Version: Irrelevant OS: N/A
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2013-07-01 14:52 UTC]
From manual page:

The resulting resource cannot be used with openssl_pkey_get_public as stated.

At least not always.

Maybe that statement is only valid for some inputs for the config?

If so, clarification is needed, preferably identifying the sorts of keys where the statement is applicable.

See also: 25614 from 2009...

Test script:
$key_pair = openssl_pkey_new(array('digest_alg'=>'sha1', 'private_key_bits'=>1024, 'private_key_type'=>OPENSSL_KEYTYPE_RSA));


$public = openssl_pkey_get_public($key_pair);

Expected result:
resource (4) of type (OpenSSL key)

Actual result:
PHP Warning:  openssl_pkey_get_public(): Don't know how to get public key from this private key in /var/www/vhost.d/ on line 8
PHP Stack trace:
PHP   1. {main}() /var/www/vhost.d/
PHP   2. openssl_pkey_get_public() /var/www/vhost.d/

Warning: openssl_pkey_get_public(): Don't know how to get public key from this private key in /var/www/vhost.d/ on line 8

Call Stack:
    0.0005     222672   1. {main}() /var/www/vhost.d/
    0.0466     223696   2. openssl_pkey_get_public() /var/www/vhost.d/


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-01-13 12:47 UTC]
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2021-01-13 12:47 UTC]
The handling of bug #25614 was really suboptimal.  Despite the
last few comments, the documentation is still in error (see the
first comment from wez).
 [2021-01-13 13:01 UTC]
Automatic comment on behalf of
Log: Fix #65176: openssl_pkey_new / openssl_pkey_get_public
 [2021-01-13 13:01 UTC]
-Status: Verified +Status: Closed
 [2021-01-13 16:47 UTC]
Automatic comment on behalf of
Log: Fix #65176: openssl_pkey_new / openssl_pkey_get_public
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Jul 29 18:01:23 2021 UTC