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

问题描述 投票:0回答:1

所以首先是错误代码:

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. 
php ssl libcurl x-cart pfsense
1个回答
1
投票

好,我能够解决此问题。就我而言,它与curl或证书无关。

如果您点击我们的网站,但未使用正确的网站网址,我们的网站就会自动将您转到正确的网址。

由于此脚本从托管站点的同一框中访问该站点,因此它试图访问'localhost'。然后我们的网站将找到哪个URL错误,并将您转发到正确的“ www.example.com” URL。

由于将其最终转发到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)
© www.soinside.com 2019 - 2024. All rights reserved.