1--TEST--
2openssl_x509_read() tests
3--SKIPIF--
4<?php if (!extension_loaded("openssl")) print "skip"; ?>
5--FILE--
6<?php
7$fp = fopen(dirname(__FILE__) . "/cert.crt","r");
8$a = fread($fp,8192);
9fclose($fp);
10
11$b = "file://" . dirname(__FILE__) . "/cert.crt";
12$c = "invalid cert";
13$d = openssl_x509_read($a);
14$e = array();
15$f = array($b);
16
17var_dump(openssl_x509_read($a)); // read cert as a string
18var_dump(openssl_x509_read($b)); // read cert as a filename string
19var_dump(openssl_x509_read($c)); // read an invalid cert, fails
20var_dump(openssl_x509_read($d)); // read cert from a resource
21var_dump(openssl_x509_read($e)); // read an array
22var_dump(openssl_x509_read($f)); // read an array with the filename
23?>
24--EXPECTF--
25resource(%d) of type (OpenSSL X.509)
26resource(%d) of type (OpenSSL X.509)
27
28Warning: openssl_x509_read(): supplied parameter cannot be coerced into an X509 certificate! in %s on line %d
29bool(false)
30resource(%d) of type (OpenSSL X.509)
31
32Warning: openssl_x509_read(): supplied parameter cannot be coerced into an X509 certificate! in %s on line %d
33bool(false)
34
35Warning: openssl_x509_read(): supplied parameter cannot be coerced into an X509 certificate! in %s on line %d
36bool(false)
37