- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在从 PHP 5.6 升级到 PHP 7.3,PHP 7.3 中的 SoapClient 似乎忽略了 ssl verify_peer
选项。
在 PHP 5.6 中,以下代码会正常执行:
$opts = [
'ssl' => [
'crypto_method' => STREAM_CRYPTO_METHOD_TLS_CLIENT,
'verify_peer' => false,
],
];
$stream_context = stream_context_create($opts);
$options = [
'stream_context' => $stream_context,
];
$client = new SoapClient("https://...?wsdl", $options);
$client->SomeMethod();
在 PHP 7.3 中执行相同的代码会导致 PHP fatal error :未捕获的 SoapFault 异常:[WSDL] SOAP-ERROR:解析 WSDL:无法从“https://...?wsdl”加载:无法加载外部实体“https://...?wsdl”
我试过在 $opts
中包含 verify_peer_name => false
; allow_self_signed => true
(虽然证书不是自签名的 - 只是没有由运行代码的机器上的任何受信任证书签名)。我还尝试包括签署远程证书的根 CA 的 cafile
(.pem 格式),以及整个证书链(.pem 格式)。此外,我尝试包含 capath
选项,指向我保 stub CA 以及证书链的目录。
如果我尝试通过提供 uri
和 location
来绕过下载 wsdl,我会收到错误 PHP Fatal error: Uncaught SoapFault exception: [HTTP]无法连接到主机...
到目前为止,我还没有发现 5.6 和 7.3 之间的任何差异可以解释我所看到的行为差异。
最佳答案
在这上面花费了太多时间之后,PHP 7 似乎确实尊重 stream_context
verify_peer
选项。问题的根源在于协商连接时使用的“默认”密码在 PHP 5.6 和 PHP 7.3 之间发生了变化。明确调用要使用的密码允许 SoapClient 在 PHP 7.3.7 中进行通信。
$opts = [
'ssl' => [
'crypto_method' => STREAM_CRYPTO_METHOD_TLS_CLIENT,
'verify_peer' => false,
'ciphers' => 'RC4-SHA',
],
];
$stream_context = stream_context_create($opts);
$options = [
'stream_context' => $stream_context,
];
$client = new SoapClient("https://...?wsdl", $options);
$client->SomeMethod();
关于忽略 PHP 7.3 SoapClient stream_context (verify_peer),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57083821/
我想使用第三方的网络服务。要使用 Web 服务,我需要使用 HTTPS 连接。我的问题是,对于开发过程,我有一个带有无效证书的测试 api。我想设置 SoapClient no 来验证服务器的证书。这
我猜想 PHP 的 get_headers 不允许使用上下文,所以我必须更改默认流上下文以仅获取请求的 HEAD。这会导致页面上的其他请求出现一些问题。我似乎无法弄清楚如何重置默认流上下文。我正在尝试
我必须向 iOS 设备发送推送通知。我的连接必须通过代理启用。我尝试了一切但没有成功。我有一个错误 110 连接超时。如果我只是尝试连接到 Apple 推送的地址,它可以与 cURL 一起使用。我不知
我正在从 PHP 5.6 升级到 PHP 7.3,PHP 7.3 中的 SoapClient 似乎忽略了 ssl verify_peer 选项。 在 PHP 5.6 中,以下代码会正常执行: $opt
我是一名优秀的程序员,十分优秀!