Download src/php/php-src/ext/openssl/tests/001.phpt from meddyrat/dis-bench: direct link, hf CLI and curl.
- Browser
- Download file 2.23 kB
-
https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/ext/openssl/tests/001.phpt
- Command line
-
hf download hf://datasets/meddyrat/dis-bench/src/php/php-src/ext/openssl/tests/001.phpt
-
curl -L -o 001.phpt https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/ext/openssl/tests/001.phpt
2.23 kB
| --TEST-- | |
| OpenSSL private key functions | |
| --EXTENSIONS-- | |
| openssl | |
| --SKIPIF-- | |
| if (!@openssl_pkey_new()) die("skip cannot create private key"); | |
| --FILE-- | |
| echo "Creating private key\n"; | |
| $conf = array('config' => __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf'); | |
| $privkey = openssl_pkey_new($conf); | |
| if ($privkey === false) { | |
| die("failed to create private key"); | |
| } | |
| $passphrase = "banana"; | |
| $key_file_name = __DIR__ . '/001-tmp.key'; | |
| if ($key_file_name === false) { | |
| die("failed to get a temporary filename!"); | |
| } | |
| echo "Export key to file\n"; | |
| if (!openssl_pkey_export_to_file($privkey, $key_file_name, $passphrase, $conf)) { | |
| die("failed to export to file $key_file_name"); | |
| } | |
| var_dump($privkey instanceof OpenSSLAsymmetricKey); | |
| echo "Load key from file - array syntax\n"; | |
| $loaded_key = openssl_pkey_get_private(array("file://$key_file_name", $passphrase)); | |
| if ($loaded_key === false) { | |
| die("failed to load key using array syntax"); | |
| } | |
| openssl_pkey_free($loaded_key); | |
| echo "Load key using direct syntax\n"; | |
| $loaded_key = openssl_pkey_get_private("file://$key_file_name", $passphrase); | |
| if ($loaded_key === false) { | |
| die("failed to load key using direct syntax"); | |
| } | |
| openssl_pkey_free($loaded_key); | |
| echo "Load key manually and use string syntax\n"; | |
| $key_content = file_get_contents($key_file_name); | |
| $loaded_key = openssl_pkey_get_private($key_content, $passphrase); | |
| if ($loaded_key === false) { | |
| die("failed to load key using string syntax"); | |
| } | |
| openssl_pkey_free($loaded_key); | |
| echo "OK!\n"; | |
| --CLEAN-- | |
| $key_file_name = __DIR__ . DIRECTORY_SEPARATOR . '001-tmp.key'; | |
| @unlink($key_file_name); | |
| --EXPECTF-- | |
| Creating private key | |
| Export key to file | |
| bool(true) | |
| Load key from file - array syntax | |
| Deprecated: Function openssl_pkey_free() is deprecated since 8.0, as OpenSSLAsymmetricKey objects are freed automatically in %s on line %d | |
| Load key using direct syntax | |
| Deprecated: Function openssl_pkey_free() is deprecated since 8.0, as OpenSSLAsymmetricKey objects are freed automatically in %s on line %d | |
| Load key manually and use string syntax | |
| Deprecated: Function openssl_pkey_free() is deprecated since 8.0, as OpenSSLAsymmetricKey objects are freed automatically in %s on line %d | |
| OK! | |