CakeFest 2024: The Official CakePHP Conference

openssl_pkey_export_to_file

(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)

openssl_pkey_export_to_fileエクスポート可能な形式で、キーをファイルに取得する

説明

openssl_pkey_export_to_file(
    OpenSSLAsymmetricKey|OpenSSLCertificate|array|string $key,
    string $output_filename,
    ?string $passphrase = null,
    ?array $options = null
): bool

openssl_pkey_export_to_file() は、ASCII 変換された (PEM エンコードされた) keyoutput_filename のファイルに保存します。

注意: この関数を正しく動作させるには、正しい形式の openssl.cnf をインストールしておく必要があります。 詳細な情報は、インストールについてのセクション を参照ください。

パラメータ

key

output_filename

出力ファイルへのパス。

passphrase

オプションで passphrase を使用してキーを保護することが可能です。

options

options により openssl 設定ファイルの設定を 追加したり上書きしたりすることで、エクスポート処理の詳細設定が可能です。 options についての詳細な情報は openssl_csr_new() を参照ください。

戻り値

成功した場合に true を、失敗した場合に false を返します。

変更履歴

バージョン 説明
8.0.0 key は、 OpenSSLAsymmetricKey または OpenSSLCertificate クラスのインスタンスを受け入れるようになりました。 これより前のバージョンでは、 OpenSSL key または OpenSSL X.509 型のリソースを受け入れていました。
add a note

User Contributed Notes 2 notes

up
-7
w3ricardo
12 years ago
You can't use this function to export a public key

Warning: openssl_pkey_export_to_file(): supplied key param is a public key
up
-7
StampyCode
7 years ago
On Linux (PHP5.6), this function will overwrite an existing keyfile, unless the keyfile is marked as read-only, in which case you will get an error:

error:0200100D:system library:fopen:Permission denied
To Top