2024 年 PHP Conference Japan

openssl_pkcs12_export_to_file

(PHP 5 >= 5.2.2, PHP 7, PHP 8)

openssl_pkcs12_export_to_file匯出 PKCS#12 相容的憑證儲存檔案

說明

openssl_pkcs12_export_to_file(
    OpenSSLCertificate|字串 $certificate,
    字串 $output_filename,
    #[\SensitiveParameter] OpenSSLAsymmetricKey|OpenSSLCertificate|陣列|字串 $private_key,
    #[\SensitiveParameter] 字串 $passphrase,
    陣列 $options = []
): 布林值

openssl_pkcs12_export_to_file()certificatePKCS#12 檔案格式儲存至名為 output_filename 的檔案中。

參數

x509

請參閱 金鑰/憑證參數 以取得有效值的列表。

output_filename

輸出檔案的路徑。

private_key

PKCS#12 檔案的私鑰元件。請參閱 公開/私鑰參數 以取得有效值的列表。

passphrase

用於解鎖 PKCS#12 檔案的加密密碼。

options

可選的陣列,其他鍵值將被忽略。

鍵值 說明
"extracerts" 要包含在 PKCS#12 檔案中的額外憑證陣列或單一憑證。
"friendly_name" 用於提供的憑證和金鑰的字串

回傳值

成功時回傳 true,失敗時回傳 false

更新日誌

版本 說明
8.0.0 certificate 現在接受 OpenSSLCertificate 實例;先前接受類型為 OpenSSL X.509 CSR資源
8.0.0 private_key 現在接受 OpenSSLAsymmetricKeyOpenSSLCertificate 實例;先前接受類型為 OpenSSL keyOpenSSL X.509資源
新增註記

使用者貢獻的註記 2 則註記

greejd
5 年前
請注意
參數中,鍵值 'friendlyname' 應為 'friendly_name'

$args = array(
'friendly_name'=> 'www.example.com'
);
lampacz at gmail dot com
15 年前
[, array $args ] 只能包含:extracerts、friendly_name

extracerts - 額外的憑證(可以是檔案或字串)
friendly_name - 憑證和私鑰的「顯示名稱」。此名稱通常會由匯入檔案的軟體顯示在列表框中。

基於原始程式碼版本 5.2.8 和 pkcs12 使用手冊頁面
To Top