1--TEST-- 2openssl_csr_sign() tests 3--SKIPIF-- 4<?php if (!extension_loaded("openssl")) print "skip"; ?> 5--FILE-- 6<?php 7$cert = "file://" . dirname(__FILE__) . "/cert.crt"; 8$priv = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; 9$wrong = "wrong"; 10$pub = "file://" . dirname(__FILE__) . "/public.key"; 11$config = __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf'; 12$config_arg = array('config' => $config); 13 14$dn = array( 15 "countryName" => "BR", 16 "stateOrProvinceName" => "Rio Grande do Sul", 17 "localityName" => "Porto Alegre", 18 "commonName" => "Henrique do N. Angelo", 19 "emailAddress" => "hnangelo@php.net" 20 ); 21 22$args = array( 23 "digest_alg" => "sha1", 24 "private_key_bits" => 2048, 25 "private_key_type" => OPENSSL_KEYTYPE_DSA, 26 "encrypt_key" => true, 27 "config" => $config 28 ); 29 30$privkey = openssl_pkey_new($config_arg); 31$csr = openssl_csr_new($dn, $privkey, $args); 32var_dump(openssl_csr_sign($csr, null, $privkey, 365, $args)); 33var_dump(openssl_csr_sign($csr, null, $privkey, 365, $config_arg)); 34var_dump(openssl_csr_sign($csr, $cert, $priv, 365, $config_arg)); 35var_dump(openssl_csr_sign($csr, $wrong, $privkey, 365)); 36var_dump(openssl_csr_sign($csr, null, $wrong, 365)); 37var_dump(openssl_csr_sign($csr, null, $privkey, $wrong)); 38var_dump(openssl_csr_sign($csr, null, $privkey, 365, $wrong)); 39var_dump(openssl_csr_sign($wrong, null, $privkey, 365)); 40var_dump(openssl_csr_sign(array(), null, $privkey, 365)); 41var_dump(openssl_csr_sign($csr, array(), $privkey, 365)); 42var_dump(openssl_csr_sign($csr, null, array(), 365)); 43var_dump(openssl_csr_sign($csr, null, $privkey, array())); 44var_dump(openssl_csr_sign($csr, null, $privkey, 365, $config_arg)); 45?> 46--EXPECTF-- 47resource(%d) of type (OpenSSL X.509) 48resource(%d) of type (OpenSSL X.509) 49resource(%d) of type (OpenSSL X.509) 50 51Warning: openssl_csr_sign(): cannot get cert from parameter 2 in %s on line %d 52bool(false) 53 54Warning: openssl_csr_sign(): cannot get private key from parameter 3 in %s on line %d 55bool(false) 56 57Warning: openssl_csr_sign() expects parameter 4 to be long, string given in %s on line %d 58NULL 59 60Warning: openssl_csr_sign() expects parameter 5 to be array, string given in %s on line %d 61NULL 62 63Warning: openssl_csr_sign(): cannot get CSR from parameter 1 in %s on line %d 64bool(false) 65 66Warning: openssl_csr_sign(): cannot get CSR from parameter 1 in %s on line %d 67bool(false) 68 69Warning: openssl_csr_sign(): cannot get cert from parameter 2 in %s on line %d 70bool(false) 71 72Warning: openssl_csr_sign(): key array must be of the form array(0 => key, 1 => phrase) in %s on line %d 73 74Warning: openssl_csr_sign(): cannot get private key from parameter 3 in %s on line %d 75bool(false) 76 77Warning: openssl_csr_sign() expects parameter 4 to be long, array given in %s on line %d 78NULL 79resource(%d) of type (OpenSSL X.509) 80 81