PHP 8.4.1 Released!

运行时配置

这些函数的行为受 php.ini 中的设置影响。

openssl 配置选项
名字 默认 可修改范围 更新日志
openssl.cafile "" INI_PERDIR  
openssl.capath "" INI_PERDIR  
有关 INI_* 样式的更多详情与定义,见 配置可被设定范围

这是配置指令的简短说明。

openssl.cafile string

本地文件系统上证书颁发机构文件的位置, 被用来和对等校验上下文选项一起校验远程对等方的身份。

openssl.capath string

如果没有制定证书颁发机构文件或者证书找不到,将在由capath指向的目录下搜索一个合适的证书。capath 必须是一个正确的已被散列的证书目录。

参见 SSL stream context 选项。

添加备注

用户贡献的备注 2 notes

up
1
mmi at uhb-consulting dot de
6 years ago
in capath the Certificates must be placed with the certificates hash as name and .0 as Ending.

Here is how to get the hashes from Certificates lying in this folder and automatically rename them in a correct way:
<?php
$paths
=openssl_get_cert_locations();
$allowed=array("cer","crt","pem");
if (!empty(
$paths['ini_capath'])){
$capathDirectory = dir($paths['ini_capath']);
while (
false !== ($entry = $capathDirectory->read())) {
$Sourcefile=$paths['ini_capath']."/".$entry;
if (
file_exists( $Sourcefile)){
$path_parts = pathinfo($Sourcefile);
if (
in_array(strtolower($path_parts['extension']),$allowed)){
$ParsedCertificatePbject = openssl_x509_parse(file_get_contents($Sourcefile));
$Sourcefile= $ParsedCertificatePbject["hash"].".0";
$TargetFilename = dirname($Sourcefile)."/".$Sourcefile;
if (!
file_exists($TargetFilename)) {
rename ($Sourcefile ,$TargetFilename);
}
}
}
}
$capathDirectory->close();
}
?>
up
0
ofrick at bluewin dot ch
6 years ago
above code should be corrected to:

$Destfile= $ParsedCertificatePbject["hash"].".0";
$TargetFilename = dirname($Sourcefile)."/".$Destfile;
To Top