1--TEST-- 2openssl_pkcs12_export_to_file() tests 3--SKIPIF-- 4<?php if (!extension_loaded("openssl")) print "skip"; ?> 5--FILE-- 6<?php 7$pkcsfile = __DIR__ . "/openssl_pkcs12_export_to_file__pkcsfile.tmp"; 8 9$cert_file = __DIR__ . "/public.crt"; 10$cert = file_get_contents($cert_file); 11$cert_path = "file://" . $cert_file; 12$priv_file = __DIR__ . "/private.crt"; 13$priv = file_get_contents($priv_file); 14$priv_path = "file://" . $priv_file; 15$cert_res = openssl_x509_read($cert); 16$priv_res = openssl_pkey_get_private($priv); 17$pass = "test"; 18$invalid = ""; 19$invalid_path = __DIR__ . "/invalid_path"; 20$opts = []; 21 22var_dump(openssl_pkcs12_export_to_file($cert, $pkcsfile, $priv, $pass)); 23var_dump(openssl_pkcs12_read(file_get_contents($pkcsfile), $opts, $pass)); 24var_dump(openssl_pkcs12_export_to_file($cert_path, $pkcsfile, $priv_path, $pass)); 25var_dump(openssl_pkcs12_read(file_get_contents($pkcsfile), $opts, $pass)); 26var_dump(openssl_pkcs12_export_to_file($cert_res, $pkcsfile, $priv_res, $pass)); 27var_dump(openssl_pkcs12_read(file_get_contents($pkcsfile), $opts, $pass)); 28var_dump(openssl_pkcs12_export_to_file($cert_res, $pkcsfile, $priv_res, $pass, array($cert))); 29var_dump(openssl_pkcs12_read(file_get_contents($pkcsfile), $opts, $pass)); 30 31var_dump(openssl_pkcs12_export_to_file($invalid, $pkcsfile, $invalid, $pass)); 32var_dump(openssl_pkcs12_export_to_file($invalid_path, $pkcsfile, $invalid_path, $pass)); 33var_dump(openssl_pkcs12_export_to_file($priv_res, $pkcsfile, $cert_res, $pass)); 34?> 35--CLEAN-- 36<?php 37$pkcsfile = __DIR__ . "/openssl_pkcs12_export_to_file__pkcsfile.tmp"; 38if (file_exists($pkcsfile)) { 39 unlink($pkcsfile); 40} 41?> 42--EXPECTF-- 43bool(true) 44bool(true) 45bool(true) 46bool(true) 47bool(true) 48bool(true) 49bool(true) 50bool(true) 51 52Warning: openssl_pkcs12_export_to_file(): cannot get cert from parameter 1 in %s on line %d 53bool(false) 54 55Warning: openssl_pkcs12_export_to_file(): cannot get cert from parameter 1 in %s on line %d 56bool(false) 57 58Warning: openssl_pkcs12_export_to_file(): supplied resource is not a valid OpenSSL X.509 resource in %s on line %d 59 60Warning: openssl_pkcs12_export_to_file(): cannot get cert from parameter 1 in %s on line %d 61bool(false) 62