略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: openssl_pkey_export_to_file

2024-04-30

openssl_pkey_export_to_file

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

openssl_pkey_export_to_file将密钥导出到文件中

说明

openssl_pkey_export_to_file(
    mixed $key,
    string $outfilename,
    string $passphrase = ?,
    array $configargs = ?
): bool

openssl_pkey_export_to_file() 将 ascii 格式 (PEM编码)的 key 保存到名为outfilename文件中。

注意: 必须安装有效的 openssl.cnf 以保证此函数正确运行。参考有关安装的说明以获得更多信息。

参数

key

outfilename

输出文件的路径。

passphrase

密钥可以通过值为passphrase的密码来保护。

configargs

configargs 可以用来调整导出流程,通过指定或者覆盖openssl配置文件选项。参见 openssl_csr_new() 获取更多关于 configargs 的信息。

返回值

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

add a noteadd a note

User Contributed Notes 2 notes

up
-3
StampyCode
5 years ago
On Linux (PHP5.6), this function will overwrite an existing keyfile, unless the keyfile is marked as read-only, in which case you will get an error:

    error:0200100D:system library:fopen:Permission denied
up
-6
w3ricardo
10 years ago
You can't use this function to export a public key

Warning: openssl_pkey_export_to_file(): supplied key param is a public key

官方地址:https://www.php.net/manual/en/function.openssl-pkey-export-to-file.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3