|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-07-28 10:37 UTC] agoralski at certum dot pl
When the certificate has more that one OU (organizationalUnit), the openssl_x509_parse function will return only the last one. Proposal: The openssl_x509_parse should return: [subject][OU][0]='First OU' [subject][OU][1]='Second OU' When there is only one OU field the openssl_x509_parse should return: [subject][OU]='First and only OU' It's up to the user to check if [subject][OU] is an array IMO. We can submit a patch :) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 07:00:01 2025 UTC |
verified on RedHat 9, PHP 4.2.2 output from var_dump of array after openssl_x509_parse was performed. There should have been an ["OU"]=> "DoD" before the PKI line ["issuer"]=> array(4) { ["C"]=> string(2) "US" ["O"]=> string(15) "U.S. Government" ["OU"]=> string(3) "PKI" ["CN"]=> string(22) "DOD CLASS 3 EMAIL CA-7"Multiple OUs are visible in "name" after openssl_x509_parse so here's a quick & dirty workaround: function get_ous($data) { if (strlen(strstr($data,'/OU='))>0) { $parts=explode('=', $data); for ($i=0, $j=count($parts); $i<$j; $i++) { if ($i>0) { if (substr($parts[$i-1], strrpos($parts[$i-1], '/')+1)=='OU') { $ret[]=substr($parts[$i], 0, strrpos($parts[$i], '/')); } } } return $ret; } else { return false; } } $cert=openssl_x509_parse($crt); $ous=get_ous($cert['name']); if (is_array($ous)) { //your code here }