php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71919 openssl_pkey_get_private/public() require 2 calls to openssl_pkey_free()
Submitted: 2016-03-29 12:32 UTC Modified: 2017-10-30 12:37 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: gelenkig at runbox dot com Assigned: bukka (profile)
Status: Closed Package: OpenSSL related
PHP Version: 5.5.33 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gelenkig at runbox dot com
New email:
PHP Version: OS:

 

 [2016-03-29 12:32 UTC] gelenkig at runbox dot com
Description:
------------
This code works as expected:

  $r = openssl_pkey_new();
  // passes
  assert(is_resource($r));
  openssl_pkey_free($r);
  // passes
  assert(!is_resource($r));



Test script:
---------------
This code works wrong:

  $r = openssl_pkey_new();
  openssl_pkey_export($r, $pem);
  openssl_pkey_free($r);
  $r = openssl_pkey_get_private($pem);
  // passes
  assert(is_resource($r));
  openssl_pkey_free($r);
  // assertion below must not pass but it does pass
  assert(is_resource($r));
  openssl_pkey_free($r);
  // passes
  assert(!is_resource($r));

Same wrong behaviour for openssl_pkey_get_public().

Expected result:
----------------
  // either that or openssl_pkey_get_public()
  $r = openssl_pkey_get_private($pem);
  // passes
  assert(is_resource($r));
  openssl_pkey_free($r);
  // passes (in reality DOES NOT)
  assert(is_resource($r));



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-10-30 12:37 UTC] bukka@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: bukka
 [2017-10-30 12:37 UTC] bukka@php.net
This was fixed in 7.0 when extension was ported and is no longer an issue. It is still present in 5.6 but that's just for security related fixes. So closing.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 11:01:32 2025 UTC