You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PHP 5.6升级后Peer证书CN不匹配错误解决方法求助

Hi Bob,

Let's work through this frustrating issue you're hitting after upgrading PHP to 5.6 on your shared host. It's confusing that disabling SSL verification in HTTP_Request2 works on your Synology test setup but not in production—let's break down targeted fixes to get this sorted:

Double-check configuration application and order

First, confirm you're calling setConfig() after initializing the request but before sending it. Accidentally overwriting these settings with later configuration calls is an easy mistake to make. Also, double-check for typos in the config keys (they’re case-sensitive: ssl_verify_peer and ssl_verify_host are the correct names).

Force the socket backend

HTTP_Request2 uses either socket or curl as its underlying backend, and shared hosts sometimes have curl configurations that override request-specific settings. Try explicitly specifying the socket backend when creating your request:

$query = new HTTP_Request2($url, HTTP_Request2::METHOD_GET, array(
    'connect_timeout' => 2,
    'timeout' => 4,
    'backend' => 'socket'
));
$query->setConfig(array(
    'ssl_verify_peer' => FALSE,
    'ssl_verify_host' => FALSE,
));

Manually configure curl adapter options (if using curl backend)

If you need to stick with the curl backend, directly set curl’s native SSL options via the adapter. This bypasses any potential gaps in how HTTP_Request2 maps its own config to curl’s flags:

$query = new HTTP_Request2($url, HTTP_Request2::METHOD_GET, array(
    'connect_timeout' => 2,
    'timeout' => 4
));
$adapter = new HTTP_Request2_Adapter_Curl();
$adapter->setOptions(array(
    CURLOPT_SSL_VERIFYPEER => false,
    CURLOPT_SSL_VERIFYHOST => 0, // 0 disables host name verification entirely
));
$query->setAdapter($adapter);

Check shared host global PHP SSL settings

Some shared hosts enforce SSL verification at the php.ini level (via directives like openssl.cafile, openssl.capath, or curl.cainfo). These global settings can override your request-level configurations. You can check current settings with phpinfo(), and if your host allows it, override them in a local .user.ini file:

curl.cainfo = ""
openssl.cafile = ""

Note: Only do this if your security requirements are truly low, as it weakens SSL security globally for your application.

Update HTTP_Request2 to the latest stable version

Older versions of HTTP_Request2 might have bugs in handling SSL verification flags in PHP 5.6. Updating to the latest stable release (via Composer or manual download) could resolve the mismatch between your test and production environments.

The discrepancy between your Synology setup and shared host is likely due to differences in backend defaults, PHP configuration, or HTTP_Request2 version—shared hosts often have more restrictive or customized setups than self-managed NAS systems.

内容的提问来源于stack exchange,提问作者Bob

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:07:34