PHP CURL SSL 连接到 XML 网关


PHP CURL SSL Connecting to XML Gateway

这已经让我疯狂了 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;
}

任何帮助将不胜感激!

谢谢

我得出的结论是,这是与服务器的整体连接中的一个错误 - 尽管我找不到任何方法来证明这一点。 我已经设法在不使用SSL套接字的情况下找到了替代解决方案。