Doc #65186 [Asn->Opn]: openssl_csr_new allows creation from text

From: Date: Tue, 24 Oct 2017 06:43:51 +0000
Subject: Doc #65186 [Asn->Opn]: openssl_csr_new allows creation from text
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-15143@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=65186&edit=1 ID: 65186 Updated by: kalle@php.net Reported by: lynch@php.net Summary: openssl_csr_new allows creation from text -Status: Assigned +Status: Open Type: Documentation Problem Package: OpenSSL related Operating System: N/A PHP Version: Irrelevant -Assigned To: lynch +Assigned To: Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2013-07-02 19:17:32] lynch@php.net Hope it's kosher to just decide to fix it myself... ------------------------------------------------------------------------ [2013-07-02 18:39:15] lynch@php.net 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 this bug report at https://bugs.php.net/bug.php?id=65186&edit=1

« previous php.doc.bugs (#15143) next »