com php-src: Rename and clean up OpenSSL tests: ext/openssl/tests/002.phpt ext/openssl/tests/003.phpt ext/openssl/tests/004.phpt
ext/openssl/tests/005.phpt ext/openssl/tests/005_crt. txt ext/openssl/tests/006.phpt ext/openssl/tests/ 007.phpt ext/openssl/tests/008.phpt ext/ope
nssl/tests/009.phpt ext/openssl/tests/011.php t ext/openssl/tests/012.phpt ext/openssl/tests/0 13.phpt ext/openssl/tests/014.phpt ext/openss
l/tests/015.phpt ext/openssl/tests/016

From: Date: Wed, 03 Feb 2016 16:20:27 +0000
Subject: com php-src: Rename and clean up OpenSSL tests: ext/openssl/tests/002.phpt ext/openssl/tests/003.phpt ext/openssl/tests/004.phpt
ext/openssl/tests/005.phpt ext/openssl/tests/005_crt. txt ext/openssl/tests/006.phpt ext/openssl/tests/ 007.phpt ext/openssl/tests/008.phpt ext/ope
nssl/tests/009.phpt ext/openssl/tests/011.php t ext/openssl/tests/012.phpt ext/openssl/tests/0 13.phpt ext/openssl/tests/014.phpt ext/openss
l/tests/015.phpt ext/openssl/tests/016
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-90935@lists.php.net to get a copy of this message
Commit: 1f3906c1ce24931fac60735c48bff3cfda760409 Author: Jakub Zelenka <bukka@php.net> Wed, 3 Feb 2016 16:20:27 +0000 Parents: e0332ea1a9d068c3bf0d2b82d8d8b0b06e632c9d Branches: PHP-5.6 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1f3906c1ce24931fac60735c48bff3cfda760409 Log: Rename and clean up OpenSSL tests Changed paths: D ext/openssl/tests/002.phpt D ext/openssl/tests/003..phpt D ext/openssl/tests/004.phpt D ext/openssl/tests/005.phpt D ext/openssl/tests/005_crt.txt D ext/openssl/tests/006.phpt D ext/openssl/tests/007.phpt D ext/openssl/tests/008.phpt D ext/openssl/tests/009.phpt D ext/openssl/tests/011.phpt D ext/openssl/tests/012.phpt D ext/openssl/tests/013.phpt D ext/openssl/tests/014.phpt D ext/openssl/tests/015.phpt D ext/openssl/tests/016.phpt D ext/openssl/tests/017.phpt D ext/openssl/tests/018.phpt D ext/openssl/tests/019.phpt D ext/openssl/tests/021.phpt D ext/openssl/tests/022.phpt D ext/openssl/tests/023.phpt D ext/openssl/tests/024.phpt D ext/openssl/tests/025.phpt D ext/openssl/tests/026.phpt D ext/openssl/tests/027.phpt D ext/openssl/tests/028.phpt A ext/openssl/tests/cert.csr A ext/openssl/tests/openssl_csr_export_bacis.phpt A ext/openssl/tests/openssl_csr_get_subject_basic.phpt A ext/openssl/tests/openssl_csr_new_basic.phpt A ext/openssl/tests/openssl_csr_sign_basic.phpt A ext/openssl/tests/openssl_decrypt_basic.phpt A ext/openssl/tests/openssl_open_basic.phpt D ext/openssl/tests/openssl_pbkdf2.phpt A ext/openssl/tests/openssl_pbkdf2_basic.phpt D ext/openssl/tests/openssl_peer_fingerprint.phpt A ext/openssl/tests/openssl_peer_fingerprint_basic.phpt A ext/openssl/tests/openssl_pkcs7_decrypt_basic.phpt A ext/openssl/tests/openssl_pkcs7_decrypt_error.phpt A ext/openssl/tests/openssl_pkcs7_encrypt_basic.phpt A ext/openssl/tests/openssl_pkcs7_sign_basic.phpt A ext/openssl/tests/openssl_pkey_export_basic.phpt A ext/openssl/tests/openssl_pkey_get_details_basic.phpt A ext/openssl/tests/openssl_pkey_new_basic.phpt A ext/openssl/tests/openssl_private_decrypt_basic.phpt A ext/openssl/tests/openssl_private_encrypt_basic.phpt A ext/openssl/tests/openssl_public_decrypt_basic.phpt A ext/openssl/tests/openssl_public_encrypt_basic..phpt D ext/openssl/tests/openssl_random_pseudo_bytes.phpt A ext/openssl/tests/openssl_random_pseudo_bytes_basic.phpt A ext/openssl/tests/openssl_seal_basic.phpt A ext/openssl/tests/openssl_sign_basic.phpt A ext/openssl/tests/openssl_verify_basic.phpt A ext/openssl/tests/openssl_x509_check_private_key_basic.phpt A ext/openssl/tests/openssl_x509_export_basic.phpt D ext/openssl/tests/openssl_x509_fingerprint.phpt A ext/openssl/tests/openssl_x509_fingerprint_basic.phpt D ext/openssl/tests/openssl_x509_parse_basic_v9.phpt A ext/openssl/tests/openssl_x509_parse_v9_basic.phpt A ext/openssl/tests/openssl_x509_read_basic.phpt

