Annotation of embedaddon/php/ext/openssl/tests/bug55646.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Bug #55646: textual input in openssl_csr_new() is not expected in UTF-8
! 3: --SKIPIF--
! 4: <?php
! 5: if (!function_exists('openssl_csr_new'))
! 6: die('skip no openssl extension');
! 7: --FILE--
! 8: <?php
! 9: function stringAsHex($string){$unpacked = unpack("H*", $string);return implode(" ", str_split($unpacked[1],2));}
! 10:
! 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,);
! 12: $csr_info = array(
! 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"]);
! 23: if (!$csr_res) {
! 24: while ($e = openssl_error_string()) { $err = $e; }
! 25: die("Failed; last error: $err");
! 26: }
! 27: openssl_csr_export($csr_res, $csr);
! 28: $output = openssl_csr_get_subject($csr);
! 29:
! 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";
! 34: --EXPECT--
! 35: A: IT 互
! 36: B: 49 54 20 e4 ba 92
! 37: C: IT 互
! 38: D: 49 54 20 e4 ba 92
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>