【问题标题】:libCURL:: SSL: certificate subject name 'Common Name (eg, YOUR name)' does not match target host name ... but the CN and the target name matchlibCURL:: SSL: 证书主题名称“通用名称(例如,您的名称)”与目标主机名不匹配...但 CN 和目标名称匹配
【发布时间】:2015-02-04 16:09:20
【问题描述】:

所以首先是错误代码:

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 Secure Certificate Authority - G2 的高级 SSL 证书

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】:

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

    我们网站的运作方式是,如果您点击它,但没有使用网站的正确 URL,它会将您转发到正确的 URL。

    由于此脚本是从托管该站点的同一框访问该站点,因此它试图访问“本地主机”。然后我们的网站会发现 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 = Common Name (eg, YOUR name)”后,此错误开始变得有意义......

    因此,总而言之,脚本使用的是防火墙的证书,而不是 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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-08-20
      • 1970-01-01
      • 2020-11-15
      • 2020-11-14
      • 2021-07-07
      相关资源
      最近更新 更多