php - 即使提供了匹配的证书,PHP SoapClient 也无法验证_peer
问题描述
我有一个php:8.0.7-apache
码头集装箱。
我正在尝试通过verify_peer
以下设置为我的 SoapClient 使用 ssl 流上下文中的选项:
$stream = stream_context_create([
'ssl' => [
'verify_peer' => true,
'cafile' => '/var/www/html/path/to/certificate.pem.crt',
'verify_peer_name' => false,
'verify_host' => false,
'allow_self_signed' => true
]
]);
$options = [
'trace' => true,
'cache_wsdl' => WSDL_CACHE_NONE,
'exceptions' => true,
'location' => 'https://server.com/endpoint',
'classmap' => $this->getClassMap(),
'stream_context' => $stream,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS
];
我已经通过该选项查看了端点正在使用的证书,并确保它与 SHA256 与我在此命令输出'capture_peer_cert' => true
的选项中放入的证书文件相匹配:cafile
openssl x509 -noout -fingerporint -sha256 -inform pem -in certificate.pem.crt
/usr/local/share/ca-certificates/
我已尝试根据此问题将“cafile”添加到 docker
我尝试添加一个符号链接'cafile'
到/etc/ssl/certs/[FILE_HASH].0
哪里[FILE_HASH]
是输出,openssl x509 -hash -noout -in certificate.pem.crt
然后使用'capath'
选项设置为/etc/ssl/certs
我也尝试将证书安装/导入到 Windows。
openssl 在我的 php 环境中启用(extension_loaded('openssl')
输出true
)
然而,每当'verify_peer' => true
我得到以下 SoapFault 时:
+"faultstring": "Could not connect to host"
+"faultcode": "HTTP"
但是当我有以下流上下文时,它可以正常工作:
$stream = stream_context_create([
'ssl' => [
'verify_peer' => false
]
]);
HTTP/1.0 200 OK
X-Backside-Transport: OK OK
Date: Mon, 30 Aug 2021 02:00:00 GMT
X-Powered-By: Servlet/3.0
Set-Cookie: JSESSIONID=*************************************; Path=/; HttpOnly
Expires: Thu, 01 Dec 1994 16:00:00 GMT
Cache-Control: no-cache="set-cookie, set-cookie2"
Content-Type: text/xml
Content-Language: en-US
Connection: Keep-Alive
Content-Length: ****
我不知道还能尝试什么:(
解决方案
推荐阅读
- sql - SQL Query - 在上面的行中使用值并向下复制
- c# - 如何初始化一个继承接口的类?
- php - PHP CURL 不适用于多维数组
- regex - 提取最后一个单词/文本多个匹配的logstash
- javascript - 导入冲突两个模块反应原生
- reactjs - 带有 react-redux-firebase 的 react-hook-form 不起作用
- android - 如何处理android webview中的firebase动态链接
- python - 在不同版本的 Python 中使用 pip 安装包
- c++ - 将一系列数字映射到 cpp 中的值的简单方法
- angular-material - 在 Angular 8 的 MatIcon 中使用 MatTooltip 导致问题