我遇到一个问题,我的 SSL 证书主题名称与目标主机名“匹配”,但仍引发错误
bash-4.1$ curl -X GET --cacert ./server-cert.pem --cert ./client-cert.pem --key ./client-key.pem 'https://PHXC02NX7CBG3QD:9001'
curl: (51) SSL: certificate subject name 'PHXC02NX7CBG3QD' does not match target host name 'PHXC02NX7CBG3QD'
可以看出,两个名字都是匹配的,但由于未知的原因抛出了错误。
任何帮助将不胜感激。预先感谢!
只要在curl请求中传递
CURLOPT_SSL_VERIFYHOST
等于FALSE
$url = 'https://aa.com';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
if (curl_exec($ch) === false) {
echo 'Curl error: ' . curl_error($ch);
} else {
echo 'Operation completed without any errors';
}
$content = curl_exec($ch);
curl_close($ch);