2
Bug #55646: textual input in openssl_csr_new() is not expected in UTF-8
5
if (!function_exists('openssl_csr_new'))
6
die('skip no openssl extension');
9
function stringAsHex($string){$unpacked = unpack("H*", $string);return implode(" ", str_split($unpacked[1],2));}
11
$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,);
13
"countryName" => "US",
14
"stateOrProvinceName" => "Utah",
15
"localityName" => "Lindon",
16
"organizationName" => "Chinese",
17
"organizationalUnitName" => "IT \xe4\xba\x92",
18
"commonName" => "www.example.com",);
19
$private = openssl_pkey_new($config);
20
while (openssl_error_string()) {}
21
$csr_res = openssl_csr_new($csr_info, $private,
22
['config' => __DIR__."/openssl.cnf"]);
24
while ($e = openssl_error_string()) { $err = $e; }
25
die("Failed; last error: $err");
27
openssl_csr_export($csr_res, $csr);
28
$output = openssl_csr_get_subject($csr);
30
echo "A: ".$csr_info["organizationalUnitName"]."\n";
31
echo "B: ".stringAsHex($csr_info["organizationalUnitName"])."\n";
32
echo "C: ".$output['OU']."\n";
33
echo "D: ".stringAsHex($output['OU'])."\n";