PHP8 openssl_csr_export_to_file

2024-03-11 16:52 更新

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

openssl_csr_export_to_file — 將 CSR 導(dǎo)出到文件

說明

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

openssl_csr_export_to_file() 獲取證書簽名請求()并將之保存在以 命名的 PEM 格式文件中。 csroutput_filename

參數(shù) 

csr

有關(guān)有效值的列表,請參閱 CSR 參數(shù)。

output_filename

輸出文件的路徑。

no_text

可選參數(shù) 影響輸出的冗余度。 如果設(shè)為 false,輸出內(nèi)容將包含附加的人類可讀信息。 的缺省值為 true。 notextnotext

返回值 

成功時返回 true, 或者在失敗時返回 false。

更新日志 

版本說明
8.0.0csr 現(xiàn)在接受 OpenSSLCertificateSigningRequest 實例; 之前接受類型 的 resource。 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');
?>

參見 

  • openssl_csr_export() - 將 CSR 作為字符串導(dǎo)出
  • openssl_csr_new() - 生成一個 CSR
  • openssl_csr_sign() - 用另一個證書簽署 CSR(或者本身)并且生成一個證書


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號