(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)
openssl_csr_export_to_file — CSR をファイルにエクスポートする
openssl_csr_export_to_file() は、Certificate
Signing Request csr
を受け取り、
それを outfilename
という名前のファイルに
PEM フォーマットとして保存します。
csr
使用できる値の一覧は CSR パラメータ を参照ください。
outfilename
出力ファイルへのパス。
notext
オプションのパラメータ notext
を設定すると、出力内容の冗長性が変化します。false
を指定すると、
人間が読むための追加情報が出力に含まれるようになります。
notext
のデフォルト値は true
です。
成功した場合に true
を、失敗した場合に false
を返します。
例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');
?>