xref: /PHP-5.4/ext/openssl/tests/022.phpt (revision b638d302)
1--TEST--
2openssl_csr_export() tests
3--SKIPIF--
4<?php if (!extension_loaded("openssl")) print "skip"; ?>
5--FILE--
6<?php
7$wrong = "wrong";
8$config = __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf';
9$config_arg = array('config' => $config);
10
11$dn = array(
12	"countryName" => "BR",
13	"stateOrProvinceName" => "Rio Grande do Sul",
14	"localityName" => "Porto Alegre",
15	"commonName" => "Henrique do N. Angelo",
16	"emailAddress" => "hnangelo@php.net"
17	);
18
19$args = array(
20	"digest_alg" => "sha1",
21	"private_key_bits" => 2048,
22	"private_key_type" => OPENSSL_KEYTYPE_DSA,
23	"encrypt_key" => true,
24	"config" => $config,
25	);
26
27$privkey = openssl_pkey_new($config_arg);
28$csr = openssl_csr_new($dn, $privkey, $args);
29var_dump(openssl_csr_export($csr, $output));
30var_dump(openssl_csr_export($wrong, $output));
31var_dump(openssl_csr_export($privkey, $output));
32var_dump(openssl_csr_export(array(), $output));
33var_dump(openssl_csr_export($csr, $output, false));
34?>
35--EXPECTF--
36bool(true)
37
38Warning: openssl_csr_export() expects parameter 1 to be resource, string given in %s on line %d
39NULL
40
41Warning: openssl_csr_export(): supplied resource is not a valid OpenSSL X.509 CSR resource in %s on line %d
42
43Warning: openssl_csr_export(): cannot get CSR from parameter 1 in %s on line %d
44bool(false)
45
46Warning: openssl_csr_export() expects parameter 1 to be resource, array given in %s on line %d
47NULL
48bool(true)
49