libCURL::SSL:证书使用者名称';常用名称(例如,您的姓名)';与目标主机名不匹配..但是CN和目


libCURL:: SSL: certificate subject name 'Common Name (eg, YOUR name)' does not match target host name ... but the CN and the target name match

所以首先是错误代码:

string(345) "
404 - Not Found
" 
0
SSL: certificate subject name 'Common Name (eg, YOUR name)' does not match target host name 'www.example.com'

这是使用以下测试脚本发现的。

<?php
$request=<<<EOT
EOT;
$c = curl_init("https://www.example.com");
curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($c, CURLOPT_POST, "POST");
curl_setopt($c, CURLOPT_POSTFIELDS, $request);
curl_setopt ($c, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($c, CURLOPT_SSL_VERIFYHOST, 2);
ob_start();
curl_exec($c);
$response = ob_get_contents();
ob_end_clean();
$curlErrorCode = curl_errno($c);
$error = curl_error($c);
var_dump($response);
echo "<br>";
echo $curlErrorCode."<br>";
echo $error."<br>";
curl_close ($c);
?>

实际的网站名称已经更改,但我已经反复检查了证书和名称是否匹配。这是来自Starfield安全证书颁发机构的高级SSL证书-G2

Subject section of SSL CERT 
    CN = www.example.com
    O = EXAMPLE, INC.
    L = City
    S = State
    C = US
    SERIALNUMBER = 19xxxxxxxx
    2.5.x.xx = Private Organization
    1.3.x.x.x.x.xxx.xx.x.x.x = State
    1.3.x.x.x.x.xxx.xx.x.x.x = US

为了让我们的支付系统合规,这个脚本必须干净地运行(这个网站不是实时的,所以我们不接受不合规的付款)。但我一直没能把它弄清楚。有人知道为什么吗?

更多信息:

OS = MS Server 2012_R2
Platform = Hyper-v Virtual Instance (Hyper-v is installed on metal on MS Server 2012_R2)
Service = IIS 6.2 (build 9200)
Certificate is installed on IIS and bound to website. 

好的,我能够解决这个问题。就我而言,这与卷曲或证书无关。

我们网站的功能是,如果你点击了它,但没有使用正确的网站URL,它会将你转发到正确的URL。

由于此脚本是从承载该站点的同一个框访问该站点的,因此它试图访问"localhost"。然后我们的网站会找到URL的错误,并将您转发到正确的"www.example.com"URL。

由于它被转发到URL,脚本最终被转发到的DNS地址为其提供了站点的外部IP地址。

转发后,防火墙上触发了DNS重新绑定错误,因为它位于防火墙内部。因此,将脚本登录到我们防火墙的错误页面上。

原始错误:

SSL: certificate subject name 'Common Name (eg, YOUR name)' does not match target host name 'www.example.com'

在我发现防火墙已恢复到其默认证书"CN=通用名称(例如,您的名称)"后,这个错误开始变得有意义。。。

因此,总之,脚本使用的是防火墙的证书,而不是www.example.com的证书!

为了解决这个问题,我更新了托管服务器的DNS条目以反映www.example.com = 127.0.0.1

之后,脚本能够避免转发到外部地址,避免DNS重新绑定错误,并最终能够为www.example.com 找到正确的证书

设置信息:

pfSense Firewall
X-Cart eCommerce platform w/ X-Payments
Windows Server 2012_R2
IIS 6.2 (build 9200)