首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

openssl_csr_export_to_file

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

openssl_csr_export_to_file - 将 CSR 导出到文件

描述

代码语言:javascript
复制
bool openssl_csr_export_to_file ( mixed $csr , string $outfilename [, bool $notext = true ] )

openssl_csr_export_to_file()采用由csrPEM 格式表示的证书签名请求并将其保存为名为outfilename的文件。

参数

csr

请参阅 CSR 参数以获取有效值列表。

outfilename

输出文件的路径。

notext

可选参数notext影响输出的详细程度; 如果是FALSE,则输出中会包含额外的人类可读信息。notextis 的默认值TRUE

返回值

TRUE成功或FALSE失败时返回。

例子

示例#1 openssl_csr_export_to_file()示例

代码语言:javascript
复制
<?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');
?>

扫码关注腾讯云开发者

领取腾讯云代金券