php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80489 openssl_pkey_get_private cannot parse private keys. Works in 7.4
Submitted: 2020-12-07 10:47 UTC Modified: 2020-12-07 11:36 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: php at themodem dot co dot uk Assigned:
Status: Not a bug Package: OpenSSL related
PHP Version: 8.0.0 OS: all
Private report: No CVE-ID: None
 [2020-12-07 10:47 UTC] php at themodem dot co dot uk
Description:
------------
In php 7.4 the function openssl_pkey_get_private on the private key listed in the test script is parsed correctly as a private key and a resource is returned.

In php 8.0 this function fails silently to parse the key and does not return a resource.

Test script:
---------------
<?php

$privateKey = <<<EOL
-----BEGIN RSA PRIVATE KEY-----
MIIJKQIBAAKCAgEA4sBq75B5RV02UaqNS/PmhompscLf4igPdhcs4a1viRH91w37
ymYUuKwIUG3gOnd+vJT/SK/ncNAOfcsAxJNgFjel3T3riMVt8sHOFkPooGJCJiER
RtLQO+gnly/yEvNfbwJertXpdOBJotvq/2a9J1OCjrf/W5L4o7mu6Wi0yQFPNdJj
81LUoNYAMBhNLF37kBguxMubGHbeyfoyGuS0/5l+R22Ra7THMDn3BdfZ0nW3VgMK
xjDigMIh2glRS+UtkJN8uP8enwuNO9LTZLDkW5Xl+9657kMismr29RiZ7L4wbDzl
dDdTjwMuYSCqITltj1l5QL1z8b/m04RAB47s1EwSkxHejXVSA+PdrTfhi2cULvwq
iW5NYdZjycFEQlH2fgzJyyQ97MfsqA7KWsUT7rtq/F4cg4NWaNpRUMyD9gTreMDf
6g19sY9foojNWd/GkSLSI4oooYpVruJAJYKKUGqrnevYiRbuxuu2oA291KuwylAt
f7gtj6XBlt1Nhz/ySfiPFF27v/vFxLDVEVGsFiSFBv4ikOzOMYftTlNVMF2g1EQn
DiRQh7kQSrXeUQn0CGjqxlfsglJ1pTRrFdJHEH33AsBMCwIAydMSoNr31O2vwUyR
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EP/YjmE
2KuloSf6cDgsc46cfQUH/COAxHzScrT+6wKCAQAJ6udkTzI5356F4Fws0j6Tnaw8
nrBjG0aLotB8FeHuCzjeElOhEzzskjsHO7eqRTJqtcNEHXhy7+H+OkMbCfUAT1NK
HeHdI7HPyFdI5yVJu7o5Mg69rQTMUWEqMzyht1BG4f3J4luf24RNkMNG/OncFie7
xGkrqfPhxSzELOUyyNLNhceBe+YXL6yWYyVIb6t4meu0svmhWv2jDrtMFTHiTlNQ
tWamInGPLg3uH0RhzgAqReKzV0muOxZ23s/u+VOSyactWxufQ4z/duURoa1mLTE+
WtEnQ+edqZTbhlr4bE8qdpDEd79sjU8+7V9nThF7ySCPDNMYslZyT+HU5ggv
-----END RSA PRIVATE KEY-----
EOL;

$res = openssl_pkey_get_private($privateKey);
var_dump(is_resource($res));


Expected result:
----------------
bool(true)

Actual result:
--------------
bool(false)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-07 10:49 UTC] rtrtrtrtrt at dfdfdfdf dot dfd
you really hsould read the changes before major updates

https://www.php.net/releases/8.0/en.php

Opaque objects instead of resources for Curl, Gd, Sockets, OpenSSL, XMLWriter, and XML extensions 

https://php.watch/versions/8.0/OpenSSL-resource
 [2020-12-07 10:55 UTC] php at themodem dot co dot uk
-Status: Open +Status: Closed
 [2020-12-07 10:55 UTC] php at themodem dot co dot uk
My bad, was searching for the function name and not generic openssl in the release notes.

Closed as not a bug
 [2020-12-07 11:36 UTC] cmb@php.net
-Status: Closed +Status: Not a bug
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Dec 03 00:05:54 2022 UTC