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)); 30try { 31 var_dump(openssl_csr_export($wrong, $output)); 32} catch (TypeError $e) { 33 echo $e->getMessage(), "\n"; 34} 35try { 36 var_dump(openssl_csr_export($privkey, $output)); 37} catch (TypeError $e) { 38 echo $e->getMessage(), "\n"; 39} 40var_dump(openssl_csr_export($csr, $output, false)); 41?> 42--EXPECTF-- 43bool(true) 44 45Warning: openssl_csr_export(): X.509 Certificate Signing Request cannot be retrieved in %s on line %d 46bool(false) 47openssl_csr_export(): Argument #1 ($csr) must be of type OpenSSLCertificateSigningRequest|string, OpenSSLAsymmetricKey given 48bool(true) 49