File: bug55646.phpt

package info (click to toggle)
php5 5.6.7%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 150,376 kB
  • sloc: ansic: 727,510; php: 21,966; sh: 12,356; cpp: 8,763; xml: 6,105; yacc: 1,551; exp: 1,514; makefile: 1,461; pascal: 1,048; awk: 538; perl: 315; sql: 22
file content (38 lines) | stat: -rw-r--r-- 1,337 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
--TEST--
Bug #55646: textual input in openssl_csr_new() is not expected in UTF-8
--SKIPIF--
<?php
if (!function_exists('openssl_csr_new'))
	die('skip no openssl extension');
--FILE--
<?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);
while (openssl_error_string()) {}
$csr_res = openssl_csr_new($csr_info, $private,
	['config' => __DIR__."/openssl.cnf"]);
if (!$csr_res) {
	while ($e = openssl_error_string()) { $err = $e; }
	die("Failed; last error: $err");
}
openssl_csr_export($csr_res, $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";
--EXPECT--
A: IT 互
B: 49 54 20 e4 ba 92
C: IT 互
D: 49 54 20 e4 ba 92