swoole-cli icon indicating copy to clipboard operation
swoole-cli copied to clipboard

openssl 证书路径

Open matyhtf opened this issue 1 year ago • 3 comments

macOS 下会指向 ~/.swoole_cli/openssl/ssl ,linux 会指向 /usr/openssl/ssl

用户需要创建软连接,可在编译 openssl 时指定证书路径,直接使用操作系统的证书

matyhtf avatar Mar 22 '23 03:03 matyhtf

除了上述办法以外,还可以使用如下几种方式

创建证书

mkdir -p /etc/ssl/

wget https://curl.se/ca/cacert.pem  -O /etc/ssl/cacert.pem

指定证书方式一:

./swoole-cli  -d 'curl.cainfo="/etc/ssl/cacert.pem"' -d 'openssl.cafile="/etc/ssl/cacert.pem"'  your_application.php

指定证书方式二:

# 生成 php 配置文件
cat > /etc/my_custom.ini <<EOF
curl.cainfo="/etc/ssl/cacert.pem"
openssl.cafile="/etc/ssl/cacert.pem"
EOF

./swoole-cli  -c /etc/my_custom.ini  your_application.php

指定证书方式三:

$ca='/root/cacert.pem';
curl_setopt($ch, CURLOPT_CAINFO, $ca);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);

jingjingxyk avatar Mar 23 '23 10:03 jingjingxyk

还可以在编译 swoole-cli 时添加这个参数: 运行环境创建这个目录,并在 /usr/local/swoole-cli/etc/ 创建 php.ini 文件

--with-config-file-path=/usr/local/swoole-cli/etc/ 

jingjingxyk avatar May 26 '23 12:05 jingjingxyk

还可以这样


export PHP_INI_SCAN_DIR=/usr/local/swoole-cli/etc/

jingjingxyk avatar May 26 '23 19:05 jingjingxyk