diff --git a/ext/openssl/tests/002.phpt b/ext/openssl/tests/002.phpt deleted file mode 100644 index dd4f04a..0000000 --- a/ext/openssl/tests/002.phpt +++ /dev/null @@ -1,32 +0,0 @@ ---TEST-- -openssl_seal() tests ---SKIPIF-- -<?php if (!extension_loaded("openssl")) print "skip"; ?> ---FILE-- -<?php - -$a = 1; -$b = array(1); -$c = array(1); -$d = array(1); - -var_dump(openssl_seal($a, $b, $c, $d)); -var_dump(openssl_seal($a, $a, $a, array())); -var_dump(openssl_seal($c, $c, $c, 1)); -var_dump(openssl_seal($b, $b, $b, "")); - -echo "Done\n"; -?> ---EXPECTF-- -Warning: openssl_seal(): not a public key (1th member of pubkeys) in %s on line %d -bool(false) - -Warning: openssl_seal(): Fourth argument to openssl_seal() must be a non-empty array in %s on line %d -bool(false) - -Warning: openssl_seal() expects parameter 1 to be string, array given in %s on line %d -NULL - -Warning: openssl_seal() expects parameter 1 to be string, array given in %s on line %d -NULL -Done diff --git a/ext/openssl/tests/003.phpt b/ext/openssl/tests/003.phpt deleted file mode 100644 index 92c8c85..0000000 --- a/ext/openssl/tests/003.phpt +++ /dev/null @@ -1,43 +0,0 @@ ---TEST-- -openssl_pkcs7_decrypt() and invalid parameters ---SKIPIF-- -<?php if (!extension_loaded("openssl")) print "skip"; ?> ---FILE-- -<?php - -function myErrorHandler($errno, $errstr, $errfile, $errline) { -var_dump($errstr); -} -set_error_handler("myErrorHandler"); - -$a = 1; -$b = 1; -$c = new stdclass; -$d = new stdclass; - -var_dump(openssl_pkcs7_decrypt($a, $b, $c, $d)); -var_dump($c); - -var_dump(openssl_pkcs7_decrypt($b, $b, $b, $b)); -var_dump(openssl_pkcs7_decrypt($a, $b, "", "")); -var_dump(openssl_pkcs7_decrypt($a, $b, true, false)); -var_dump(openssl_pkcs7_decrypt($a, $b, 0, 0)); - -echo "Done\n"; -?> ---EXPECTF-- -string(57) "Object of class stdClass could not be converted to string" -string(45) "Object of class stdClass to string conversion" -string(66) "openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert" -bool(false) -object(stdClass)#1 (0) { -} -string(66) "openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert" -bool(false) -string(66) "openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert" -bool(false) -string(66) "openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert" -bool(false) -string(66) "openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert" -bool(false) -Done diff --git a/ext/openssl/tests/004.phpt b/ext/openssl/tests/004.phpt deleted file mode 100644 index 508ccab..0000000 --- a/ext/openssl/tests/004.phpt +++ /dev/null @@ -1,34 +0,0 @@ ---TEST-- -openssl_csr_new() tests ---SKIPIF-- -<?php if (!extension_loaded("openssl")) print "skip"; ?> ---FILE-- -<?php - -$a = 1; -var_dump(openssl_csr_new(1,$a)); -var_dump(openssl_csr_new(1,$a,1,1)); -$a = array(); -var_dump(openssl_csr_new(array(), $a, array('config' => __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf'), array())); - -//this leaks -$a = array(1,2); -$b = array(1,2); -var_dump(openssl_csr_new($a, $b, array('config' => __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf'))); - - -echo "Done\n"; -?> ---EXPECTF-- -Warning: openssl_csr_new() expects parameter 1 to be array, integer given in %s on line %d -NULL - -Warning: openssl_csr_new() expects parameter 1 to be array, integer given in %s on line %d -NULL - -Warning: openssl_csr_new(): key array must be of the form array(0 => key, 1 => phrase) in %s on line %d - -Warning: openssl_csr_new(): add1_attr_by_txt challengePassword_min -> 4 (failed; check error queue and value of string_mask OpenSSL option if illegal characters are reported) in %s on line %d -bool(false) -resource(%d) of type (OpenSSL X.509 CSR) -Done diff --git a/ext/openssl/tests/005.phpt b/ext/openssl/tests/005.phpt deleted file mode 100644 index f7fa201..0000000 --- a/ext/openssl/tests/005.phpt +++ /dev/null @@ -1,34 +0,0 @@ ---TEST-- -openssl_csr_get_subject() tests ---SKIPIF-- -<?php -if (!extension_loaded("openssl")) die("skip"); -if (!function_exists("utf8_decode")) die("skip"); -?> ---FILE-- -<?php - -$csr = file_get_contents(dirname(__FILE__) . '/005_crt.txt'); -if ($out = openssl_csr_get_subject($csr, 1)) { - var_dump($out); -} -echo "\n"; -$cn = utf8_decode($out['CN']); -var_dump($cn); ---EXPECTF-- -array(6) { - ["C"]=> - string(2) "NL" - ["ST"]=> - string(13) "Noord Brabant" - ["L"]=> - string(4) "Uden" - ["O"]=> - string(10) "Triconnect" - ["OU"]=> - string(10) "Triconnect" - ["CN"]=> - string(15) "*.triconnect.nl" -} - -string(15) "*.triconnect.nl" diff --git a/ext/openssl/tests/005_crt.txt b/ext/openssl/tests/005_crt.txt deleted file mode 100644 index 39084bc..0000000 --- a/ext/openssl/tests/005_crt.txt +++ /dev/null @@ -1,22 +0,0 @@ ------BEGIN NEW CERTIFICATE REQUEST----- -MIIDYzCCAswCAQAwgYcxCzAJBgNVBAYTAk5MMRYwFAYDVQQIEw1Ob29yZCBCcmFi -YW50MQ0wCwYDVQQHEwRVZGVuMRMwEQYDVQQKEwpUcmljb25uZWN0MRMwEQYDVQQL -EwpUcmljb25uZWN0MScwJQYDVQQDHh4AKgAuAHQAcgBpAGMAbwBuAG4AZQBjAHQA -LgBuAGwwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANjE/qKAKgo93162HhtX -OZdvunF5eG/PFK2yn6uAUDWgZciPoKBslgL6a6sK+RdcS7LjWdjWEOOANGzZY1Kk -FelzxrIjIGSGJHC9eubebdu2LWFFM5cEMDiH0QSD9Rdiy7svSLWvngUDYj0wwd+m -iV2duzUFHnusj9iVPpD9s47RAgMBAAGgggGZMBoGCisGAQQBgjcNAgMxDBYKNS4y -LjM3OTAuMjB7BgorBgEEAYI3AgEOMW0wazAOBgNVHQ8BAf8EBAMCBPAwRAYJKoZI -hvcNAQkPBDcwNTAOBggqhkiG9w0DAgICAIAwDgYIKoZIhvcNAwQCAgCAMAcGBSsO -AwIHMAoGCCqGSIb3DQMHMBMGA1UdJQQMMAoGCCsGAQUFBwMBMIH9BgorBgEEAYI3 -DQICMYHuMIHrAgEBHloATQBpAGMAcgBvAHMAbwBmAHQAIABSAFMAQQAgAFMAQwBo -AGEAbgBuAGUAbAAgAEMAcgB5AHAAdABvAGcAcgBhAHAAaABpAGMAIABQAHIAbwB2 -AGkAZABlAHIDgYkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA -AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA -AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA -AAAAADANBgkqhkiG9w0BAQUFAAOBgQA4agiUkIblhF+n0wth4vQY+PwMadyaBpA4 -epr4TKL0QEkA0bQBbIERw5dDE3WQi6aVFJe6y870QymBwmKIvfBBfOyyA0IlQq/n -uybhzQNQbSMKF1T82hpfh1w2RwVGaGrw7f6qH+CLyP1ydvBPvmD88HwiibNBBB3c -R23mEEGYUQ== ------END NEW CERTIFICATE REQUEST----- - diff --git a/ext/openssl/tests/006.phpt b/ext/openssl/tests/006.phpt deleted file mode 100644 index d6e41e4..0000000 --- a/ext/openssl/tests/006.phpt +++ /dev/null @@ -1,25 +0,0 @@ ---TEST-- -openssl_pkey_new() with an empty sub-array arg generates a malformed resource ---SKIPIF-- -<?php if (!extension_loaded("openssl")) print "skip"; ?> ---FILE-- -<?php -/* openssl_pkey_get_details() segfaults when getting the information - from openssl_pkey_new() with an empty sub-array arg */ - -$rsa = array("rsa" => array()); -$dsa = array("dsa" => array()); -$dh = array("dh" => array()); - -openssl_pkey_get_details(openssl_pkey_new($rsa)); -openssl_pkey_get_details(openssl_pkey_new($dsa)); -openssl_pkey_get_details(openssl_pkey_new($dh)); -?> ---EXPECTF-- - -Warning: openssl_pkey_get_details() expects parameter 1 to be resource, boolean given in %s on line %d - -Warning: openssl_pkey_get_details() expects parameter 1 to be resource, boolean given in %s on line %d - -Warning: openssl_pkey_get_details() expects parameter 1 to be resource, boolean given in %s on line %d - diff --git a/ext/openssl/tests/007.phpt b/ext/openssl/tests/007.phpt deleted file mode 100644 index 0a74bd3..0000000 --- a/ext/openssl/tests/007.phpt +++ /dev/null @@ -1,60 +0,0 @@ ---TEST-- -openssl_x509_read() and openssl_x509_free() tests ---SKIPIF-- -<?php if (!extension_loaded("openssl")) print "skip"; ?> ---FILE-- -<?php -$fp = fopen(dirname(__FILE__) . "/cert.crt","r"); -$a = fread($fp,8192); -fclose($fp); - -$b = "file://" . dirname(__FILE__) . "/cert.crt"; -$c = "invalid cert"; -$d = openssl_x509_read($a); -$e = array(); -$f = array($b); - -var_dump($res = openssl_x509_read($a)); // read cert as a string -openssl_x509_free($res); -var_dump($res); -var_dump($res = openssl_x509_read($b)); // read cert as a filename string -openssl_x509_free($res); -var_dump($res); -var_dump($res = openssl_x509_read($c)); // read an invalid cert, fails -openssl_x509_free($res); -var_dump($res); -var_dump($res = openssl_x509_read($d)); // read cert from a resource -openssl_x509_free($res); -var_dump($res); -var_dump($res = openssl_x509_read($e)); // read an array -openssl_x509_free($res); -var_dump($res); -var_dump($res = openssl_x509_read($f)); // read an array with the filename -openssl_x509_free($res); -var_dump($res); -?> ---EXPECTF-- -resource(%d) of type (OpenSSL X.509) -resource(%d) of type (Unknown) -resource(%d) of type (OpenSSL X.509) -resource(%d) of type (Unknown) - -Warning: openssl_x509_read(): supplied parameter cannot be coerced into an X509 certificate! in %s on line %d -bool(false) - -Warning: openssl_x509_free() expects parameter 1 to be resource, boolean given in %s on line %d -bool(false) -resource(%d) of type (OpenSSL X.509) -resource(%d) of type (Unknown) - -Warning: openssl_x509_read(): supplied parameter cannot be coerced into an X509 certificate! in %s on line %d -bool(false) - -Warning: openssl_x509_free() expects parameter 1 to be resource, boolean given in %s on line %d -bool(false) - -Warning: openssl_x509_read(): supplied parameter cannot be coerced into an X509 certificate! in %s on line %d -bool(false) - -Warning: openssl_x509_free() expects parameter 1 to be resource, boolean given in %s on line %d -bool(false) diff --git a/ext/openssl/tests/008.phpt b/ext/openssl/tests/008.phpt deleted file mode 100644 index 8963864..0000000 --- a/ext/openssl/tests/008.phpt +++ /dev/null @@ -1,74 +0,0 @@ ---TEST-- -openssl_x509_export() and openssl_x509_export_to_file() tests ---SKIPIF-- -<?php if (!extension_loaded("openssl")) print "skip"; ?> ---FILE-- -<?php -$fp = fopen(dirname(__FILE__) . "/cert.crt","r"); -$a = fread($fp,8192); -fclose($fp); - -$b = "file://" . dirname(__FILE__) . "/cert.crt"; -$c = "invalid cert"; -$d = openssl_x509_read($a); -$e = array(); - -var_dump(openssl_x509_export($a, $output)); // read cert as a binary string -var_dump(openssl_x509_export($b, $output2)); // read cert from a filename string -var_dump(openssl_x509_export($c, $output3)); // read an invalid cert, fails -var_dump(openssl_x509_export($d, $output4)); // read cert from a resource -var_dump(openssl_x509_export($e, $output5)); // read an array, fails - -$outfilename = tempnam("/tmp", "ssl"); -if ($outfilename === false) - die("failed to get a temporary filename!"); - -echo "---\n"; - -var_dump(openssl_x509_export_to_file($a, $outfilename)); // read cert as a binary string -var_dump(openssl_x509_export_to_file($b, $outfilename)); // read cert from a filename string -var_dump(openssl_x509_export_to_file($c, $outfilename)); // read an invalid cert, fails -var_dump(openssl_x509_export_to_file($d, $outfilename)); // read cert from a resource -var_dump(openssl_x509_export_to_file($e, $outfilename)); // read an array, fails -echo "---\n"; - -var_dump($exists = file_exists($outfilename)); -if ($exists) { - @unlink($outfilename); -} -echo "---\n"; - -var_dump(strcmp($output, $a)); -var_dump(strcmp($output, $output2)); -var_dump(strcmp($output, $output3)); -var_dump(strcmp($output, $output4)); // different -var_dump(strcmp($output, $output5)); // different -?> ---EXPECTF-- -bool(true) -bool(true) - -Warning: openssl_x509_export(): cannot get cert from parameter 1 in %s on line %d -bool(false) -bool(true) - -Warning: openssl_x509_export(): cannot get cert from parameter 1 in %s on line %d -bool(false) ---- -bool(true) -bool(true) - -Warning: openssl_x509_export_to_file(): cannot get cert from parameter 1 in %s on line %d -bool(false) -bool(true) - -Warning: openssl_x509_export_to_file(): cannot get cert from parameter 1 in %s on line %d -bool(false) ---- -bool(true) ---- -int(0) -int(0) -int(%d) -int(0) -int(%d) diff --git a/ext/openssl/tests/009.phpt b/ext/openssl/tests/009.phpt deleted file mode 100644 index df18322..0000000 --- a/ext/openssl/tests/009.phpt +++ /dev/null @@ -1,29 +0,0 @@ ---TEST-- -openssl_x509_check_private_key() tests ---SKIPIF-- -<?php if (!extension_loaded("openssl")) print "skip"; ?> ---FILE-- -<?php -$fp = fopen(dirname(__FILE__) . "/cert.crt","r"); -$a = fread($fp,8192); -fclose($fp); - -$fp = fopen(dirname(__FILE__) . "/private_rsa_1024.key","r"); -$b = fread($fp,8192); -fclose($fp); - -$cert = "file://" . dirname(__FILE__) . "/cert.crt"; -$key = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; - -var_dump(openssl_x509_check_private_key($cert, $key)); -var_dump(openssl_x509_check_private_key("", $key)); -var_dump(openssl_x509_check_private_key($cert, "")); -var_dump(openssl_x509_check_private_key("", "")); -var_dump(openssl_x509_check_private_key($a, $b)); -?> ---EXPECT-- -bool(true) -bool(false) -bool(false) -bool(false) -bool(true) diff --git a/ext/openssl/tests/011.phpt b/ext/openssl/tests/011.phpt deleted file mode 100644 index 118e952..0000000 --- a/ext/openssl/tests/011.phpt +++ /dev/null @@ -1,31 +0,0 @@ ---TEST-- -openssl_encrypt() and openssl_decrypt() tests ---SKIPIF-- -<?php if (!extension_loaded("openssl")) print "skip"; ?> ---FILE-- -<?php -$data = "openssl_encrypt() and openssl_decrypt() tests"; -$method = "AES-128-CBC"; -$password = "openssl"; - -$ivlen = openssl_cipher_iv_length($method); -$iv = ''; -srand(time() + ((microtime(true) * 1000000) % 1000000)); -while(strlen($iv) < $ivlen) $iv .= chr(rand(0,255)); - -$encrypted = openssl_encrypt($data, $method, $password, 0, $iv); -$output = openssl_decrypt($encrypted, $method, $password, 0, $iv); -var_dump($output); -$encrypted = openssl_encrypt($data, $method, $password, OPENSSL_RAW_DATA, $iv); -$output = openssl_decrypt($encrypted, $method, $password, OPENSSL_RAW_DATA, $iv); -var_dump($output); -// if we want to manage our own padding -$padded_data = $data . str_repeat(' ', 16 - (strlen($data) % 16)); -$encrypted = openssl_encrypt($padded_data, $method, $password, OPENSSL_RAW_DATA|OPENSSL_ZERO_PADDING, $iv); -$output = openssl_decrypt($encrypted, $method, $password, OPENSSL_RAW_DATA|OPENSSL_ZERO_PADDING, $iv); -var_dump(rtrim($output)); -?> ---EXPECT-- -string(45) "openssl_encrypt() and openssl_decrypt() tests" -string(45) "openssl_encrypt() and openssl_decrypt() tests" -string(45) "openssl_encrypt() and openssl_decrypt() tests" diff --git a/ext/openssl/tests/012.phpt b/ext/openssl/tests/012.phpt deleted file mode 100644 index dbd03ac..0000000 --- a/ext/openssl/tests/012.phpt +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -openssl_seal() error tests ---SKIPIF-- -<?php if (!extension_loaded("openssl")) print "skip"; ?> ---FILE-- -<?php -$data = "openssl_open() test"; -$pub_key = "file://" . dirname(__FILE__) . "/public.key"; -$wrong = "wrong"; - -openssl_seal($data, $sealed, $ekeys, array($pub_key)); // no output -openssl_seal($data, $sealed, $ekeys, array($pub_key, $pub_key)); // no output -openssl_seal($data, $sealed, $ekeys, array($pub_key, $wrong)); -openssl_seal($data, $sealed, $ekeys, $pub_key); -openssl_seal($data, $sealed, $ekeys, array()); -openssl_seal($data, $sealed, $ekeys, array($wrong)); -?> ---EXPECTF-- - -Warning: openssl_seal(): not a public key (2th member of pubkeys) in %s on line %d - -Warning: openssl_seal() expects parameter 4 to be array, string given in %s on line %d - -Warning: openssl_seal(): Fourth argument to openssl_seal() must be a non-empty array in %s on line %d - -Warning: openssl_seal(): not a public key (1th member of pubkeys) in %s on line %d - diff --git a/ext/openssl/tests/013.phpt b/ext/openssl/tests/013.phpt deleted file mode 100644 index 55bb9eb..0000000 --- a/ext/openssl/tests/013.phpt +++ /dev/null @@ -1,28 +0,0 @@ ---TEST-- -openssl_open() tests ---SKIPIF-- -<?php if (!extension_loaded("openssl")) print "skip"; ?> ---FILE-- -<?php -$data = "openssl_open() test"; -$pub_key = "file://" . dirname(__FILE__) . "/public.key"; -$priv_key = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; -$wrong = "wrong"; - -openssl_seal($data, $sealed, $ekeys, array($pub_key, $pub_key, $pub_key)); -openssl_open($sealed, $output, $ekeys[0], $priv_key); -var_dump($output); -openssl_open($sealed, $output2, $ekeys[1], $wrong); -var_dump($output2); -openssl_open($sealed, $output3, $ekeys[2], $priv_key); -var_dump($output3); -openssl_open($sealed, $output4, $wrong, $priv_key); -var_dump($output4); -?> ---EXPECTF-- -string(19) "openssl_open() test" - -Warning: openssl_open(): unable to coerce parameter 4 into a private key in %s on line %d -NULL -string(19) "openssl_open() test" -NULL diff --git a/ext/openssl/tests/014.phpt b/ext/openssl/tests/014.phpt deleted file mode 100644 index 72ac154..0000000 --- a/ext/openssl/tests/014.phpt +++ /dev/null @@ -1,38 +0,0 @@ ---TEST-- -openssl_private_encrypt() tests ---SKIPIF-- -<?php if (!extension_loaded("openssl")) print "skip"; ?> ---FILE-- -<?php -$data = "Testing openssl_private_encrypt()"; -$privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; -$pubkey = "file://" . dirname(__FILE__) . "/public.key"; -$wrong = "wrong"; -class test { - function __toString() { - return "test"; - } -} -$obj = new test; - -var_dump(openssl_private_encrypt($data, $encrypted, $privkey)); -var_dump(openssl_private_encrypt($data, $encrypted, $pubkey)); -var_dump(openssl_private_encrypt($data, $encrypted, $wrong)); -var_dump(openssl_private_encrypt($data, $encrypted, $obj)); -var_dump(openssl_private_encrypt($obj, $encrypted, $privkey)); -openssl_public_decrypt($encrypted, $output, $pubkey); -var_dump($output); -?> ---EXPECTF-- -bool(true) - -Warning: openssl_private_encrypt(): key param is not a valid private key in %s on line %d -bool(false) - -Warning: openssl_private_encrypt(): key param is not a valid private key in %s on line %d -bool(false) - -Warning: openssl_private_encrypt(): key param is not a valid private key in %s on line %d -bool(false) -bool(true) -string(4) "test" diff --git a/ext/openssl/tests/015.phpt b/ext/openssl/tests/015.phpt deleted file mode 100644 index 7caa66f..0000000 --- a/ext/openssl/tests/015.phpt +++ /dev/null @@ -1,39 +0,0 @@ ---TEST-- -openssl_public_encrypt() tests ---SKIPIF-- -<?php if (!extension_loaded("openssl")) print "skip"; ?> ---FILE-- -<?php -$data = "Testing openssl_public_encrypt()"; -$privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; -$pubkey = "file://" . dirname(__FILE__) . "/public.key"; -$wrong = "wrong"; -class test { - function __toString() { - return "test"; - } -} -$obj = new test; - -var_dump(openssl_public_encrypt($data, $encrypted, $pubkey)); -var_dump(openssl_public_encrypt($data, $encrypted, $privkey)); -var_dump(openssl_public_encrypt($data, $encrypted, $wrong)); -var_dump(openssl_public_encrypt($data, $encrypted, $obj)); -var_dump(openssl_public_encrypt($obj, $encrypted, $pubkey)); -openssl_private_decrypt($encrypted, $output, $privkey); -var_dump($output); -?> ---EXPECTF-- -bool(true) - -Warning: openssl_public_encrypt(): key parameter is not a valid public key in %s on line %d -bool(false) - -Warning: openssl_public_encrypt(): key parameter is not a valid public key in %s on line %d -bool(false) - -Warning: openssl_public_encrypt(): key parameter is not a valid public key in %s on line %d -bool(false) -bool(true) -string(4) "test" - diff --git a/ext/openssl/tests/016.phpt b/ext/openssl/tests/016.phpt deleted file mode 100644 index 42d72b9..0000000 --- a/ext/openssl/tests/016.phpt +++ /dev/null @@ -1,48 +0,0 @@ ---TEST-- -openssl_public_decrypt() tests ---SKIPIF-- -<?php if (!extension_loaded("openssl")) print "skip"; ?> ---FILE-- -<?php -$data = "Testing openssl_public_decrypt()"; -$privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; -$pubkey = "file://" . dirname(__FILE__) . "/public.key"; -$wrong = "wrong"; - -openssl_private_encrypt($data, $encrypted, $privkey); -var_dump(openssl_public_decrypt($encrypted, $output, $pubkey)); -var_dump($output); -var_dump(openssl_public_decrypt($encrypted, $output2, $wrong)); -var_dump($output2); -var_dump(openssl_public_decrypt($wrong, $output3, $pubkey)); -var_dump($output3); -var_dump(openssl_public_decrypt($encrypted, $output4, array())); -var_dump($output4); -var_dump(openssl_public_decrypt($encrypted, $output5, array($pubkey))); -var_dump($output5); -var_dump(openssl_public_decrypt($encrypted, $output6, array($pubkey, ""))); -var_dump($output6); -?> ---EXPECTF-- -bool(true) -string(32) "Testing openssl_public_decrypt()" - -Warning: openssl_public_decrypt(): key parameter is not a valid public key in %s on line %d -bool(false) -NULL -bool(false) -NULL - -Warning: openssl_public_decrypt(): key array must be of the form array(0 => key, 1 => phrase) in %s on line %d - -Warning: openssl_public_decrypt(): key parameter is not a valid public key in %s on line %d -bool(false) -NULL - -Warning: openssl_public_decrypt(): key array must be of the form array(0 => key, 1 => phrase) in %s on line %d - -Warning: openssl_public_decrypt(): key parameter is not a valid public key in %s on line %d -bool(false) -NULL -bool(true) -string(32) "Testing openssl_public_decrypt()" diff --git a/ext/openssl/tests/017.phpt b/ext/openssl/tests/017.phpt deleted file mode 100644 index 76a08b8..0000000 --- a/ext/openssl/tests/017.phpt +++ /dev/null @@ -1,40 +0,0 @@ ---TEST-- -openssl_private_decrypt() tests ---SKIPIF-- -<?php if (!extension_loaded("openssl")) print "skip"; ?> ---FILE-- -<?php -$data = "Testing openssl_public_decrypt()"; -$privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; -$pubkey = "file://" . dirname(__FILE__) . "/public.key"; -$wrong = "wrong"; - -openssl_public_encrypt($data, $encrypted, $pubkey); -var_dump(openssl_private_decrypt($encrypted, $output, $privkey)); -var_dump($output); -var_dump(openssl_private_decrypt($encrypted, $output2, $wrong)); -var_dump($output2); -var_dump(openssl_private_decrypt($wrong, $output3, $privkey)); -var_dump($output3); -var_dump(openssl_private_decrypt($encrypted, $output4, array($privkey))); -var_dump($output4); -var_dump(openssl_private_decrypt($encrypted, $output5, array($privkey, ""))); -var_dump($output5); -?> ---EXPECTF-- -bool(true) -string(32) "Testing openssl_public_decrypt()" - -Warning: openssl_private_decrypt(): key parameter is not a valid private key in %s on line %d -bool(false) -NULL -bool(false) -NULL - -Warning: openssl_private_decrypt(): key array must be of the form array(0 => key, 1 => phrase) in %s on line %d - -Warning: openssl_private_decrypt(): key parameter is not a valid private key in %s on line %d -bool(false) -NULL -bool(true) -string(32) "Testing openssl_public_decrypt()" diff --git a/ext/openssl/tests/018.phpt b/ext/openssl/tests/018.phpt deleted file mode 100644 index 3d41ee1..0000000 --- a/ext/openssl/tests/018.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -openssl_sign() tests ---SKIPIF-- -<?php if (!extension_loaded("openssl")) print "skip"; ?> ---FILE-- -<?php -$data = "Testing openssl_sign()"; -$privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; -$wrong = "wrong"; - -var_dump(openssl_sign($data, $sign, $privkey)); // no output -var_dump(openssl_sign($data, $sign, $wrong)); -var_dump(openssl_sign(array(), $sign, $privkey)); -?> ---EXPECTF-- -bool(true) - -Warning: openssl_sign(): supplied key param cannot be coerced into a private key in %s on line %d -bool(false) - -Warning: openssl_sign() expects parameter 1 to be string, array given in %s on line %d -NULL diff --git a/ext/openssl/tests/019.phpt b/ext/openssl/tests/019.phpt deleted file mode 100644 index a21dfed..0000000 --- a/ext/openssl/tests/019.phpt +++ /dev/null @@ -1,28 +0,0 @@ ---TEST-- -openssl_verify() tests ---SKIPIF-- -<?php if (!extension_loaded("openssl")) print "skip"; ?> ---FILE-- -<?php -$data = "Testing openssl_verify()"; -$privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; -$pubkey = "file://" . dirname(__FILE__) . "/public.key"; -$wrong = "wrong"; - -openssl_sign($data, $sign, $privkey); -var_dump(openssl_verify($data, $sign, $pubkey)); -var_dump(openssl_verify($data, $sign, $privkey)); -var_dump(openssl_verify($data, $sign, $wrong)); -var_dump(openssl_verify($data, $wrong, $pubkey)); -var_dump(openssl_verify($wrong, $sign, $pubkey)); -?> ---EXPECTF-- -int(1) - -Warning: openssl_verify(): supplied key param cannot be coerced into a public key in %s on line %d -bool(false) - -Warning: openssl_verify(): supplied key param cannot be coerced into a public key in %s on line %d -bool(false) -int(0) -int(0) diff --git a/ext/openssl/tests/021.phpt b/ext/openssl/tests/021.phpt deleted file mode 100644 index ae948e3..0000000 --- a/ext/openssl/tests/021.phpt +++ /dev/null @@ -1,80 +0,0 @@ ---TEST-- -openssl_csr_sign() tests ---SKIPIF-- -<?php if (!extension_loaded("openssl")) print "skip"; ?> ---FILE-- -<?php -$cert = "file://" . dirname(__FILE__) . "/cert.crt"; -$priv = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; -$wrong = "wrong"; -$pub = "file://" . dirname(__FILE__) . "/public.key"; -$config = __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf'; -$config_arg = array('config' => $config); - -$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 = openssl_pkey_new($config_arg); -$csr = openssl_csr_new($dn, $privkey, $args); -var_dump(openssl_csr_sign($csr, null, $privkey, 365, $args)); -var_dump(openssl_csr_sign($csr, null, $privkey, 365, $config_arg)); -var_dump(openssl_csr_sign($csr, $cert, $priv, 365, $config_arg)); -var_dump(openssl_csr_sign($csr, $wrong, $privkey, 365)); -var_dump(openssl_csr_sign($csr, null, $wrong, 365)); -var_dump(openssl_csr_sign($csr, null, $privkey, $wrong)); -var_dump(openssl_csr_sign($csr, null, $privkey, 365, $wrong)); -var_dump(openssl_csr_sign($wrong, null, $privkey, 365)); -var_dump(openssl_csr_sign(array(), null, $privkey, 365)); -var_dump(openssl_csr_sign($csr, array(), $privkey, 365)); -var_dump(openssl_csr_sign($csr, null, array(), 365)); -var_dump(openssl_csr_sign($csr, null, $privkey, array())); -var_dump(openssl_csr_sign($csr, null, $privkey, 365, $config_arg)); -?> ---EXPECTF-- -resource(%d) of type (OpenSSL X.509) -resource(%d) of type (OpenSSL X.509) -resource(%d) of type (OpenSSL X.509) - -Warning: openssl_csr_sign(): cannot get cert from parameter 2 in %s on line %d -bool(false) - -Warning: openssl_csr_sign(): cannot get private key from parameter 3 in %s on line %d -bool(false) - -Warning: openssl_csr_sign() expects parameter 4 to be long, string given in %s on line %d -NULL - -Warning: openssl_csr_sign() expects parameter 5 to be array, string given in %s on line %d -NULL - -Warning: openssl_csr_sign(): cannot get CSR from parameter 1 in %s on line %d -bool(false) - -Warning: openssl_csr_sign(): cannot get CSR from parameter 1 in %s on line %d -bool(false) - -Warning: openssl_csr_sign(): cannot get cert from parameter 2 in %s on line %d -bool(false) - -Warning: openssl_csr_sign(): key array must be of the form array(0 => key, 1 => phrase) in %s on line %d - -Warning: openssl_csr_sign(): cannot get private key from parameter 3 in %s on line %d -bool(false) - -Warning: openssl_csr_sign() expects parameter 4 to be long, array given in %s on line %d -NULL -resource(%d) of type (OpenSSL X.509) - diff --git a/ext/openssl/tests/022.phpt b/ext/openssl/tests/022.phpt deleted file mode 100644 index 1fa84d9..0000000 --- a/ext/openssl/tests/022.phpt +++ /dev/null @@ -1,48 +0,0 @@ ---TEST-- -openssl_csr_export() tests ---SKIPIF-- -<?php if (!extension_loaded("openssl")) print "skip"; ?> ---FILE-- -<?php -$wrong = "wrong"; -$config = __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf'; -$config_arg = array('config' => $config); - -$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 = openssl_pkey_new($config_arg); -$csr = openssl_csr_new($dn, $privkey, $args); -var_dump(openssl_csr_export($csr, $output)); -var_dump(openssl_csr_export($wrong, $output)); -var_dump(openssl_csr_export($privkey, $output)); -var_dump(openssl_csr_export(array(), $output)); -var_dump(openssl_csr_export($csr, $output, false)); -?> ---EXPECTF-- -bool(true) - -Warning: openssl_csr_export() expects parameter 1 to be resource, string given in %s on line %d -NULL - -Warning: openssl_csr_export(): supplied resource is not a valid OpenSSL X.509 CSR resource in %s on line %d - -Warning: openssl_csr_export(): cannot get CSR from parameter 1 in %s on line %d -bool(false) - -Warning: openssl_csr_export() expects parameter 1 to be resource, array given in %s on line %d -NULL -bool(true) diff --git a/ext/openssl/tests/023.phpt b/ext/openssl/tests/023.phpt deleted file mode 100644 index 5f74f97..0000000 --- a/ext/openssl/tests/023.phpt +++ /dev/null @@ -1,64 +0,0 @@ ---TEST-- -openssl_pkcs7_encrypt() tests ---SKIPIF-- -<?php if (!extension_loaded("openssl")) print "skip"; ?> ---FILE-- -<?php -$infile = dirname(__FILE__) . "/cert.crt"; -$outfile = tempnam("/tmp", "ssl"); -if ($outfile === false) - die("failed to get a temporary filename!"); -$outfile2 = tempnam("/tmp", "ssl"); -if ($outfile2 === false) - die("failed to get a temporary filename!"); - -$single_cert = "file://" . dirname(__FILE__) . "/cert.crt"; -$privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; -$multi_certs = array($single_cert, $single_cert); -$assoc_headers = array("To" => "test@test", "Subject" => "testing openssl_pkcs7_encrypt()"); -$headers = array("test@test", "testing openssl_pkcs7_encrypt()"); -$empty_headers = array(); -$wrong = "wrong"; -$empty = ""; - -var_dump(openssl_pkcs7_encrypt($infile, $outfile, $single_cert, $headers)); -var_dump(openssl_pkcs7_decrypt($outfile, $outfile2, $single_cert, $privkey)); -var_dump(openssl_pkcs7_encrypt($infile, $outfile, $single_cert, $assoc_headers)); -var_dump(openssl_pkcs7_encrypt($infile, $outfile, $single_cert, $empty_headers)); -var_dump(openssl_pkcs7_encrypt($infile, $outfile, $single_cert, $wrong)); -var_dump(openssl_pkcs7_encrypt($wrong, $outfile, $single_cert, $headers)); -var_dump(openssl_pkcs7_encrypt($empty, $outfile, $single_cert, $headers)); -var_dump(openssl_pkcs7_encrypt($infile, $empty, $single_cert, $headers)); -var_dump(openssl_pkcs7_encrypt($infile, $outfile, $wrong, $headers)); -var_dump(openssl_pkcs7_encrypt($infile, $outfile, $empty, $headers)); -var_dump(openssl_pkcs7_encrypt($infile, $outfile, $single_cert, $empty)); -var_dump(openssl_pkcs7_encrypt($infile, $outfile, $multi_certs, $headers)); - -if (file_exists($outfile)) { - echo "true\n"; - unlink($outfile); -} -if (file_exists($outfile2)) { - echo "true\n"; - unlink($outfile2); -} -?> ---EXPECTF-- -bool(true) -bool(true) -bool(true) -bool(true) - -Warning: openssl_pkcs7_encrypt() expects parameter 4 to be array, string given in %s on line %d -bool(false) -bool(false) -bool(false) -bool(false) -bool(false) -bool(false) - -Warning: openssl_pkcs7_encrypt() expects parameter 4 to be array, string given in %s on line %d -bool(false) -bool(true) -true -true diff --git a/ext/openssl/tests/024.phpt b/ext/openssl/tests/024.phpt deleted file mode 100644 index 5589abb..0000000 --- a/ext/openssl/tests/024.phpt +++ /dev/null @@ -1,64 +0,0 @@ ---TEST-- -openssl_pkcs7_decrypt() tests ---SKIPIF-- -<?php if (!extension_loaded("openssl")) print "skip"; ?> ---FILE-- -<?php -$infile = dirname(__FILE__) . "/cert.crt"; -$privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; -$encrypted = tempnam("/tmp", "ssl"); -if ($encrypted === false) - die("failed to get a temporary filename!"); -$outfile = tempnam("/tmp", "ssl"); -if ($outfile === false) { - unlink($outfile); - die("failed to get a temporary filename!"); -} - -$single_cert = "file://" . dirname(__FILE__) . "/cert.crt"; -$headers = array("test@test", "testing openssl_pkcs7_encrypt()"); -$wrong = "wrong"; -$empty = ""; - -openssl_pkcs7_encrypt($infile, $encrypted, $single_cert, $headers); -var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $single_cert, $privkey)); -var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $single_cert, $wrong)); -var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $wrong, $privkey)); -var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, null, $privkey)); -var_dump(openssl_pkcs7_decrypt($wrong, $outfile, $single_cert, $privkey)); -var_dump(openssl_pkcs7_decrypt($empty, $outfile, $single_cert, $privkey)); -var_dump(openssl_pkcs7_decrypt($encrypted, $empty, $single_cert, $privkey)); -var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $empty, $privkey)); -var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $single_cert, $empty)); - -if (file_exists($encrypted)) { - echo "true\n"; - unlink($encrypted); -} -if (file_exists($outfile)) { - echo "true\n"; - unlink($outfile); -} -?> ---EXPECTF-- -bool(true) - -Warning: openssl_pkcs7_decrypt(): unable to get private key in %s on line %d -bool(false) - -Warning: openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert in %s on line %d -bool(false) - -Warning: openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert in %s on line %d -bool(false) -bool(false) -bool(false) -bool(false) - -Warning: openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert in %s on line %d -bool(false) - -Warning: openssl_pkcs7_decrypt(): unable to get private key in %s on line %d -bool(false) -true -true diff --git a/ext/openssl/tests/025.phpt b/ext/openssl/tests/025.phpt deleted file mode 100644 index 46c3926..0000000 --- a/ext/openssl/tests/025.phpt +++ /dev/null @@ -1,65 +0,0 @@ ---TEST-- -openssl_pkcs7_sign() tests ---SKIPIF-- -<?php if (!extension_loaded("openssl")) print "skip"; ?> ---FILE-- -<?php -$infile = dirname(__FILE__) . "/cert.crt"; -$outfile = tempnam("/tmp", "ssl"); -if ($outfile === false) - die("failed to get a temporary filename!"); - -$privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; -$single_cert = "file://" . dirname(__FILE__) . "/cert.crt"; -$assoc_headers = array("To" => "test@test", "Subject" => "testing openssl_pkcs7_sign()"); -$headers = array("test@test", "testing openssl_pkcs7_sign()"); -$empty_headers = array(); -$wrong = "wrong"; -$empty = ""; - -var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $headers)); -var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $assoc_headers)); -var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $empty_headers)); -var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $wrong)); -var_dump(openssl_pkcs7_sign($wrong, $outfile, $single_cert, $privkey, $headers)); -var_dump(openssl_pkcs7_sign($empty, $outfile, $single_cert, $privkey, $headers)); -var_dump(openssl_pkcs7_sign($infile, $empty, $single_cert, $privkey, $headers)); -var_dump(openssl_pkcs7_sign($infile, $outfile, $wrong, $privkey, $headers)); -var_dump(openssl_pkcs7_sign($infile, $outfile, $empty, $privkey, $headers)); -var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $empty)); -var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $wrong, $headers)); - -if (file_exists($outfile)) { - echo "true\n"; - unlink($outfile); -} -?> ---EXPECTF-- -bool(true) -bool(true) -bool(true) - -Warning: openssl_pkcs7_sign() expects parameter 5 to be array, string given in %s on line %d -NULL - -Warning: openssl_pkcs7_sign(): error opening input file %s in %s on line %d -bool(false) - -Warning: openssl_pkcs7_sign(): error opening input file %s in %s on line %d -bool(false) - -Warning: openssl_pkcs7_sign(): error opening output file %s in %s on line %d -bool(false) - -Warning: openssl_pkcs7_sign(): error getting cert in %s on line %d -bool(false) - -Warning: openssl_pkcs7_sign(): error getting cert in %s on line %d -bool(false) - -Warning: openssl_pkcs7_sign() expects parameter 5 to be array, string given in %s on line %d -NULL - -Warning: openssl_pkcs7_sign(): error getting private key in %s on line %d -bool(false) -true diff --git a/ext/openssl/tests/026.phpt b/ext/openssl/tests/026.phpt deleted file mode 100644 index 38d626d..0000000 --- a/ext/openssl/tests/026.phpt +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -Options type checks ---SKIPIF-- -<?php if (!extension_loaded("openssl")) print "skip"; ?> ---FILE-- -<?php -$x = openssl_pkey_new(); -$csr = openssl_csr_new(["countryName" => "DE"], $x, ["x509_extensions" => 0xDEADBEEF]); -?> -DONE ---EXPECT-- -DONE diff --git a/ext/openssl/tests/027.phpt b/ext/openssl/tests/027.phpt deleted file mode 100644 index 8311ab1..0000000 --- a/ext/openssl/tests/027.phpt +++ /dev/null @@ -1,52 +0,0 @@ ---TEST-- -openssl_pkey_export() with EC key ---SKIPIF-- -<?php -if (!extension_loaded("openssl")) die("skip"); -if (!defined('OPENSSL_KEYTYPE_EC')) die("skip no EC available"); -?> ---FILE-- -<?php -$key = openssl_pkey_get_private('file://' . dirname(__FILE__) . '/private_ec.key'); -var_dump($key); - -var_dump(openssl_pkey_export($key, $output)); -echo $output; - -// Load the private key from the exported pem string -$details = openssl_pkey_get_details(openssl_pkey_get_private($output)); -var_dump(OPENSSL_KEYTYPE_EC === $details['type']); - -// Export key with passphrase -openssl_pkey_export($key, $output, 'passphrase'); - -$details = openssl_pkey_get_details(openssl_pkey_get_private($output, 'passphrase')); -var_dump(OPENSSL_KEYTYPE_EC === $details['type']); - -// Read public key -$pKey = openssl_pkey_get_public('file://' . dirname(__FILE__) . '/public_ec.key'); -var_dump($pKey); -// The details are the same for a public or private key -var_dump($details === openssl_pkey_get_details($pKey)); - - -// Export to file -$tempname = tempnam(sys_get_temp_dir(), 'openssl_ec'); -var_dump(openssl_pkey_export_to_file($key, $tempname)); -$details = openssl_pkey_get_details(openssl_pkey_get_private('file://' . $tempname)); -var_dump(OPENSSL_KEYTYPE_EC === $details['type']); - -// Clean the temporary file -@unlink($tempname); - -?> ---EXPECTF-- -resource(%d) of type (OpenSSL key) -bool(true) ------BEGIN EC PRIVATE KEY-----%a-----END EC PRIVATE KEY----- -bool(true) -bool(true) -resource(%d) of type (OpenSSL key) -bool(true) -bool(true) -bool(true) diff --git a/ext/openssl/tests/028.phpt b/ext/openssl/tests/028.phpt deleted file mode 100644 index 8e0cef4..0000000 --- a/ext/openssl/tests/028.phpt +++ /dev/null @@ -1,28 +0,0 @@ ---TEST-- -openssl_pkey_get_details() with EC key ---SKIPIF-- -<?php -if (!extension_loaded("openssl")) die("skip"); -if (!defined('OPENSSL_KEYTYPE_EC')) die("skip no EC available"); -?> ---FILE-- -<?php -$key = openssl_pkey_get_private('file://' . dirname(__FILE__) . '/private_ec.key'); - -print_r(openssl_pkey_get_details($key)); -?> ---EXPECTF-- -Array -( - [bits] => 256 - [key] => -----BEGIN PUBLIC KEY-----%a ------END PUBLIC KEY----- - - [ec] => Array - ( - [curve_name] => prime256v1 - [curve_oid] => 1.2.840.10045.3.1.7 - ) - - [type] => 3 -) diff --git a/ext/openssl/tests/cert.csr b/ext/openssl/tests/cert.csr new file mode 100644 index 0000000..39084bc --- /dev/null +++ b/ext/openssl/tests/cert.csr @@ -0,0 +1,22 @@ +-----BEGIN NEW CERTIFICATE REQUEST----- +MIIDYzCCAswCAQAwgYcxCzAJBgNVBAYTAk5MMRYwFAYDVQQIEw1Ob29yZCBCcmFi +YW50MQ0wCwYDVQQHEwRVZGVuMRMwEQYDVQQKEwpUcmljb25uZWN0MRMwEQYDVQQL +EwpUcmljb25uZWN0MScwJQYDVQQDHh4AKgAuAHQAcgBpAGMAbwBuAG4AZQBjAHQA +LgBuAGwwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANjE/qKAKgo93162HhtX +OZdvunF5eG/PFK2yn6uAUDWgZciPoKBslgL6a6sK+RdcS7LjWdjWEOOANGzZY1Kk +FelzxrIjIGSGJHC9eubebdu2LWFFM5cEMDiH0QSD9Rdiy7svSLWvngUDYj0wwd+m +iV2duzUFHnusj9iVPpD9s47RAgMBAAGgggGZMBoGCisGAQQBgjcNAgMxDBYKNS4y +LjM3OTAuMjB7BgorBgEEAYI3AgEOMW0wazAOBgNVHQ8BAf8EBAMCBPAwRAYJKoZI +hvcNAQkPBDcwNTAOBggqhkiG9w0DAgICAIAwDgYIKoZIhvcNAwQCAgCAMAcGBSsO +AwIHMAoGCCqGSIb3DQMHMBMGA1UdJQQMMAoGCCsGAQUFBwMBMIH9BgorBgEEAYI3 +DQICMYHuMIHrAgEBHloATQBpAGMAcgBvAHMAbwBmAHQAIABSAFMAQQAgAFMAQwBo +AGEAbgBuAGUAbAAgAEMAcgB5AHAAdABvAGcAcgBhAHAAaABpAGMAIABQAHIAbwB2 +AGkAZABlAHIDgYkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAADANBgkqhkiG9w0BAQUFAAOBgQA4agiUkIblhF+n0wth4vQY+PwMadyaBpA4 +epr4TKL0QEkA0bQBbIERw5dDE3WQi6aVFJe6y870QymBwmKIvfBBfOyyA0IlQq/n +uybhzQNQbSMKF1T82hpfh1w2RwVGaGrw7f6qH+CLyP1ydvBPvmD88HwiibNBBB3c +R23mEEGYUQ== +-----END NEW CERTIFICATE REQUEST----- + diff --git a/ext/openssl/tests/openssl_csr_export_bacis.phpt b/ext/openssl/tests/openssl_csr_export_bacis.phpt new file mode 100644 index 0000000..d3f8842 --- /dev/null +++ b/ext/openssl/tests/openssl_csr_export_bacis.phpt @@ -0,0 +1,48 @@ +--TEST-- +openssl_csr_export() tests +--SKIPIF-- +<?php if (!extension_loaded("openssl")) print "skip"; ?> +--FILE-- +<?php +$wrong = "wrong"; +$config = __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf'; +$config_arg = array('config' => $config); + +$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 = openssl_pkey_new($config_arg); +$csr = openssl_csr_new($dn, $privkey, $args); +var_dump(openssl_csr_export($csr, $output)); +var_dump(openssl_csr_export($wrong, $output)); +var_dump(openssl_csr_export($privkey, $output)); +var_dump(openssl_csr_export(array(), $output)); +var_dump(openssl_csr_export($csr, $output, false)); +?> +--EXPECTF-- +bool(true) + +Warning: openssl_csr_export() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Warning: openssl_csr_export(): supplied resource is not a valid OpenSSL X.509 CSR resource in %s on line %d + +Warning: openssl_csr_export(): cannot get CSR from parameter 1 in %s on line %d +bool(false) + +Warning: openssl_csr_export() expects parameter 1 to be resource, array given in %s on line %d +NULL +bool(true) diff --git a/ext/openssl/tests/openssl_csr_get_subject_basic.phpt b/ext/openssl/tests/openssl_csr_get_subject_basic.phpt new file mode 100644 index 0000000..895ed36 --- /dev/null +++ b/ext/openssl/tests/openssl_csr_get_subject_basic.phpt @@ -0,0 +1,34 @@ +--TEST-- +openssl_csr_get_subject() tests +--SKIPIF-- +<?php +if (!extension_loaded("openssl")) die("skip"); +if (!function_exists("utf8_decode")) die("skip"); +?> +--FILE-- +<?php + +$csr = file_get_contents(dirname(__FILE__) . '/cert.csr'); +if ($out = openssl_csr_get_subject($csr, 1)) { + var_dump($out); +} +echo "\n"; +$cn = utf8_decode($out['CN']); +var_dump($cn); +--EXPECTF-- +array(6) { + ["C"]=> + string(2) "NL" + ["ST"]=> + string(13) "Noord Brabant" + ["L"]=> + string(4) "Uden" + ["O"]=> + string(10) "Triconnect" + ["OU"]=> + string(10) "Triconnect" + ["CN"]=> + string(15) "*.triconnect.nl" +} + +string(15) "*.triconnect.nl" diff --git a/ext/openssl/tests/openssl_csr_new_basic.phpt b/ext/openssl/tests/openssl_csr_new_basic.phpt new file mode 100644 index 0000000..a3a4746 --- /dev/null +++ b/ext/openssl/tests/openssl_csr_new_basic.phpt @@ -0,0 +1,39 @@ +--TEST-- +openssl_csr_new() tests +--SKIPIF-- +<?php if (!extension_loaded("openssl")) print "skip"; ?> +--FILE-- +<?php + +$a = 1; +var_dump(openssl_csr_new(1,$a)); +var_dump(openssl_csr_new(1,$a,1,1)); +$a = array(); +var_dump(openssl_csr_new(array(), $a, array('config' => __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf'), array())); + +// this leaks +$a = array(1,2); +$b = array(1,2); +var_dump(openssl_csr_new($a, $b, array('config' => __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf'))); + +// options type check +$x = openssl_pkey_new(); +var_dump(openssl_csr_new(["countryName" => "DE"], $x, ["x509_extensions" => 0xDEADBEEF])); + + +echo "Done\n"; +?> +--EXPECTF-- +Warning: openssl_csr_new() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: openssl_csr_new() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: openssl_csr_new(): key array must be of the form array(0 => key, 1 => phrase) in %s on line %d + +Warning: openssl_csr_new(): add1_attr_by_txt challengePassword_min -> 4 (failed; check error queue and value of string_mask OpenSSL option if illegal characters are reported) in %s on line %d +bool(false) +resource(%d) of type (OpenSSL X.509 CSR) +resource(%d) of type (OpenSSL X.509 CSR) +Done diff --git a/ext/openssl/tests/openssl_csr_sign_basic.phpt b/ext/openssl/tests/openssl_csr_sign_basic.phpt new file mode 100644 index 0000000..ae948e3 --- /dev/null +++ b/ext/openssl/tests/openssl_csr_sign_basic.phpt @@ -0,0 +1,80 @@ +--TEST-- +openssl_csr_sign() tests +--SKIPIF-- +<?php if (!extension_loaded("openssl")) print "skip"; ?> +--FILE-- +<?php +$cert = "file://" . dirname(__FILE__) . "/cert.crt"; +$priv = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; +$wrong = "wrong"; +$pub = "file://" . dirname(__FILE__) . "/public.key"; +$config = __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf'; +$config_arg = array('config' => $config); + +$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 = openssl_pkey_new($config_arg); +$csr = openssl_csr_new($dn, $privkey, $args); +var_dump(openssl_csr_sign($csr, null, $privkey, 365, $args)); +var_dump(openssl_csr_sign($csr, null, $privkey, 365, $config_arg)); +var_dump(openssl_csr_sign($csr, $cert, $priv, 365, $config_arg)); +var_dump(openssl_csr_sign($csr, $wrong, $privkey, 365)); +var_dump(openssl_csr_sign($csr, null, $wrong, 365)); +var_dump(openssl_csr_sign($csr, null, $privkey, $wrong)); +var_dump(openssl_csr_sign($csr, null, $privkey, 365, $wrong)); +var_dump(openssl_csr_sign($wrong, null, $privkey, 365)); +var_dump(openssl_csr_sign(array(), null, $privkey, 365)); +var_dump(openssl_csr_sign($csr, array(), $privkey, 365)); +var_dump(openssl_csr_sign($csr, null, array(), 365)); +var_dump(openssl_csr_sign($csr, null, $privkey, array())); +var_dump(openssl_csr_sign($csr, null, $privkey, 365, $config_arg)); +?> +--EXPECTF-- +resource(%d) of type (OpenSSL X.509) +resource(%d) of type (OpenSSL X.509) +resource(%d) of type (OpenSSL X.509) + +Warning: openssl_csr_sign(): cannot get cert from parameter 2 in %s on line %d +bool(false) + +Warning: openssl_csr_sign(): cannot get private key from parameter 3 in %s on line %d +bool(false) + +Warning: openssl_csr_sign() expects parameter 4 to be long, string given in %s on line %d +NULL + +Warning: openssl_csr_sign() expects parameter 5 to be array, string given in %s on line %d +NULL + +Warning: openssl_csr_sign(): cannot get CSR from parameter 1 in %s on line %d +bool(false) + +Warning: openssl_csr_sign(): cannot get CSR from parameter 1 in %s on line %d +bool(false) + +Warning: openssl_csr_sign(): cannot get cert from parameter 2 in %s on line %d +bool(false) + +Warning: openssl_csr_sign(): key array must be of the form array(0 => key, 1 => phrase) in %s on line %d + +Warning: openssl_csr_sign(): cannot get private key from parameter 3 in %s on line %d +bool(false) + +Warning: openssl_csr_sign() expects parameter 4 to be long, array given in %s on line %d +NULL +resource(%d) of type (OpenSSL X.509) + diff --git a/ext/openssl/tests/openssl_decrypt_basic.phpt b/ext/openssl/tests/openssl_decrypt_basic.phpt new file mode 100644 index 0000000..1c29767 --- /dev/null +++ b/ext/openssl/tests/openssl_decrypt_basic.phpt @@ -0,0 +1,31 @@ +--TEST-- +openssl_decrypt() tests dependent on openssl_encrypt +--SKIPIF-- +<?php if (!extension_loaded("openssl")) print "skip"; ?> +--FILE-- +<?php +$data = "openssl_encrypt() and openssl_decrypt() tests"; +$method = "AES-128-CBC"; +$password = "openssl"; + +$ivlen = openssl_cipher_iv_length($method); +$iv = ''; +srand(time() + ((microtime(true) * 1000000) % 1000000)); +while(strlen($iv) < $ivlen) $iv .= chr(rand(0,255)); + +$encrypted = openssl_encrypt($data, $method, $password, 0, $iv); +$output = openssl_decrypt($encrypted, $method, $password, 0, $iv); +var_dump($output); +$encrypted = openssl_encrypt($data, $method, $password, OPENSSL_RAW_DATA, $iv); +$output = openssl_decrypt($encrypted, $method, $password, OPENSSL_RAW_DATA, $iv); +var_dump($output); +// if we want to manage our own padding +$padded_data = $data . str_repeat(' ', 16 - (strlen($data) % 16)); +$encrypted = openssl_encrypt($padded_data, $method, $password, OPENSSL_RAW_DATA|OPENSSL_ZERO_PADDING, $iv); +$output = openssl_decrypt($encrypted, $method, $password, OPENSSL_RAW_DATA|OPENSSL_ZERO_PADDING, $iv); +var_dump(rtrim($output)); +?> +--EXPECT-- +string(45) "openssl_encrypt() and openssl_decrypt() tests" +string(45) "openssl_encrypt() and openssl_decrypt() tests" +string(45) "openssl_encrypt() and openssl_decrypt() tests" diff --git a/ext/openssl/tests/openssl_open_basic.phpt b/ext/openssl/tests/openssl_open_basic.phpt new file mode 100644 index 0000000..55bb9eb --- /dev/null +++ b/ext/openssl/tests/openssl_open_basic.phpt @@ -0,0 +1,28 @@ +--TEST-- +openssl_open() tests +--SKIPIF-- +<?php if (!extension_loaded("openssl")) print "skip"; ?> +--FILE-- +<?php +$data = "openssl_open() test"; +$pub_key = "file://" . dirname(__FILE__) . "/public.key"; +$priv_key = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; +$wrong = "wrong"; + +openssl_seal($data, $sealed, $ekeys, array($pub_key, $pub_key, $pub_key)); +openssl_open($sealed, $output, $ekeys[0], $priv_key); +var_dump($output); +openssl_open($sealed, $output2, $ekeys[1], $wrong); +var_dump($output2); +openssl_open($sealed, $output3, $ekeys[2], $priv_key); +var_dump($output3); +openssl_open($sealed, $output4, $wrong, $priv_key); +var_dump($output4); +?> +--EXPECTF-- +string(19) "openssl_open() test" + +Warning: openssl_open(): unable to coerce parameter 4 into a private key in %s on line %d +NULL +string(19) "openssl_open() test" +NULL diff --git a/ext/openssl/tests/openssl_pbkdf2.phpt b/ext/openssl/tests/openssl_pbkdf2.phpt deleted file mode 100644 index 3ec4dce..0000000 --- a/ext/openssl/tests/openssl_pbkdf2.phpt +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -openssl_pbkdf2() tests ---SKIPIF-- -<?php if (!extension_loaded("openssl") || !function_exists("openssl_pbkdf2")) print "skip"; ?> ---FILE-- -<?php -// official test vectors -var_dump(bin2hex(openssl_pbkdf2('password', 'salt', 20, 1))); -var_dump(bin2hex(openssl_pbkdf2('password', 'salt', 20, 2))); -var_dump(bin2hex(openssl_pbkdf2('password', 'salt', 20, 4096))); - -/* really slow but should be: -string(40) "eefe3d61cd4da4e4e9945b3d6ba2158c2634e984" -var_dump(bin2hex(openssl_pbkdf2('password', 'salt', 20, 16777216))); -*/ - -var_dump(bin2hex(openssl_pbkdf2('passwordPASSWORDpassword', 'saltSALTsaltSALTsaltSALTsaltSALTsalt', 25, 4096))); -var_dump(bin2hex(openssl_pbkdf2("pass\0word", "sa\0lt", 16, 4096))); - -?> ---EXPECTF-- -string(40) "0c60c80f961f0e71f3a9b524af6012062fe037a6" -string(40) "ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957" -string(40) "4b007901b765489abead49d926f721d065a429c1" -string(50) "3d2eec4fe41c849b80c8d83662c0e44a8b291a964cf2f07038" -string(32) "56fa6aa75548099dcc37d7f03425e0c3" diff --git a/ext/openssl/tests/openssl_pbkdf2_basic.phpt b/ext/openssl/tests/openssl_pbkdf2_basic.phpt new file mode 100644 index 0000000..3ec4dce --- /dev/null +++ b/ext/openssl/tests/openssl_pbkdf2_basic.phpt @@ -0,0 +1,26 @@ +--TEST-- +openssl_pbkdf2() tests +--SKIPIF-- +<?php if (!extension_loaded("openssl") || !function_exists("openssl_pbkdf2")) print "skip"; ?> +--FILE-- +<?php +// official test vectors +var_dump(bin2hex(openssl_pbkdf2('password', 'salt', 20, 1))); +var_dump(bin2hex(openssl_pbkdf2('password', 'salt', 20, 2))); +var_dump(bin2hex(openssl_pbkdf2('password', 'salt', 20, 4096))); + +/* really slow but should be: +string(40) "eefe3d61cd4da4e4e9945b3d6ba2158c2634e984" +var_dump(bin2hex(openssl_pbkdf2('password', 'salt', 20, 16777216))); +*/ + +var_dump(bin2hex(openssl_pbkdf2('passwordPASSWORDpassword', 'saltSALTsaltSALTsaltSALTsaltSALTsalt', 25, 4096))); +var_dump(bin2hex(openssl_pbkdf2("pass\0word", "sa\0lt", 16, 4096))); + +?> +--EXPECTF-- +string(40) "0c60c80f961f0e71f3a9b524af6012062fe037a6" +string(40) "ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957" +string(40) "4b007901b765489abead49d926f721d065a429c1" +string(50) "3d2eec4fe41c849b80c8d83662c0e44a8b291a964cf2f07038" +string(32) "56fa6aa75548099dcc37d7f03425e0c3" diff --git a/ext/openssl/tests/openssl_peer_fingerprint.phpt b/ext/openssl/tests/openssl_peer_fingerprint.phpt deleted file mode 100644 index 7432335..0000000 --- a/ext/openssl/tests/openssl_peer_fingerprint.phpt +++ /dev/null @@ -1,54 +0,0 @@ ---TEST-- -Testing peer fingerprint on connection ---SKIPIF-- -<?php -if (!extension_loaded("openssl")) die("skip openssl not loaded"); -if (!function_exists("proc_open")) die("skip no proc_open"); ---FILE-- -<?php -$serverCode = <<<'CODE' - $serverUri = "ssl://127.0.0.1:64321"; - $serverFlags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN; - $serverCtx = stream_context_create(['ssl' => [ - 'local_cert' => __DIR__ . '/bug54992.pem' - ]]); - - $server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx); - phpt_notify(); - - @stream_socket_accept($server, 1); - @stream_socket_accept($server, 1); -CODE; - -$clientCode = <<<'CODE' - $serverUri = "ssl://127.0.0.1:64321"; - $clientFlags = STREAM_CLIENT_CONNECT; - $clientCtx = stream_context_create(['ssl' => [ - 'verify_peer' => true, - 'cafile' => __DIR__ . '/bug54992-ca.pem', - 'capture_peer_cert' => true, - 'peer_name' => 'bug54992.local', - ]]); - - phpt_wait(); - - // should be: 81cafc260aa8d82956ebc6212a362ecc - stream_context_set_option($clientCtx, 'ssl', 'peer_fingerprint', '81cafc260aa8d82956ebc6212a362ece'); - var_dump(stream_socket_client($serverUri, $errno, $errstr, 2, $clientFlags, $clientCtx)); - - stream_context_set_option($clientCtx, 'ssl', 'peer_fingerprint', [ - 'sha256' => '78ea579f2c3b439359dec5dac9d445108772927427c4780037e87df3799a0aa0', - ]); - var_dump(stream_socket_client($serverUri, $errno, $errstr, 2, $clientFlags, $clientCtx)); -CODE; - -include 'ServerClientTestCase.inc'; -ServerClientTestCase::getInstance()->run($clientCode, $serverCode); ---EXPECTF-- -Warning: stream_socket_client(): peer_fingerprint match failure in %s on line %d - -Warning: stream_socket_client(): Failed to enable crypto in %s on line %d - -Warning: stream_socket_client(): unable to connect to ssl://127.0.0.1:64321 (Unknown error) in %s on line %d -bool(false) -resource(%d) of type (stream) diff --git a/ext/openssl/tests/openssl_peer_fingerprint_basic.phpt b/ext/openssl/tests/openssl_peer_fingerprint_basic.phpt new file mode 100644 index 0000000..7432335 --- /dev/null +++ b/ext/openssl/tests/openssl_peer_fingerprint_basic.phpt @@ -0,0 +1,54 @@ +--TEST-- +Testing peer fingerprint on connection +--SKIPIF-- +<?php +if (!extension_loaded("openssl")) die("skip openssl not loaded"); +if (!function_exists("proc_open")) die("skip no proc_open"); +--FILE-- +<?php +$serverCode = <<<'CODE' + $serverUri = "ssl://127.0.0.1:64321"; + $serverFlags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN; + $serverCtx = stream_context_create(['ssl' => [ + 'local_cert' => __DIR__ . '/bug54992.pem' + ]]); + + $server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx); + phpt_notify(); + + @stream_socket_accept($server, 1); + @stream_socket_accept($server, 1); +CODE; + +$clientCode = <<<'CODE' + $serverUri = "ssl://127.0.0.1:64321"; + $clientFlags = STREAM_CLIENT_CONNECT; + $clientCtx = stream_context_create(['ssl' => [ + 'verify_peer' => true, + 'cafile' => __DIR__ . '/bug54992-ca.pem', + 'capture_peer_cert' => true, + 'peer_name' => 'bug54992.local', + ]]); + + phpt_wait(); + + // should be: 81cafc260aa8d82956ebc6212a362ecc + stream_context_set_option($clientCtx, 'ssl', 'peer_fingerprint', '81cafc260aa8d82956ebc6212a362ece'); + var_dump(stream_socket_client($serverUri, $errno, $errstr, 2, $clientFlags, $clientCtx)); + + stream_context_set_option($clientCtx, 'ssl', 'peer_fingerprint', [ + 'sha256' => '78ea579f2c3b439359dec5dac9d445108772927427c4780037e87df3799a0aa0', + ]); + var_dump(stream_socket_client($serverUri, $errno, $errstr, 2, $clientFlags, $clientCtx)); +CODE; + +include 'ServerClientTestCase.inc'; +ServerClientTestCase::getInstance()->run($clientCode, $serverCode); +--EXPECTF-- +Warning: stream_socket_client(): peer_fingerprint match failure in %s on line %d + +Warning: stream_socket_client(): Failed to enable crypto in %s on line %d + +Warning: stream_socket_client(): unable to connect to ssl://127.0.0.1:64321 (Unknown error) in %s on line %d +bool(false) +resource(%d) of type (stream) diff --git a/ext/openssl/tests/openssl_pkcs7_decrypt_basic.phpt b/ext/openssl/tests/openssl_pkcs7_decrypt_basic.phpt new file mode 100644 index 0000000..5589abb --- /dev/null +++ b/ext/openssl/tests/openssl_pkcs7_decrypt_basic.phpt @@ -0,0 +1,64 @@ +--TEST-- +openssl_pkcs7_decrypt() tests +--SKIPIF-- +<?php if (!extension_loaded("openssl")) print "skip"; ?> +--FILE-- +<?php +$infile = dirname(__FILE__) . "/cert.crt"; +$privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; +$encrypted = tempnam("/tmp", "ssl"); +if ($encrypted === false) + die("failed to get a temporary filename!"); +$outfile = tempnam("/tmp", "ssl"); +if ($outfile === false) { + unlink($outfile); + die("failed to get a temporary filename!"); +} + +$single_cert = "file://" . dirname(__FILE__) . "/cert.crt"; +$headers = array("test@test", "testing openssl_pkcs7_encrypt()"); +$wrong = "wrong"; +$empty = ""; + +openssl_pkcs7_encrypt($infile, $encrypted, $single_cert, $headers); +var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $single_cert, $privkey)); +var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $single_cert, $wrong)); +var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $wrong, $privkey)); +var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, null, $privkey)); +var_dump(openssl_pkcs7_decrypt($wrong, $outfile, $single_cert, $privkey)); +var_dump(openssl_pkcs7_decrypt($empty, $outfile, $single_cert, $privkey)); +var_dump(openssl_pkcs7_decrypt($encrypted, $empty, $single_cert, $privkey)); +var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $empty, $privkey)); +var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $single_cert, $empty)); + +if (file_exists($encrypted)) { + echo "true\n"; + unlink($encrypted); +} +if (file_exists($outfile)) { + echo "true\n"; + unlink($outfile); +} +?> +--EXPECTF-- +bool(true) + +Warning: openssl_pkcs7_decrypt(): unable to get private key in %s on line %d +bool(false) + +Warning: openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert in %s on line %d +bool(false) + +Warning: openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert in %s on line %d +bool(false) +bool(false) +bool(false) +bool(false) + +Warning: openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert in %s on line %d +bool(false) + +Warning: openssl_pkcs7_decrypt(): unable to get private key in %s on line %d +bool(false) +true +true diff --git a/ext/openssl/tests/openssl_pkcs7_decrypt_error.phpt b/ext/openssl/tests/openssl_pkcs7_decrypt_error.phpt new file mode 100644 index 0000000..0fdb985 --- /dev/null +++ b/ext/openssl/tests/openssl_pkcs7_decrypt_error.phpt @@ -0,0 +1,43 @@ +--TEST-- +openssl_pkcs7_decrypt() and invalid parameters +--SKIPIF-- +<?php if (!extension_loaded("openssl")) print "skip"; ?> +--FILE-- +<?php + +function myErrorHandler($errno, $errstr, $errfile, $errline) { + var_dump($errstr); +} +set_error_handler("myErrorHandler"); + +$a = 1; +$b = 1; +$c = new stdclass; +$d = new stdclass; + +var_dump(openssl_pkcs7_decrypt($a, $b, $c, $d)); +var_dump($c); + +var_dump(openssl_pkcs7_decrypt($b, $b, $b, $b)); +var_dump(openssl_pkcs7_decrypt($a, $b, "", "")); +var_dump(openssl_pkcs7_decrypt($a, $b, true, false)); +var_dump(openssl_pkcs7_decrypt($a, $b, 0, 0)); + +echo "Done\n"; +?> +--EXPECTF-- +string(57) "Object of class stdClass could not be converted to string" +string(45) "Object of class stdClass to string conversion" +string(66) "openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert" +bool(false) +object(stdClass)#1 (0) { +} +string(66) "openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert" +bool(false) +string(66) "openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert" +bool(false) +string(66) "openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert" +bool(false) +string(66) "openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert" +bool(false) +Done diff --git a/ext/openssl/tests/openssl_pkcs7_encrypt_basic.phpt b/ext/openssl/tests/openssl_pkcs7_encrypt_basic.phpt new file mode 100644 index 0000000..5f74f97 --- /dev/null +++ b/ext/openssl/tests/openssl_pkcs7_encrypt_basic.phpt @@ -0,0 +1,64 @@ +--TEST-- +openssl_pkcs7_encrypt() tests +--SKIPIF-- +<?php if (!extension_loaded("openssl")) print "skip"; ?> +--FILE-- +<?php +$infile = dirname(__FILE__) . "/cert.crt"; +$outfile = tempnam("/tmp", "ssl"); +if ($outfile === false) + die("failed to get a temporary filename!"); +$outfile2 = tempnam("/tmp", "ssl"); +if ($outfile2 === false) + die("failed to get a temporary filename!"); + +$single_cert = "file://" . dirname(__FILE__) . "/cert.crt"; +$privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; +$multi_certs = array($single_cert, $single_cert); +$assoc_headers = array("To" => "test@test", "Subject" => "testing openssl_pkcs7_encrypt()"); +$headers = array("test@test", "testing openssl_pkcs7_encrypt()"); +$empty_headers = array(); +$wrong = "wrong"; +$empty = ""; + +var_dump(openssl_pkcs7_encrypt($infile, $outfile, $single_cert, $headers)); +var_dump(openssl_pkcs7_decrypt($outfile, $outfile2, $single_cert, $privkey)); +var_dump(openssl_pkcs7_encrypt($infile, $outfile, $single_cert, $assoc_headers)); +var_dump(openssl_pkcs7_encrypt($infile, $outfile, $single_cert, $empty_headers)); +var_dump(openssl_pkcs7_encrypt($infile, $outfile, $single_cert, $wrong)); +var_dump(openssl_pkcs7_encrypt($wrong, $outfile, $single_cert, $headers)); +var_dump(openssl_pkcs7_encrypt($empty, $outfile, $single_cert, $headers)); +var_dump(openssl_pkcs7_encrypt($infile, $empty, $single_cert, $headers)); +var_dump(openssl_pkcs7_encrypt($infile, $outfile, $wrong, $headers)); +var_dump(openssl_pkcs7_encrypt($infile, $outfile, $empty, $headers)); +var_dump(openssl_pkcs7_encrypt($infile, $outfile, $single_cert, $empty)); +var_dump(openssl_pkcs7_encrypt($infile, $outfile, $multi_certs, $headers)); + +if (file_exists($outfile)) { + echo "true\n"; + unlink($outfile); +} +if (file_exists($outfile2)) { + echo "true\n"; + unlink($outfile2); +} +?> +--EXPECTF-- +bool(true) +bool(true) +bool(true) +bool(true) + +Warning: openssl_pkcs7_encrypt() expects parameter 4 to be array, string given in %s on line %d +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) + +Warning: openssl_pkcs7_encrypt() expects parameter 4 to be array, string given in %s on line %d +bool(false) +bool(true) +true +true diff --git a/ext/openssl/tests/openssl_pkcs7_sign_basic.phpt b/ext/openssl/tests/openssl_pkcs7_sign_basic.phpt new file mode 100644 index 0000000..ac8edf1 --- /dev/null +++ b/ext/openssl/tests/openssl_pkcs7_sign_basic.phpt @@ -0,0 +1,66 @@ +--TEST-- +openssl_pkcs7_sign() tests +--SKIPIF-- +<?php if (!extension_loaded("openssl")) print "skip"; ?> +--FILE-- +<?php +$infile = dirname(__FILE__) . "/cert.crt"; +$outfile = tempnam("/tmp", "ssl"); +if ($outfile === false) { + die("failed to get a temporary filename!"); +} + +$privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; +$single_cert = "file://" . dirname(__FILE__) . "/cert.crt"; +$assoc_headers = array("To" => "test@test", "Subject" => "testing openssl_pkcs7_sign()"); +$headers = array("test@test", "testing openssl_pkcs7_sign()"); +$empty_headers = array(); +$wrong = "wrong"; +$empty = ""; + +var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $headers)); +var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $assoc_headers)); +var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $empty_headers)); +var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $wrong)); +var_dump(openssl_pkcs7_sign($wrong, $outfile, $single_cert, $privkey, $headers)); +var_dump(openssl_pkcs7_sign($empty, $outfile, $single_cert, $privkey, $headers)); +var_dump(openssl_pkcs7_sign($infile, $empty, $single_cert, $privkey, $headers)); +var_dump(openssl_pkcs7_sign($infile, $outfile, $wrong, $privkey, $headers)); +var_dump(openssl_pkcs7_sign($infile, $outfile, $empty, $privkey, $headers)); +var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $empty)); +var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $wrong, $headers)); + +if (file_exists($outfile)) { + echo "true\n"; + unlink($outfile); +} +?> +--EXPECTF-- +bool(true) +bool(true) +bool(true) + +Warning: openssl_pkcs7_sign() expects parameter 5 to be array, string given in %s on line %d +NULL + +Warning: openssl_pkcs7_sign(): error opening input file %s in %s on line %d +bool(false) + +Warning: openssl_pkcs7_sign(): error opening input file %s in %s on line %d +bool(false) + +Warning: openssl_pkcs7_sign(): error opening output file %s in %s on line %d +bool(false) + +Warning: openssl_pkcs7_sign(): error getting cert in %s on line %d +bool(false) + +Warning: openssl_pkcs7_sign(): error getting cert in %s on line %d +bool(false) + +Warning: openssl_pkcs7_sign() expects parameter 5 to be array, string given in %s on line %d +NULL + +Warning: openssl_pkcs7_sign(): error getting private key in %s on line %d +bool(false) +true diff --git a/ext/openssl/tests/openssl_pkey_export_basic.phpt b/ext/openssl/tests/openssl_pkey_export_basic.phpt new file mode 100644 index 0000000..8311ab1 --- /dev/null +++ b/ext/openssl/tests/openssl_pkey_export_basic.phpt @@ -0,0 +1,52 @@ +--TEST-- +openssl_pkey_export() with EC key +--SKIPIF-- +<?php +if (!extension_loaded("openssl")) die("skip"); +if (!defined('OPENSSL_KEYTYPE_EC')) die("skip no EC available"); +?> +--FILE-- +<?php +$key = openssl_pkey_get_private('file://' . dirname(__FILE__) . '/private_ec.key'); +var_dump($key); + +var_dump(openssl_pkey_export($key, $output)); +echo $output; + +// Load the private key from the exported pem string +$details = openssl_pkey_get_details(openssl_pkey_get_private($output)); +var_dump(OPENSSL_KEYTYPE_EC === $details['type']); + +// Export key with passphrase +openssl_pkey_export($key, $output, 'passphrase'); + +$details = openssl_pkey_get_details(openssl_pkey_get_private($output, 'passphrase')); +var_dump(OPENSSL_KEYTYPE_EC === $details['type']); + +// Read public key +$pKey = openssl_pkey_get_public('file://' . dirname(__FILE__) . '/public_ec.key'); +var_dump($pKey); +// The details are the same for a public or private key +var_dump($details === openssl_pkey_get_details($pKey)); + + +// Export to file +$tempname = tempnam(sys_get_temp_dir(), 'openssl_ec'); +var_dump(openssl_pkey_export_to_file($key, $tempname)); +$details = openssl_pkey_get_details(openssl_pkey_get_private('file://' . $tempname)); +var_dump(OPENSSL_KEYTYPE_EC === $details['type']); + +// Clean the temporary file +@unlink($tempname); + +?> +--EXPECTF-- +resource(%d) of type (OpenSSL key) +bool(true) +-----BEGIN EC PRIVATE KEY-----%a-----END EC PRIVATE KEY----- +bool(true) +bool(true) +resource(%d) of type (OpenSSL key) +bool(true) +bool(true) +bool(true) diff --git a/ext/openssl/tests/openssl_pkey_get_details_basic.phpt b/ext/openssl/tests/openssl_pkey_get_details_basic.phpt new file mode 100644 index 0000000..8e0cef4 --- /dev/null +++ b/ext/openssl/tests/openssl_pkey_get_details_basic.phpt @@ -0,0 +1,28 @@ +--TEST-- +openssl_pkey_get_details() with EC key +--SKIPIF-- +<?php +if (!extension_loaded("openssl")) die("skip"); +if (!defined('OPENSSL_KEYTYPE_EC')) die("skip no EC available"); +?> +--FILE-- +<?php +$key = openssl_pkey_get_private('file://' . dirname(__FILE__) . '/private_ec.key'); + +print_r(openssl_pkey_get_details($key)); +?> +--EXPECTF-- +Array +( + [bits] => 256 + [key] => -----BEGIN PUBLIC KEY-----%a +-----END PUBLIC KEY----- + + [ec] => Array + ( + [curve_name] => prime256v1 + [curve_oid] => 1.2.840.10045.3.1.7 + ) + + [type] => 3 +) diff --git a/ext/openssl/tests/openssl_pkey_new_basic.phpt b/ext/openssl/tests/openssl_pkey_new_basic.phpt new file mode 100644 index 0000000..3c43497 --- /dev/null +++ b/ext/openssl/tests/openssl_pkey_new_basic.phpt @@ -0,0 +1,25 @@ +--TEST-- +openssl_pkey_new() tests +--SKIPIF-- +<?php if (!extension_loaded("openssl")) print "skip"; ?> +--FILE-- +<?php +/* openssl_pkey_get_details() segfaults when getting the information + from openssl_pkey_new() with an empty sub-array arg */ + +$rsa = array("rsa" => array()); +$dsa = array("dsa" => array()); +$dh = array("dh" => array()); + +openssl_pkey_get_details(openssl_pkey_new($rsa)); +openssl_pkey_get_details(openssl_pkey_new($dsa)); +openssl_pkey_get_details(openssl_pkey_new($dh)); +?> +--EXPECTF-- + +Warning: openssl_pkey_get_details() expects parameter 1 to be resource, boolean given in %s on line %d + +Warning: openssl_pkey_get_details() expects parameter 1 to be resource, boolean given in %s on line %d + +Warning: openssl_pkey_get_details() expects parameter 1 to be resource, boolean given in %s on line %d + diff --git a/ext/openssl/tests/openssl_private_decrypt_basic.phpt b/ext/openssl/tests/openssl_private_decrypt_basic.phpt new file mode 100644 index 0000000..76a08b8 --- /dev/null +++ b/ext/openssl/tests/openssl_private_decrypt_basic.phpt @@ -0,0 +1,40 @@ +--TEST-- +openssl_private_decrypt() tests +--SKIPIF-- +<?php if (!extension_loaded("openssl")) print "skip"; ?> +--FILE-- +<?php +$data = "Testing openssl_public_decrypt()"; +$privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; +$pubkey = "file://" . dirname(__FILE__) . "/public.key"; +$wrong = "wrong"; + +openssl_public_encrypt($data, $encrypted, $pubkey); +var_dump(openssl_private_decrypt($encrypted, $output, $privkey)); +var_dump($output); +var_dump(openssl_private_decrypt($encrypted, $output2, $wrong)); +var_dump($output2); +var_dump(openssl_private_decrypt($wrong, $output3, $privkey)); +var_dump($output3); +var_dump(openssl_private_decrypt($encrypted, $output4, array($privkey))); +var_dump($output4); +var_dump(openssl_private_decrypt($encrypted, $output5, array($privkey, ""))); +var_dump($output5); +?> +--EXPECTF-- +bool(true) +string(32) "Testing openssl_public_decrypt()" + +Warning: openssl_private_decrypt(): key parameter is not a valid private key in %s on line %d +bool(false) +NULL +bool(false) +NULL + +Warning: openssl_private_decrypt(): key array must be of the form array(0 => key, 1 => phrase) in %s on line %d + +Warning: openssl_private_decrypt(): key parameter is not a valid private key in %s on line %d +bool(false) +NULL +bool(true) +string(32) "Testing openssl_public_decrypt()" diff --git a/ext/openssl/tests/openssl_private_encrypt_basic.phpt b/ext/openssl/tests/openssl_private_encrypt_basic.phpt new file mode 100644 index 0000000..a2a5152 --- /dev/null +++ b/ext/openssl/tests/openssl_private_encrypt_basic.phpt @@ -0,0 +1,39 @@ +--TEST-- +openssl_private_encrypt() tests +--SKIPIF-- +<?php if (!extension_loaded("openssl")) print "skip"; ?> +--FILE-- +<?php +$data = "Testing openssl_private_encrypt()"; +$privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; +$pubkey = "file://" . dirname(__FILE__) . "/public.key"; +$wrong = "wrong"; + +class test { + function __toString() { + return "test"; + } +} +$obj = new test; + +var_dump(openssl_private_encrypt($data, $encrypted, $privkey)); +var_dump(openssl_private_encrypt($data, $encrypted, $pubkey)); +var_dump(openssl_private_encrypt($data, $encrypted, $wrong)); +var_dump(openssl_private_encrypt($data, $encrypted, $obj)); +var_dump(openssl_private_encrypt($obj, $encrypted, $privkey)); +openssl_public_decrypt($encrypted, $output, $pubkey); +var_dump($output); +?> +--EXPECTF-- +bool(true) + +Warning: openssl_private_encrypt(): key param is not a valid private key in %s on line %d +bool(false) + +Warning: openssl_private_encrypt(): key param is not a valid private key in %s on line %d +bool(false) + +Warning: openssl_private_encrypt(): key param is not a valid private key in %s on line %d +bool(false) +bool(true) +string(4) "test" diff --git a/ext/openssl/tests/openssl_public_decrypt_basic.phpt b/ext/openssl/tests/openssl_public_decrypt_basic.phpt new file mode 100644 index 0000000..42d72b9 --- /dev/null +++ b/ext/openssl/tests/openssl_public_decrypt_basic.phpt @@ -0,0 +1,48 @@ +--TEST-- +openssl_public_decrypt() tests +--SKIPIF-- +<?php if (!extension_loaded("openssl")) print "skip"; ?> +--FILE-- +<?php +$data = "Testing openssl_public_decrypt()"; +$privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; +$pubkey = "file://" . dirname(__FILE__) . "/public.key"; +$wrong = "wrong"; + +openssl_private_encrypt($data, $encrypted, $privkey); +var_dump(openssl_public_decrypt($encrypted, $output, $pubkey)); +var_dump($output); +var_dump(openssl_public_decrypt($encrypted, $output2, $wrong)); +var_dump($output2); +var_dump(openssl_public_decrypt($wrong, $output3, $pubkey)); +var_dump($output3); +var_dump(openssl_public_decrypt($encrypted, $output4, array())); +var_dump($output4); +var_dump(openssl_public_decrypt($encrypted, $output5, array($pubkey))); +var_dump($output5); +var_dump(openssl_public_decrypt($encrypted, $output6, array($pubkey, ""))); +var_dump($output6); +?> +--EXPECTF-- +bool(true) +string(32) "Testing openssl_public_decrypt()" + +Warning: openssl_public_decrypt(): key parameter is not a valid public key in %s on line %d +bool(false) +NULL +bool(false) +NULL + +Warning: openssl_public_decrypt(): key array must be of the form array(0 => key, 1 => phrase) in %s on line %d + +Warning: openssl_public_decrypt(): key parameter is not a valid public key in %s on line %d +bool(false) +NULL + +Warning: openssl_public_decrypt(): key array must be of the form array(0 => key, 1 => phrase) in %s on line %d + +Warning: openssl_public_decrypt(): key parameter is not a valid public key in %s on line %d +bool(false) +NULL +bool(true) +string(32) "Testing openssl_public_decrypt()" diff --git a/ext/openssl/tests/openssl_public_encrypt_basic.phpt b/ext/openssl/tests/openssl_public_encrypt_basic.phpt new file mode 100644 index 0000000..a3c4c57 --- /dev/null +++ b/ext/openssl/tests/openssl_public_encrypt_basic.phpt @@ -0,0 +1,40 @@ +--TEST-- +openssl_public_encrypt() tests +--SKIPIF-- +<?php if (!extension_loaded("openssl")) print "skip"; ?> +--FILE-- +<?php +$data = "Testing openssl_public_encrypt()"; +$privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; +$pubkey = "file://" . dirname(__FILE__) . "/public.key"; +$wrong = "wrong"; + +class test { + function __toString() { + return "test"; + } +} +$obj = new test; + +var_dump(openssl_public_encrypt($data, $encrypted, $pubkey)); +var_dump(openssl_public_encrypt($data, $encrypted, $privkey)); +var_dump(openssl_public_encrypt($data, $encrypted, $wrong)); +var_dump(openssl_public_encrypt($data, $encrypted, $obj)); +var_dump(openssl_public_encrypt($obj, $encrypted, $pubkey)); +openssl_private_decrypt($encrypted, $output, $privkey); +var_dump($output); +?> +--EXPECTF-- +bool(true) + +Warning: openssl_public_encrypt(): key parameter is not a valid public key in %s on line %d +bool(false) + +Warning: openssl_public_encrypt(): key parameter is not a valid public key in %s on line %d +bool(false) + +Warning: openssl_public_encrypt(): key parameter is not a valid public key in %s on line %d +bool(false) +bool(true) +string(4) "test" + diff --git a/ext/openssl/tests/openssl_random_pseudo_bytes.phpt b/ext/openssl/tests/openssl_random_pseudo_bytes.phpt deleted file mode 100644 index ac5a307..0000000 --- a/ext/openssl/tests/openssl_random_pseudo_bytes.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -openssl_random_pseudo_bytes() tests ---SKIPIF-- -<?php if (!extension_loaded("openssl")) print "skip"; ?> ---FILE-- -<?php -for ($i = 0; $i < 10; $i++) { - var_dump(bin2hex(openssl_random_pseudo_bytes($i, $strong))); -} - -?> ---EXPECTF-- -string(0) "" -string(2) "%s" -string(4) "%s" -string(6) "%s" -string(8) "%s" -string(10) "%s" -string(12) "%s" -string(14) "%s" -string(16) "%s" -string(18) "%s" \ No newline at end of file diff --git a/ext/openssl/tests/openssl_random_pseudo_bytes_basic.phpt b/ext/openssl/tests/openssl_random_pseudo_bytes_basic.phpt new file mode 100644 index 0000000..ac5a307 --- /dev/null +++ b/ext/openssl/tests/openssl_random_pseudo_bytes_basic.phpt @@ -0,0 +1,22 @@ +--TEST-- +openssl_random_pseudo_bytes() tests +--SKIPIF-- +<?php if (!extension_loaded("openssl")) print "skip"; ?> +--FILE-- +<?php +for ($i = 0; $i < 10; $i++) { + var_dump(bin2hex(openssl_random_pseudo_bytes($i, $strong))); +} + +?> +--EXPECTF-- +string(0) "" +string(2) "%s" +string(4) "%s" +string(6) "%s" +string(8) "%s" +string(10) "%s" +string(12) "%s" +string(14) "%s" +string(16) "%s" +string(18) "%s" \ No newline at end of file diff --git a/ext/openssl/tests/openssl_seal_basic.phpt b/ext/openssl/tests/openssl_seal_basic.phpt new file mode 100644 index 0000000..4f1958a --- /dev/null +++ b/ext/openssl/tests/openssl_seal_basic.phpt @@ -0,0 +1,58 @@ +--TEST-- +openssl_seal() tests +--SKIPIF-- +<?php if (!extension_loaded("openssl")) print "skip"; ?> +--FILE-- +<?php +// simple tests +$a = 1; +$b = array(1); +$c = array(1); +$d = array(1); + +var_dump(openssl_seal($a, $b, $c, $d)); +var_dump(openssl_seal($a, $a, $a, array())); +var_dump(openssl_seal($c, $c, $c, 1)); +var_dump(openssl_seal($b, $b, $b, "")); + +// tests with cert +$data = "openssl_open() test"; +$pub_key = "file://" . dirname(__FILE__) . "/public.key"; +$wrong = "wrong"; + +var_dump(openssl_seal($data, $sealed, $ekeys, array($pub_key))); // no output +var_dump(openssl_seal($data, $sealed, $ekeys, array($pub_key, $pub_key))); // no output +var_dump(openssl_seal($data, $sealed, $ekeys, array($pub_key, $wrong))); +var_dump(openssl_seal($data, $sealed, $ekeys, $pub_key)); +var_dump(openssl_seal($data, $sealed, $ekeys, array())); +var_dump(openssl_seal($data, $sealed, $ekeys, array($wrong))); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: openssl_seal(): not a public key (1th member of pubkeys) in %s on line %d +bool(false) + +Warning: openssl_seal(): Fourth argument to openssl_seal() must be a non-empty array in %s on line %d +bool(false) + +Warning: openssl_seal() expects parameter 1 to be string, array given in %s on line %d +NULL + +Warning: openssl_seal() expects parameter 1 to be string, array given in %s on line %d +NULL +int(19) +int(19) + +Warning: openssl_seal(): not a public key (2th member of pubkeys) in %s on line %d +bool(false) + +Warning: openssl_seal() expects parameter 4 to be array, string given in %s on line %d +NULL + +Warning: openssl_seal(): Fourth argument to openssl_seal() must be a non-empty array in %s on line %d +bool(false) + +Warning: openssl_seal(): not a public key (1th member of pubkeys) in %s on line %d +bool(false) +Done diff --git a/ext/openssl/tests/openssl_sign_basic.phpt b/ext/openssl/tests/openssl_sign_basic.phpt new file mode 100644 index 0000000..3d41ee1 --- /dev/null +++ b/ext/openssl/tests/openssl_sign_basic.phpt @@ -0,0 +1,22 @@ +--TEST-- +openssl_sign() tests +--SKIPIF-- +<?php if (!extension_loaded("openssl")) print "skip"; ?> +--FILE-- +<?php +$data = "Testing openssl_sign()"; +$privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; +$wrong = "wrong"; + +var_dump(openssl_sign($data, $sign, $privkey)); // no output +var_dump(openssl_sign($data, $sign, $wrong)); +var_dump(openssl_sign(array(), $sign, $privkey)); +?> +--EXPECTF-- +bool(true) + +Warning: openssl_sign(): supplied key param cannot be coerced into a private key in %s on line %d +bool(false) + +Warning: openssl_sign() expects parameter 1 to be string, array given in %s on line %d +NULL diff --git a/ext/openssl/tests/openssl_verify_basic.phpt b/ext/openssl/tests/openssl_verify_basic.phpt new file mode 100644 index 0000000..a21dfed --- /dev/null +++ b/ext/openssl/tests/openssl_verify_basic.phpt @@ -0,0 +1,28 @@ +--TEST-- +openssl_verify() tests +--SKIPIF-- +<?php if (!extension_loaded("openssl")) print "skip"; ?> +--FILE-- +<?php +$data = "Testing openssl_verify()"; +$privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; +$pubkey = "file://" . dirname(__FILE__) . "/public.key"; +$wrong = "wrong"; + +openssl_sign($data, $sign, $privkey); +var_dump(openssl_verify($data, $sign, $pubkey)); +var_dump(openssl_verify($data, $sign, $privkey)); +var_dump(openssl_verify($data, $sign, $wrong)); +var_dump(openssl_verify($data, $wrong, $pubkey)); +var_dump(openssl_verify($wrong, $sign, $pubkey)); +?> +--EXPECTF-- +int(1) + +Warning: openssl_verify(): supplied key param cannot be coerced into a public key in %s on line %d +bool(false) + +Warning: openssl_verify(): supplied key param cannot be coerced into a public key in %s on line %d +bool(false) +int(0) +int(0) diff --git a/ext/openssl/tests/openssl_x509_check_private_key_basic.phpt b/ext/openssl/tests/openssl_x509_check_private_key_basic.phpt new file mode 100644 index 0000000..df18322 --- /dev/null +++ b/ext/openssl/tests/openssl_x509_check_private_key_basic.phpt @@ -0,0 +1,29 @@ +--TEST-- +openssl_x509_check_private_key() tests +--SKIPIF-- +<?php if (!extension_loaded("openssl")) print "skip"; ?> +--FILE-- +<?php +$fp = fopen(dirname(__FILE__) . "/cert.crt","r"); +$a = fread($fp,8192); +fclose($fp); + +$fp = fopen(dirname(__FILE__) . "/private_rsa_1024.key","r"); +$b = fread($fp,8192); +fclose($fp); + +$cert = "file://" . dirname(__FILE__) . "/cert.crt"; +$key = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; + +var_dump(openssl_x509_check_private_key($cert, $key)); +var_dump(openssl_x509_check_private_key("", $key)); +var_dump(openssl_x509_check_private_key($cert, "")); +var_dump(openssl_x509_check_private_key("", "")); +var_dump(openssl_x509_check_private_key($a, $b)); +?> +--EXPECT-- +bool(true) +bool(false) +bool(false) +bool(false) +bool(true) diff --git a/ext/openssl/tests/openssl_x509_export_basic.phpt b/ext/openssl/tests/openssl_x509_export_basic.phpt new file mode 100644 index 0000000..e0988c0 --- /dev/null +++ b/ext/openssl/tests/openssl_x509_export_basic.phpt @@ -0,0 +1,75 @@ +--TEST-- +openssl_x509_export() and openssl_x509_export_to_file() tests +--SKIPIF-- +<?php if (!extension_loaded("openssl")) print "skip"; ?> +--FILE-- +<?php +$fp = fopen(dirname(__FILE__) . "/cert.crt","r"); +$a = fread($fp,8192); +fclose($fp); + +$b = "file://" . dirname(__FILE__) . "/cert.crt"; +$c = "invalid cert"; +$d = openssl_x509_read($a); +$e = array(); + +var_dump(openssl_x509_export($a, $output)); // read cert as a binary string +var_dump(openssl_x509_export($b, $output2)); // read cert from a filename string +var_dump(openssl_x509_export($c, $output3)); // read an invalid cert, fails +var_dump(openssl_x509_export($d, $output4)); // read cert from a resource +var_dump(openssl_x509_export($e, $output5)); // read an array, fails + +$outfilename = tempnam("/tmp", "ssl"); +if ($outfilename === false) { + die("failed to get a temporary filename!"); +} + +echo "---\n"; + +var_dump(openssl_x509_export_to_file($a, $outfilename)); // read cert as a binary string +var_dump(openssl_x509_export_to_file($b, $outfilename)); // read cert from a filename string +var_dump(openssl_x509_export_to_file($c, $outfilename)); // read an invalid cert, fails +var_dump(openssl_x509_export_to_file($d, $outfilename)); // read cert from a resource +var_dump(openssl_x509_export_to_file($e, $outfilename)); // read an array, fails +echo "---\n"; + +var_dump($exists = file_exists($outfilename)); +if ($exists) { + @unlink($outfilename); +} +echo "---\n"; + +var_dump(strcmp($output, $a)); +var_dump(strcmp($output, $output2)); +var_dump(strcmp($output, $output3)); +var_dump(strcmp($output, $output4)); // different +var_dump(strcmp($output, $output5)); // different +?> +--EXPECTF-- +bool(true) +bool(true) + +Warning: openssl_x509_export(): cannot get cert from parameter 1 in %s on line %d +bool(false) +bool(true) + +Warning: openssl_x509_export(): cannot get cert from parameter 1 in %s on line %d +bool(false) +--- +bool(true) +bool(true) + +Warning: openssl_x509_export_to_file(): cannot get cert from parameter 1 in %s on line %d +bool(false) +bool(true) + +Warning: openssl_x509_export_to_file(): cannot get cert from parameter 1 in %s on line %d +bool(false) +--- +bool(true) +--- +int(0) +int(0) +int(%d) +int(0) +int(%d) diff --git a/ext/openssl/tests/openssl_x509_fingerprint.phpt b/ext/openssl/tests/openssl_x509_fingerprint.phpt deleted file mode 100644 index 6cd464a..0000000 --- a/ext/openssl/tests/openssl_x509_fingerprint.phpt +++ /dev/null @@ -1,47 +0,0 @@ ---TEST-- -Testing openssl_x509_fingerprint() ---SKIPIF-- -<?php -if (!extension_loaded("openssl")) die("skip"); -?> ---FILE-- -<?php - -$cert = "file://" . dirname(__FILE__) . "/cert.crt"; - -echo "** Testing with no parameters **\n"; -var_dump(openssl_x509_fingerprint()); - -echo "** Testing default functionality **\n"; -var_dump(openssl_x509_fingerprint($cert)); - -echo "** Testing hash method md5 **\n"; -var_dump(openssl_x509_fingerprint($cert, 'md5')); - -echo "**Testing raw output md5 **\n"; -var_dump(bin2hex(openssl_x509_fingerprint($cert, 'md5', true))); - -echo "** Testing bad certification **\n"; -var_dump(openssl_x509_fingerprint('123')); -echo "** Testing bad hash method **\n"; -var_dump(openssl_x509_fingerprint($cert, 'xx45')); ---EXPECTF-- -** Testing with no parameters ** - -Warning: openssl_x509_fingerprint() expects at least 1 parameter, 0 given in %s on line %d -NULL -** Testing default functionality ** -string(40) "6e6fd1ea10a5a23071d61c728ee9b40df6dbc33c" -** Testing hash method md5 ** -string(32) "ac77008e172897e06c0b065294487a67" -**Testing raw output md5 ** -string(32) "ac77008e172897e06c0b065294487a67" -** Testing bad certification ** - -Warning: openssl_x509_fingerprint(): cannot get cert from parameter 1 in %s on line %d -bool(false) -** Testing bad hash method ** - -Warning: openssl_x509_fingerprint(): Unknown signature algorithm in %s on line %d -bool(false) - diff --git a/ext/openssl/tests/openssl_x509_fingerprint_basic.phpt b/ext/openssl/tests/openssl_x509_fingerprint_basic.phpt new file mode 100644 index 0000000..6cd464a --- /dev/null +++ b/ext/openssl/tests/openssl_x509_fingerprint_basic.phpt @@ -0,0 +1,47 @@ +--TEST-- +Testing openssl_x509_fingerprint() +--SKIPIF-- +<?php +if (!extension_loaded("openssl")) die("skip"); +?> +--FILE-- +<?php + +$cert = "file://" . dirname(__FILE__) . "/cert.crt"; + +echo "** Testing with no parameters **\n"; +var_dump(openssl_x509_fingerprint()); + +echo "** Testing default functionality **\n"; +var_dump(openssl_x509_fingerprint($cert)); + +echo "** Testing hash method md5 **\n"; +var_dump(openssl_x509_fingerprint($cert, 'md5')); + +echo "**Testing raw output md5 **\n"; +var_dump(bin2hex(openssl_x509_fingerprint($cert, 'md5', true))); + +echo "** Testing bad certification **\n"; +var_dump(openssl_x509_fingerprint('123')); +echo "** Testing bad hash method **\n"; +var_dump(openssl_x509_fingerprint($cert, 'xx45')); +--EXPECTF-- +** Testing with no parameters ** + +Warning: openssl_x509_fingerprint() expects at least 1 parameter, 0 given in %s on line %d +NULL +** Testing default functionality ** +string(40) "6e6fd1ea10a5a23071d61c728ee9b40df6dbc33c" +** Testing hash method md5 ** +string(32) "ac77008e172897e06c0b065294487a67" +**Testing raw output md5 ** +string(32) "ac77008e172897e06c0b065294487a67" +** Testing bad certification ** + +Warning: openssl_x509_fingerprint(): cannot get cert from parameter 1 in %s on line %d +bool(false) +** Testing bad hash method ** + +Warning: openssl_x509_fingerprint(): Unknown signature algorithm in %s on line %d +bool(false) + diff --git a/ext/openssl/tests/openssl_x509_parse_basic_v9.phpt b/ext/openssl/tests/openssl_x509_parse_basic_v9.phpt deleted file mode 100644 index 89862ef..0000000 --- a/ext/openssl/tests/openssl_x509_parse_basic_v9.phpt +++ /dev/null @@ -1,276 +0,0 @@ ---TEST-- -openssl_x509_parse() basic test for OpenSSL 0.9 ---SKIPIF-- -<?php if (!extension_loaded("openssl")) print "skip"; -if (OPENSSL_VERSION_NUMBER > 0x10000000) die("skip Output requires OpenSSL 0.9"); -?> ---FILE-- -<?php -$cert = "file://" . dirname(__FILE__) . "/cert.crt"; - -var_dump(openssl_x509_parse($cert)); -var_dump(openssl_x509_parse($cert, false)); -?> ---EXPECTF-- -array(12) { - ["name"]=> - string(96) "/C=BR/ST=Rio Grande do Sul/L=Porto Alegre/CN=Henrique do N. Angelo/emailAddress=hnangelo@php.net" - ["subject"]=> - array(5) { - ["C"]=> - string(2) "BR" - ["ST"]=> - string(17) "Rio Grande do Sul" - ["L"]=> - string(12) "Porto Alegre" - ["CN"]=> - string(21) "Henrique do N. Angelo" - ["emailAddress"]=> - string(16) "hnangelo@php.net" - } - ["hash"]=> - string(8) "%s" - ["issuer"]=> - array(5) { - ["C"]=> - string(2) "BR" - ["ST"]=> - string(17) "Rio Grande do Sul" - ["L"]=> - string(12) "Porto Alegre" - ["CN"]=> - string(21) "Henrique do N. Angelo" - ["emailAddress"]=> - string(16) "hnangelo@php.net" - } - ["version"]=> - int(2) - ["serialNumber"]=> - string(20) "12593567369101004962" - ["validFrom"]=> - string(13) "080630102843Z" - ["validTo"]=> - string(13) "080730102843Z" - ["validFrom_time_t"]=> - int(1214821723) - ["validTo_time_t"]=> - int(1217413723) - ["purposes"]=> - array(8) { - [1]=> - array(3) { - [0]=> - bool(true) - [1]=> - bool(true) - [2]=> - string(9) "sslclient" - } - [2]=> - array(3) { - [0]=> - bool(true) - [1]=> - bool(true) - [2]=> - string(9) "sslserver" - } - [3]=> - array(3) { - [0]=> - bool(true) - [1]=> - bool(true) - [2]=> - string(11) "nssslserver" - } - [4]=> - array(3) { - [0]=> - bool(true) - [1]=> - bool(true) - [2]=> - string(9) "smimesign" - } - [5]=> - array(3) { - [0]=> - bool(true) - [1]=> - bool(true) - [2]=> - string(12) "smimeencrypt" - } - [6]=> - array(3) { - [0]=> - bool(true) - [1]=> - bool(true) - [2]=> - string(7) "crlsign" - } - [7]=> - array(3) { - [0]=> - bool(true) - [1]=> - bool(true) - [2]=> - string(3) "any" - } - [8]=> - array(3) { - [0]=> - bool(true) - [1]=> - bool(true) - [2]=> - string(10) "ocsphelper" - } - } - ["extensions"]=> - array(3) { - ["subjectKeyIdentifier"]=> - string(59) "DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D" - ["authorityKeyIdentifier"]=> - string(202) "keyid:DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D -DirName:/C=BR/ST=Rio Grande do Sul/L=Porto Alegre/CN=Henrique do N. Angelo/emailAddress=hnangelo@php.net -serial:AE:C5:56:CC:72:37:50:A2 -" - ["basicConstraints"]=> - string(7) "CA:TRUE" - } -} -array(12) { - ["name"]=> - string(96) "/C=BR/ST=Rio Grande do Sul/L=Porto Alegre/CN=Henrique do N. Angelo/emailAddress=hnangelo@php.net" - ["subject"]=> - array(5) { - ["countryName"]=> - string(2) "BR" - ["stateOrProvinceName"]=> - string(17) "Rio Grande do Sul" - ["localityName"]=> - string(12) "Porto Alegre" - ["commonName"]=> - string(21) "Henrique do N. Angelo" - ["emailAddress"]=> - string(16) "hnangelo@php.net" - } - ["hash"]=> - string(8) "%s" - ["issuer"]=> - array(5) { - ["countryName"]=> - string(2) "BR" - ["stateOrProvinceName"]=> - string(17) "Rio Grande do Sul" - ["localityName"]=> - string(12) "Porto Alegre" - ["commonName"]=> - string(21) "Henrique do N. Angelo" - ["emailAddress"]=> - string(16) "hnangelo@php.net" - } - ["version"]=> - int(2) - ["serialNumber"]=> - string(20) "12593567369101004962" - ["validFrom"]=> - string(13) "080630102843Z" - ["validTo"]=> - string(13) "080730102843Z" - ["validFrom_time_t"]=> - int(1214821723) - ["validTo_time_t"]=> - int(1217413723) - ["purposes"]=> - array(8) { - [1]=> - array(3) { - [0]=> - bool(true) - [1]=> - bool(true) - [2]=> - string(10) "SSL client" - } - [2]=> - array(3) { - [0]=> - bool(true) - [1]=> - bool(true) - [2]=> - string(10) "SSL server" - } - [3]=> - array(3) { - [0]=> - bool(true) - [1]=> - bool(true) - [2]=> - string(19) "Netscape SSL server" - } - [4]=> - array(3) { - [0]=> - bool(true) - [1]=> - bool(true) - [2]=> - string(14) "S/MIME signing" - } - [5]=> - array(3) { - [0]=> - bool(true) - [1]=> - bool(true) - [2]=> - string(17) "S/MIME encryption" - } - [6]=> - array(3) { - [0]=> - bool(true) - [1]=> - bool(true) - [2]=> - string(11) "CRL signing" - } - [7]=> - array(3) { - [0]=> - bool(true) - [1]=> - bool(true) - [2]=> - string(11) "Any Purpose" - } - [8]=> - array(3) { - [0]=> - bool(true) - [1]=> - bool(true) - [2]=> - string(11) "OCSP helper" - } - } - ["extensions"]=> - array(3) { - ["subjectKeyIdentifier"]=> - string(59) "DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D" - ["authorityKeyIdentifier"]=> - string(202) "keyid:DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D -DirName:/C=BR/ST=Rio Grande do Sul/L=Porto Alegre/CN=Henrique do N. Angelo/emailAddress=hnangelo@php.net -serial:AE:C5:56:CC:72:37:50:A2 -" - ["basicConstraints"]=> - string(7) "CA:TRUE" - } -} diff --git a/ext/openssl/tests/openssl_x509_parse_v9_basic.phpt b/ext/openssl/tests/openssl_x509_parse_v9_basic.phpt new file mode 100644 index 0000000..89862ef --- /dev/null +++ b/ext/openssl/tests/openssl_x509_parse_v9_basic.phpt @@ -0,0 +1,276 @@ +--TEST-- +openssl_x509_parse() basic test for OpenSSL 0.9 +--SKIPIF-- +<?php if (!extension_loaded("openssl")) print "skip"; +if (OPENSSL_VERSION_NUMBER > 0x10000000) die("skip Output requires OpenSSL 0.9"); +?> +--FILE-- +<?php +$cert = "file://" . dirname(__FILE__) . "/cert.crt"; + +var_dump(openssl_x509_parse($cert)); +var_dump(openssl_x509_parse($cert, false)); +?> +--EXPECTF-- +array(12) { + ["name"]=> + string(96) "/C=BR/ST=Rio Grande do Sul/L=Porto Alegre/CN=Henrique do N. Angelo/emailAddress=hnangelo@php.net" + ["subject"]=> + array(5) { + ["C"]=> + string(2) "BR" + ["ST"]=> + string(17) "Rio Grande do Sul" + ["L"]=> + string(12) "Porto Alegre" + ["CN"]=> + string(21) "Henrique do N. Angelo" + ["emailAddress"]=> + string(16) "hnangelo@php.net" + } + ["hash"]=> + string(8) "%s" + ["issuer"]=> + array(5) { + ["C"]=> + string(2) "BR" + ["ST"]=> + string(17) "Rio Grande do Sul" + ["L"]=> + string(12) "Porto Alegre" + ["CN"]=> + string(21) "Henrique do N. Angelo" + ["emailAddress"]=> + string(16) "hnangelo@php.net" + } + ["version"]=> + int(2) + ["serialNumber"]=> + string(20) "12593567369101004962" + ["validFrom"]=> + string(13) "080630102843Z" + ["validTo"]=> + string(13) "080730102843Z" + ["validFrom_time_t"]=> + int(1214821723) + ["validTo_time_t"]=> + int(1217413723) + ["purposes"]=> + array(8) { + [1]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(9) "sslclient" + } + [2]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(9) "sslserver" + } + [3]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(11) "nssslserver" + } + [4]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(9) "smimesign" + } + [5]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(12) "smimeencrypt" + } + [6]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(7) "crlsign" + } + [7]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(3) "any" + } + [8]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(10) "ocsphelper" + } + } + ["extensions"]=> + array(3) { + ["subjectKeyIdentifier"]=> + string(59) "DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D" + ["authorityKeyIdentifier"]=> + string(202) "keyid:DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D +DirName:/C=BR/ST=Rio Grande do Sul/L=Porto Alegre/CN=Henrique do N. Angelo/emailAddress=hnangelo@php.net +serial:AE:C5:56:CC:72:37:50:A2 +" + ["basicConstraints"]=> + string(7) "CA:TRUE" + } +} +array(12) { + ["name"]=> + string(96) "/C=BR/ST=Rio Grande do Sul/L=Porto Alegre/CN=Henrique do N. Angelo/emailAddress=hnangelo@php.net" + ["subject"]=> + array(5) { + ["countryName"]=> + string(2) "BR" + ["stateOrProvinceName"]=> + string(17) "Rio Grande do Sul" + ["localityName"]=> + string(12) "Porto Alegre" + ["commonName"]=> + string(21) "Henrique do N. Angelo" + ["emailAddress"]=> + string(16) "hnangelo@php.net" + } + ["hash"]=> + string(8) "%s" + ["issuer"]=> + array(5) { + ["countryName"]=> + string(2) "BR" + ["stateOrProvinceName"]=> + string(17) "Rio Grande do Sul" + ["localityName"]=> + string(12) "Porto Alegre" + ["commonName"]=> + string(21) "Henrique do N. Angelo" + ["emailAddress"]=> + string(16) "hnangelo@php.net" + } + ["version"]=> + int(2) + ["serialNumber"]=> + string(20) "12593567369101004962" + ["validFrom"]=> + string(13) "080630102843Z" + ["validTo"]=> + string(13) "080730102843Z" + ["validFrom_time_t"]=> + int(1214821723) + ["validTo_time_t"]=> + int(1217413723) + ["purposes"]=> + array(8) { + [1]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(10) "SSL client" + } + [2]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(10) "SSL server" + } + [3]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(19) "Netscape SSL server" + } + [4]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(14) "S/MIME signing" + } + [5]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(17) "S/MIME encryption" + } + [6]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(11) "CRL signing" + } + [7]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(11) "Any Purpose" + } + [8]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(11) "OCSP helper" + } + } + ["extensions"]=> + array(3) { + ["subjectKeyIdentifier"]=> + string(59) "DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D" + ["authorityKeyIdentifier"]=> + string(202) "keyid:DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D +DirName:/C=BR/ST=Rio Grande do Sul/L=Porto Alegre/CN=Henrique do N. Angelo/emailAddress=hnangelo@php.net +serial:AE:C5:56:CC:72:37:50:A2 +" + ["basicConstraints"]=> + string(7) "CA:TRUE" + } +} diff --git a/ext/openssl/tests/openssl_x509_read_basic.phpt b/ext/openssl/tests/openssl_x509_read_basic.phpt new file mode 100644 index 0000000..cc36e98 --- /dev/null +++ b/ext/openssl/tests/openssl_x509_read_basic.phpt @@ -0,0 +1,60 @@ +--TEST-- +openssl_x509_read() tests with testing openssl_x509_free as well +--SKIPIF-- +<?php if (!extension_loaded("openssl")) print "skip"; ?> +--FILE-- +<?php +$fp = fopen(dirname(__FILE__) . "/cert.crt","r"); +$a = fread($fp,8192); +fclose($fp); + +$b = "file://" . dirname(__FILE__) . "/cert.crt"; +$c = "invalid cert"; +$d = openssl_x509_read($a); +$e = array(); +$f = array($b); + +var_dump($res = openssl_x509_read($a)); // read cert as a string +openssl_x509_free($res); +var_dump($res); +var_dump($res = openssl_x509_read($b)); // read cert as a filename string +openssl_x509_free($res); +var_dump($res); +var_dump($res = openssl_x509_read($c)); // read an invalid cert, fails +openssl_x509_free($res); +var_dump($res); +var_dump($res = openssl_x509_read($d)); // read cert from a resource +openssl_x509_free($res); +var_dump($res); +var_dump($res = openssl_x509_read($e)); // read an array +openssl_x509_free($res); +var_dump($res); +var_dump($res = openssl_x509_read($f)); // read an array with the filename +openssl_x509_free($res); +var_dump($res); +?> +--EXPECTF-- +resource(%d) of type (OpenSSL X.509) +resource(%d) of type (Unknown) +resource(%d) of type (OpenSSL X.509) +resource(%d) of type (Unknown) + +Warning: openssl_x509_read(): supplied parameter cannot be coerced into an X509 certificate! in %s on line %d +bool(false) + +Warning: openssl_x509_free() expects parameter 1 to be resource, boolean given in %s on line %d +bool(false) +resource(%d) of type (OpenSSL X.509) +resource(%d) of type (Unknown) + +Warning: openssl_x509_read(): supplied parameter cannot be coerced into an X509 certificate! in %s on line %d +bool(false) + +Warning: openssl_x509_free() expects parameter 1 to be resource, boolean given in %s on line %d +bool(false) + +Warning: openssl_x509_read(): supplied parameter cannot be coerced into an X509 certificate! in %s on line %d +bool(false) + +Warning: openssl_x509_free() expects parameter 1 to be resource, boolean given in %s on line %d +bool(false)
« previous php.cvs (#90935) next »