From:             
Operating system: Ubuntu 10.04
PHP version:      5.3.8
Package:          OpenSSL related
Bug Type:         Bug
Bug description:decoding csr corrupts UTF8 characters

Description:
------------
I did this in command line php,
OpenSSL 0.9.8k 25 Mar 2009

If I create a csr with a UTF8 character, then I ought to get the UTF8
character out, untampered with when I parse it.


Test script:
---------------
<?php
function stringAsHex($string){$unpacked = unpack("H*", $string);return
implode(" ", str_split($unpacked[1],2));}

$config = array("digest_alg" => "sha1","x509_extensions" =>
"v3_ca","req_extensions" => "v3_req","private_key_bits" =>
2048,"private_key_type" => OPENSSL_KEYTYPE_RSA,"encrypt_key" => false,);
$csr_info = array(
  "countryName" => "US",
  "stateOrProvinceName" => "Utah",
  "localityName" => "Lindon",
  "organizationName" => "Chinese",
  "organizationalUnitName" => "IT \xe4\xba\x92",
  "commonName" => "www.example.com",);
$private = openssl_pkey_new($config);
$csr_res = openssl_csr_new($csr_info, $private);
openssl_csr_export($csr_res, $csr); //echo $csr;
$output = openssl_csr_get_subject($csr);

echo "A: ".$csr_info["organizationalUnitName"]."\n";
echo "B: ".stringAsHex($csr_info["organizationalUnitName"])."\n";
echo "C: ".$output['OU']."\n";
echo "D: ".stringAsHex($output['OU'])."\n";

Expected result:
----------------
A: IT 互
B: 49 54 20 e4 ba 92
C: IT 互
D: 49 54 20 e4 ba 92


Actual result:
--------------
A: IT 互
B: 49 54 20 e4 ba 92
C: IT 互
D: 49 54 20 c3 a4 c2 ba c2 92


-- 
Edit bug report at https://bugs.php.net/bug.php?id=55646&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=55646&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=55646&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=55646&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=55646&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=55646&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=55646&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=55646&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=55646&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=55646&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=55646&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=55646&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=55646&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=55646&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=55646&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=55646&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=55646&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=55646&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=55646&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=55646&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=55646&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=55646&r=mysqlcfg

Reply via email to