Doc #65186 [NEW]: openssl_csr_new allows creation from text
| From: | lynch@php.net | Date: | Tue, 02 Jul 2013 18:39:15 +0000 |
| Subject: | Doc #65186 [NEW]: openssl_csr_new allows creation from text | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-10037@lists.php.net to get a copy of this message | ||
From: lynch@php.net
Operating system: N/A
PHP version: Irrelevant
Package: OpenSSL related
Bug Type: Documentation Problem
Bug description:openssl_csr_new allows creation from text
Description:
------------
---
From manual page:
http://www.php.net/function.openssl-csr-new#refsect1-function.openssl-csr-new-parameters
---
It is not documented that:
$csr_resource = openssl_csr_new(array(), file_get_contents('some.csr'));
will return a valid CSR resource.
Test script:
---------------
//Load your private key
$private_key_resource =
openssl_pkey_get_private(file_get_contents('private.pem'));
//Extract the public key
$details = openssl_pkey_get_details($private_key_resource);
$public_key_text = $details['key'];
//Load the text CSR file
$csr_text = file_get_contents('request.csr');
// UNDOCUMENTED FEATURE
$csr_resource = openssl_csr_new(array(), $csr_text);
$csr_public_key_resource = openssl_csr_get_public_key($csr_resource);
$csr_public_key_details =
openssl_pkey_get_details($csr_public_key_resource);
$csr_public_key_text = $csr_public_key_details['key'];
//Prove that the CSR is valid, assuming you built it right in the first
place
if ($public_key_text != $csr_public_key_text)
{
echo "The public key doesn't match, so that's not a good CSR.\n";
}
else
{
echo "Yay! There IS a way to create a CSR resource from text. It's just
not documented.\n";
}
Expected result:
----------------
Going strictly by the docs, some kind of error message about wrong type for
the CSR, since text is in no way similar to a CSR private key resource.
Actual result:
--------------
It works, thank goodness.
Because if it didn't, there is no way to convert a CSR text file to a CSR
resource.
--
Edit bug report at https://bugs.php.net/bug.php?id=65186&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=65186&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=65186&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=65186&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=65186&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=65186&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=65186&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=65186&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=65186&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=65186&r=support
Expected behavior: https://bugs.php.net/fix.php?id=65186&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=65186&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=65186&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=65186&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65186&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=65186&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=65186&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=65186&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65186&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=65186&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=65186&r=mysqlcfg