openssl_csr_export_to_file

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

openssl_csr_export_to_file — CSR をファイルにエクスポートする

説明

function openssl_csr_export_to_file(OpenSSLCertificateSigningRequest|string $csr, string $output_filename, bool $no_text = true): bool

openssl_csr_export_to_file() は、Certificate Signing Request csr を受け取り、 それを output_filename という名前のファイルに PEM フォーマットとして保存します。

パラメータ

csr

使用できる値の一覧は CSR パラメータ を参照ください。

output_filename

出力ファイルへのパス。

no_text

オプションのパラメータ notext を設定すると、出力内容の冗長性が変化します。false を指定すると、 人間が読むための追加情報が出力に含まれるようになります。 notext のデフォルト値は true です。

戻り値

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

変更履歴

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

例

例1 openssl_csr_export_to_file() の例

<?php
$subject = array(
    "commonName" => "example.com",
);
$private_key = openssl_pkey_new(array(
    "private_key_bits" => 2048,
    "private_key_type" => OPENSSL_KEYTYPE_RSA,
));
$csr = openssl_csr_new($subject, $private_key, array('digest_alg' => 'sha384') );
openssl_pkey_export_to_file($private_key, 'example-priv.key');
// Along with the subject, the CSR contains the public key corresponding to the private key
openssl_csr_export_to_file($csr, 'example-csr.pem');
?>

参考

+add a note

User Contributed Notes

There are no user contributed notes for this page.