php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69272 openssl_spki_export outputs public key to stdout
Submitted: 2015-03-20 16:24 UTC Modified: 2016-01-31 12:51 UTC
Votes:3
Avg. Score:4.0 ± 1.4
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: fkooman at tuxed dot net Assigned: bukka (profile)
Status: Closed Package: OpenSSL related
PHP Version: 5.6.7 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: fkooman at tuxed dot net
New email:
PHP Version: OS:

 

 [2015-03-20 16:24 UTC] fkooman at tuxed dot net
Description:
------------
the openssl_spki_export() function outputs the pubkey to stdout instead of in the return value as is suggested by the documentation on http://php.net/manual/en/function.openssl-spki-export.php.



Test script:
---------------
$ cat openssl_spki_export.php 
<?php
$spkac = 'MIICYDCCAUgwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDQtftB35r7naJsELxZyQj64Sshxu2QEtb0cWWbxijxduHR4JecLzBEHG4hKCRoIqSkRVFAWqWKxYIDq3JFNkA3172u0Dv2eNiTf+hQ/tNCzjtgUebeosJNalNCMz/HVNJWZaiN1as7wE6q+d8jTuZjQmEmN7g1jAqN5E2ntl5ABQk84/fzJyQLsYXfKcZYLeIxQOn9X8xLLUcW1oAsPmZj6sG/nbPmYBTyvC2eveVaW7//3ZY0WK8q0bREKu/YF1jj18W4OSAI0hWkjiKW7yVzZZHzEO71YaRA6CcfoOGx4HCA+VG09kCXdlHD9KHaEM4IoYXfimq1xE40LnOQx1dtAgMBAAEWIGZhNjFlYzgxMzY0OGFlMTU3NDY2NTQyN2NmZDhmZTFkMA0GCSqGSIb3DQEBBAUAA4IBAQARDf9DVVv8P/4xhmTEyJWMBd7gy55JqJ/aAusjMRqqlX19c3xOGofjbHlDsGB91rbX8AhrUqN1dJS69cjNgPuWv/ZgMEjm2mctajZYBdE7b1HBWx/B9nxSIt5esB+H+Lt74I4AWLWQb/Y4UXRdOxKgGS1uUMQEHPfH1hkf4OBEamI+PoVyksvQpNarTFXbybiGmNfRcc9kJFLrZTNLK/MtY8wHA0yai9tsJOn/kN+KnmaTqk18QwEV0Lco+4SmH8wEu3Xo/JMIa6S+MAsI8u/D0sgiRYk/PKW/VGPb17PLX1e9F4QZbRpNmpVUfS3MCE6afaw4vEvmsjBQnU3BHDAG';

openssl_spki_export($spkac);


$ php openssl_spki_export.php 
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0LX7Qd+a+52ibBC8WckI
+uErIcbtkBLW9HFlm8Yo8Xbh0eCXnC8wRBxuISgkaCKkpEVRQFqlisWCA6tyRTZA
N9e9rtA79njYk3/oUP7TQs47YFHm3qLCTWpTQjM/x1TSVmWojdWrO8BOqvnfI07m
Y0JhJje4NYwKjeRNp7ZeQAUJPOP38yckC7GF3ynGWC3iMUDp/V/MSy1HFtaALD5m
Y+rBv52z5mAU8rwtnr3lWlu//92WNFivKtG0RCrv2BdY49fFuDkgCNIVpI4ilu8l
c2WR8xDu9WGkQOgnH6DhseBwgPlRtPZAl3ZRw/Sh2hDOCKGF34pqtcRONC5zkMdX
bQIDAQAB
-----END PUBLIC KEY-----
[fkooman@franet data]$ 


Expected result:
----------------
expect to place the pubkey in the return variable and not on stdout


Actual result:
--------------
pubkey is placed in stdout


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-20 23:01 UTC] requinix@php.net
-Status: Open +Status: Verified
 [2015-03-20 23:01 UTC] requinix@php.net
http://3v4l.org/tcaHH#v560

https://github.com/php/php-src/blob/master/ext/openssl/openssl.c#L1624
1666  out = BIO_new_fp(stdout, BIO_NOCLOSE);
1667  PEM_write_bio_PUBKEY(out, pkey);

Not changing to a doc bug as returning the string would be nicer than outputting it.
 [2016-01-31 12:50 UTC] bukka@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: bukka
 [2016-01-31 12:51 UTC] bukka@php.net
I also assigned this to myself as closed to get notifications in case there is anything outstanding...
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 07 10:01:34 2025 UTC