--TEST-- openssl_csr_export_to_file() tests --SKIPIF-- --FILE-- $phex, 'g' => '2'); $dh = openssl_pkey_new(array( 'dh'=> array('p' => hex2bin($phex), 'g' => '2')) ); $dn = array( "countryName" => "BR", "stateOrProvinceName" => "Rio Grande do Sul", "localityName" => "Porto Alegre", "commonName" => "Henrique do N. Angelo", "emailAddress" => "hnangelo@php.net" ); $args = array( "digest_alg" => "sha1", "private_key_bits" => 2048, "private_key_type" => OPENSSL_KEYTYPE_DSA, "encrypt_key" => true, "config" => $config, ); $privkey_file = 'file://' . __DIR__ . '/private_rsa_2048.key'; $csr = openssl_csr_new($dn, $privkey_file, $args); var_dump(openssl_csr_export_to_file($csr, $csrfile)); var_dump(file_get_contents($csrfile)); var_dump(openssl_csr_export_to_file($wrong, $csrfile)); var_dump(openssl_csr_export_to_file($dh, $csrfile)); var_dump(openssl_csr_export_to_file(array(), $csrfile)); var_dump(openssl_csr_export_to_file($csr, $csrfile, false)); ?> --CLEAN-- --EXPECTF-- bool(true) string(1086) "-----BEGIN CERTIFICATE REQUEST----- MIIC6jCCAdICAQAwgaQxCzAJBgNVBAYTAkJSMRowGAYDVQQIExFSaW8gR3JhbmRl IGRvIFN1bDEVMBMGA1UEBxMMUG9ydG8gQWxlZ3JlMR4wHAYDVQQDExVIZW5yaXF1 ZSBkbyBOLiBBbmdlbG8xHzAdBgkqhkiG9w0BCQEWEGhuYW5nZWxvQHBocC5uZXQx ITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDCCASIwDQYJKoZIhvcN AQEBBQADggEPADCCAQoCggEBAK21JlVtWPqyc2UQtw2AdJHSIL5OzAHWsu/Mmxjz w4VZWwG+Ao1m2j7OJ8lAkxLfSlRtB+6Vx8Q21krAtve+M3b6pT9C9qKdfzNkrXk3 BggTncBh9ozkVQGS/P1m0zn/SKSgDO+6DdeLHLMjpUASaoYfsay4PJLAdnTqLOeM g6qNE6u0ebZXVfmpSmV1pSZ6kQnxbsb6rX1iOZxkwHnVWYb40Hy0EILo31x6BVqB m159m7s38ChiRHqlj20DmRfxXjiT5YDgYYQ29wQBTVQrTN5O9UW5Y+eKTXd8r6te dsbIBXdKN7NeX7ksGYHq1I3hLsP8EyvZO78qfjKyEB0Jj3UCAwEAAaAAMA0GCSqG SIb3DQEBBQUAA4IBAQCamzVmIbElkiDQKzQpkfU5tHjrWPrHDSB186NI0sQ8i6GQ 1YT6yPAXBPTQ1aER/6uAZJL5HfWEX8V1rKbe8GkPAPCHHQzmHyWlaO2EHS57zJhk sRrhqkhhkSNiDg4OrsguhRtbB2VMGeDbqHGI89uGqqGHUiZc/Bh8N7WFXZkUU/A0 sfBgVeqg0P4SWez5fHXqBNcjMdMI5f0bikcDZSIfTHS8FX+PMurLBC8UPB0YNIOl 1r2Lvo+6YUHOziG1OwQd3K0xxu/JzzOE+lMB73ynz4V6DY5Qv3qVno1GpupvgmQA JViHkCA9x6m8RJXAFvqmgLlWlUzbDv/cRrDfjWjR -----END CERTIFICATE REQUEST----- " Warning: openssl_csr_export_to_file() expects parameter 1 to be resource, string given in %s on line %d NULL Warning: openssl_csr_export_to_file(): supplied resource is not a valid OpenSSL X.509 CSR resource in %s on line %d Warning: openssl_csr_export_to_file(): cannot get CSR from parameter 1 in %s on line %d bool(false) Warning: openssl_csr_export_to_file() expects parameter 1 to be resource, array given in %s on line %d NULL bool(true)