如何使用PHP函数将.pfx (PKCS12或.p12)证书转换为.crt和.pem,因此我避免使用命令行工具,这在我的公共服务器上是不允许的。
发布于 2019-11-29 13:29:45
<?php
$res = [];
$openSSL = openssl_pkcs12_read($pkcs12, $res, $cert_password);
if(!$openSSL) {
throw new ClientException("Error: ".openssl_error_string());
}
// this is the CER FILE
file_put_contents('CERT.cer', $res['pkey'].$res['cert'].implode('', $res['extracerts']));
// this is the PEM FILE
$cert = $res['cert'].implode('', $res['extracerts']);
file_put_contents('KEY.pem', $cert);https://stackoverflow.com/questions/59099201
复制相似问题