这已经让我发疯了 2 天 - 我有 2 个 PHP 函数,如下所述,它们都使用 curl。它们指向完全相同的“XML 网关”,唯一的区别是一个尝试通过 SSL 进行,另一个尝试通过未加密的 HTTP。
HTTP 连接器操作符完全按预期工作,发布 XML 文件并返回服务器响应。
SSL 连接器返回非常模糊的“发生内部服务器错误”。请稍后再试'。我的 lighttpd 错误日志中没有显示任何内容,有人有什么好主意吗?
我想知道这是否是我的网络服务器配置/openSSL 配置。它们都是 Debian Wheezy 标准软件包。我很欣赏 SSL_VERIFYPEER & HOST 设置为销售是不安全的,但是我一直在尝试用尽这些选项。
openssl s_client -connect xmlgw.companieshouse.gov.uk:443 -ssl3
和命令行功能
curl https://xmlgw.companieshouse.gov.uk/v1-0/xmlgw/Gateway
也可以在 Web 服务器上按预期工作。
PHP函数:
//SSL post function
public function getSSLCurlResponse($xml) {
$url = "https://xmlgw.companieshouse.gov.uk/v1-0/xmlgw/Gateway";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSLVERSION,3);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
//HTTP non SSL function
public function getCurlResponse($xml) {
$url = "http://xmlgw.companieshouse.gov.uk/v1-0/xmlgw/Gateway";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
任何帮助将非常感激!
谢谢