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|string $certificate,
    string $output_filename,
    OpenSSLAsymmetricKey|OpenSSLCertificate|array|string $private_key,
    string $passphrase,
    array $options = []
): bool

openssl_pkcs12_export_to_file()PKCS#12 文件格式将 certificate 保存至 output_filename 文件中。

参数

x509

参见密钥/证书参数以获取有效值列表。

output_filename

输出文件的路径。

private_key

PKCS#12 文件的私钥部分。 参见 公/私钥参数 获取可用值的列表。

passphrase

用于解锁 PKCS#12 文件的加密密码。

options

可选数组,其他主键将被忽略。

Key 说明
"extracerts" PKCS#12 文件中包含的额外证书或单个证书的数组。
"friendly_name" 被证书和密钥使用的字符串

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 certificate 现在接受 OpenSSLCertificate 实例;之前接受类型 OpenSSL X.509 CSRresource
8.0.0 private_key 现在接受 OpenSSLAsymmetricKeyOpenSSLCertificate 实例;之前接受类型 OpenSSL keyOpenSSL X.509resource
add a note add a note

User Contributed Notes 2 notes

up
0
greejd
5 years ago
please note
the key 'friendlyname' should be 'friendly_name' in args

$args = array(
        'friendly_name'=> 'www.example.com'
);
up
0
lampacz at gmail dot com
14 years ago
[, array $args ]  can contain only: extracerts, friendly_name

extracerts - additional certificates (can be file or string)
friendly_name - "friendly name" for the certificate and private key. This name is typically displayed in list boxes by software importing the file.

based on source code version 5.2.8 and pkcs12 man page
To Top