在一台很老的服务器上,调用bing的接口时,出现如下错误,以前都是好好的:
PHP Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://adinsight.api.bingads.microsoft.com/Api/Advertiser/AdInsight/v13/AdInsightService.svc?singleWsdl' : failed to load external entity "https://adinsight.api.bingads.microsoft.com/Api/Advertiser/AdInsight/v13/AdInsightService.svc?singleWsdl"
后面发现Curl也不行,报:Peer certificate cannot be authenticated with known CA certificates 错误。
wget也不行,也报:ERROR: cannot verify certificate。
现在看来是由于系统的根证书无效了(系统太老应该是很多年前的机器了),所以无法判断microsoft的证书的有效性,按如下操作就可以了:
cd /etc/pki/tls/certs wget https://curl.haxx.se/ca/cacert.pem cat cacert.pem >> ca-bundle.crt
思路是去下载一个新的可信证书串(上面是curl的,也可以找一个其它的),把这个串放到系统的可信证书后面去。
如果是在php程序里用curl的话,不用设置操作系统的,可以试试把 https://curl.haxx.se/ca/cacert.pem 下载下来后,再设置php.ini的curl设置
[curl] curl.cainfo=/path/to/downloaded/cacert.pem