PHP 8.5.2 Released!

运行时配置

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

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

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

openssl.cafile string

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

openssl.capath string

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

openssl.libctx string
指定要使用的 OpenSSL 库上下文类型。默认值 custom 会为每个工作进程或线程创建独立的库上下文。从而增强与其他使用 OpenSSL 的库之间的隔离性,并在 ZTS 构建中提升线程间的分离程度。也可选择 default 值,使 PHP 使用 OpenSSL 的全局默认库上下文。

参见 SSL stream context 选项。

添加备注

用户贡献的备注 2 notes

up
1
mmi at uhb-consulting dot de
7 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
7 years ago
above code should be corrected to:

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