1--TEST-- 2openssl_csr_get_subject() tests 3--EXTENSIONS-- 4openssl 5--SKIPIF-- 6<?php 7if (!defined("OPENSSL_KEYTYPE_DSA")) die("skip DSA disabled"); 8?> 9--FILE-- 10<?php 11$config = __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf'; 12$phex = 'dcf93a0b883972ec0e19989ac5a2ce310e1d37717e8d9571bb7623731866e61e' . 13 'f75a2e27898b057f9891c2e27a639c3f29b60814581cd3b2ca3986d268370557' . 14 '7d45c2e7e52dc81c7a171876e5cea74b1448bfdfaf18828efd2519f14e45e382' . 15 '6634af1949e5b535cc829a483b8a76223e5d490a257f05bdff16f2fb22c583ab'; 16$dh_details = array('p' => $phex, 'g' => '2'); 17$dh = openssl_pkey_new(array( 18 'dh'=> array('p' => hex2bin($phex), 'g' => '2')) 19); 20 21$dn = array( 22 "countryName" => "BR", 23 "stateOrProvinceName" => "Rio Grande do Sul", 24 "localityName" => "Porto Alegre", 25 "commonName" => "Henrique do N. Angelo", 26 "emailAddress" => "hnangelo@php.net" 27); 28 29$args = array( 30 "digest_alg" => "sha256", 31 "private_key_bits" => 2048, 32 "private_key_type" => OPENSSL_KEYTYPE_DSA, 33 "encrypt_key" => true, 34 "config" => $config, 35); 36 37$privkey_file = 'file://' . __DIR__ . '/private_rsa_2048.key'; 38$csr = openssl_csr_new($dn, $privkey_file, $args); 39$csr_file = file_get_contents(__DIR__ . '/cert.csr'); 40 41var_dump(openssl_csr_get_subject($csr_file)); 42var_dump(openssl_csr_get_subject($csr, false)); 43?> 44--EXPECT-- 45array(6) { 46 ["C"]=> 47 string(2) "NL" 48 ["ST"]=> 49 string(13) "Noord Brabant" 50 ["L"]=> 51 string(4) "Uden" 52 ["O"]=> 53 string(10) "Triconnect" 54 ["OU"]=> 55 string(10) "Triconnect" 56 ["CN"]=> 57 string(15) "*.triconnect.nl" 58} 59array(6) { 60 ["countryName"]=> 61 string(2) "BR" 62 ["stateOrProvinceName"]=> 63 string(17) "Rio Grande do Sul" 64 ["localityName"]=> 65 string(12) "Porto Alegre" 66 ["commonName"]=> 67 string(21) "Henrique do N. Angelo" 68 ["emailAddress"]=> 69 string(16) "hnangelo@php.net" 70 ["organizationName"]=> 71 string(24) "Internet Widgits Pty Ltd" 72} 73