1--TEST-- 2openssl_x509_parse() basic test 3--SKIPIF-- 4<?php if (!extension_loaded("openssl")) print "skip"; 5if (OPENSSL_VERSION_NUMBER < 0x10000000) die("skip Output requires OpenSSL 1.0"); 6?> 7--FILE-- 8<?php 9$cert = "file://" . dirname(__FILE__) . "/cert.crt"; 10 11var_dump(openssl_x509_parse($cert)); 12var_dump(openssl_x509_parse($cert, false)); 13?> 14--EXPECTF-- 15array(12) { 16 ["name"]=> 17 string(96) "/C=BR/ST=Rio Grande do Sul/L=Porto Alegre/CN=Henrique do N. Angelo/emailAddress=hnangelo@php.net" 18 ["subject"]=> 19 array(5) { 20 ["C"]=> 21 string(2) "BR" 22 ["ST"]=> 23 string(17) "Rio Grande do Sul" 24 ["L"]=> 25 string(12) "Porto Alegre" 26 ["CN"]=> 27 string(21) "Henrique do N. Angelo" 28 ["emailAddress"]=> 29 string(16) "hnangelo@php.net" 30 } 31 ["hash"]=> 32 string(8) "%s" 33 ["issuer"]=> 34 array(5) { 35 ["C"]=> 36 string(2) "BR" 37 ["ST"]=> 38 string(17) "Rio Grande do Sul" 39 ["L"]=> 40 string(12) "Porto Alegre" 41 ["CN"]=> 42 string(21) "Henrique do N. Angelo" 43 ["emailAddress"]=> 44 string(16) "hnangelo@php.net" 45 } 46 ["version"]=> 47 int(2) 48 ["serialNumber"]=> 49 string(20) "12593567369101004962" 50 ["validFrom"]=> 51 string(13) "080630102843Z" 52 ["validTo"]=> 53 string(13) "080730102843Z" 54 ["validFrom_time_t"]=> 55 int(1214821723) 56 ["validTo_time_t"]=> 57 int(1217413723) 58 ["purposes"]=> 59 array(9) { 60 [1]=> 61 array(3) { 62 [0]=> 63 bool(true) 64 [1]=> 65 bool(true) 66 [2]=> 67 string(9) "sslclient" 68 } 69 [2]=> 70 array(3) { 71 [0]=> 72 bool(true) 73 [1]=> 74 bool(true) 75 [2]=> 76 string(9) "sslserver" 77 } 78 [3]=> 79 array(3) { 80 [0]=> 81 bool(true) 82 [1]=> 83 bool(true) 84 [2]=> 85 string(11) "nssslserver" 86 } 87 [4]=> 88 array(3) { 89 [0]=> 90 bool(true) 91 [1]=> 92 bool(true) 93 [2]=> 94 string(9) "smimesign" 95 } 96 [5]=> 97 array(3) { 98 [0]=> 99 bool(true) 100 [1]=> 101 bool(true) 102 [2]=> 103 string(12) "smimeencrypt" 104 } 105 [6]=> 106 array(3) { 107 [0]=> 108 bool(true) 109 [1]=> 110 bool(true) 111 [2]=> 112 string(7) "crlsign" 113 } 114 [7]=> 115 array(3) { 116 [0]=> 117 bool(true) 118 [1]=> 119 bool(true) 120 [2]=> 121 string(3) "any" 122 } 123 [8]=> 124 array(3) { 125 [0]=> 126 bool(true) 127 [1]=> 128 bool(true) 129 [2]=> 130 string(10) "ocsphelper" 131 } 132 [9]=> 133 array(3) { 134 [0]=> 135 bool(false) 136 [1]=> 137 bool(true) 138 [2]=> 139 string(13) "timestampsign" 140 } 141 } 142 ["extensions"]=> 143 array(3) { 144 ["subjectKeyIdentifier"]=> 145 string(59) "DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D" 146 ["authorityKeyIdentifier"]=> 147 string(202) "keyid:DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D 148DirName:/C=BR/ST=Rio Grande do Sul/L=Porto Alegre/CN=Henrique do N. Angelo/emailAddress=hnangelo@php.net 149serial:AE:C5:56:CC:72:37:50:A2 150" 151 ["basicConstraints"]=> 152 string(7) "CA:TRUE" 153 } 154} 155array(12) { 156 ["name"]=> 157 string(96) "/C=BR/ST=Rio Grande do Sul/L=Porto Alegre/CN=Henrique do N. Angelo/emailAddress=hnangelo@php.net" 158 ["subject"]=> 159 array(5) { 160 ["countryName"]=> 161 string(2) "BR" 162 ["stateOrProvinceName"]=> 163 string(17) "Rio Grande do Sul" 164 ["localityName"]=> 165 string(12) "Porto Alegre" 166 ["commonName"]=> 167 string(21) "Henrique do N. Angelo" 168 ["emailAddress"]=> 169 string(16) "hnangelo@php.net" 170 } 171 ["hash"]=> 172 string(8) "%s" 173 ["issuer"]=> 174 array(5) { 175 ["countryName"]=> 176 string(2) "BR" 177 ["stateOrProvinceName"]=> 178 string(17) "Rio Grande do Sul" 179 ["localityName"]=> 180 string(12) "Porto Alegre" 181 ["commonName"]=> 182 string(21) "Henrique do N. Angelo" 183 ["emailAddress"]=> 184 string(16) "hnangelo@php.net" 185 } 186 ["version"]=> 187 int(2) 188 ["serialNumber"]=> 189 string(20) "12593567369101004962" 190 ["validFrom"]=> 191 string(13) "080630102843Z" 192 ["validTo"]=> 193 string(13) "080730102843Z" 194 ["validFrom_time_t"]=> 195 int(1214821723) 196 ["validTo_time_t"]=> 197 int(1217413723) 198 ["purposes"]=> 199 array(9) { 200 [1]=> 201 array(3) { 202 [0]=> 203 bool(true) 204 [1]=> 205 bool(true) 206 [2]=> 207 string(10) "SSL client" 208 } 209 [2]=> 210 array(3) { 211 [0]=> 212 bool(true) 213 [1]=> 214 bool(true) 215 [2]=> 216 string(10) "SSL server" 217 } 218 [3]=> 219 array(3) { 220 [0]=> 221 bool(true) 222 [1]=> 223 bool(true) 224 [2]=> 225 string(19) "Netscape SSL server" 226 } 227 [4]=> 228 array(3) { 229 [0]=> 230 bool(true) 231 [1]=> 232 bool(true) 233 [2]=> 234 string(14) "S/MIME signing" 235 } 236 [5]=> 237 array(3) { 238 [0]=> 239 bool(true) 240 [1]=> 241 bool(true) 242 [2]=> 243 string(17) "S/MIME encryption" 244 } 245 [6]=> 246 array(3) { 247 [0]=> 248 bool(true) 249 [1]=> 250 bool(true) 251 [2]=> 252 string(11) "CRL signing" 253 } 254 [7]=> 255 array(3) { 256 [0]=> 257 bool(true) 258 [1]=> 259 bool(true) 260 [2]=> 261 string(11) "Any Purpose" 262 } 263 [8]=> 264 array(3) { 265 [0]=> 266 bool(true) 267 [1]=> 268 bool(true) 269 [2]=> 270 string(11) "OCSP helper" 271 } 272 [9]=> 273 array(3) { 274 [0]=> 275 bool(false) 276 [1]=> 277 bool(true) 278 [2]=> 279 string(18) "Time Stamp signing" 280 } 281 } 282 ["extensions"]=> 283 array(3) { 284 ["subjectKeyIdentifier"]=> 285 string(59) "DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D" 286 ["authorityKeyIdentifier"]=> 287 string(202) "keyid:DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D 288DirName:/C=BR/ST=Rio Grande do Sul/L=Porto Alegre/CN=Henrique do N. Angelo/emailAddress=hnangelo@php.net 289serial:AE:C5:56:CC:72:37:50:A2 290" 291 ["basicConstraints"]=> 292 string(7) "CA:TRUE" 293 } 294} 295