Php Can';t建立与SOAP unistream的安全连接

Php Can';t建立与SOAP unistream的安全连接,php,security,curl,soap,soap-client,Php,Security,Curl,Soap,Soap Client,我在通过SOAP客户端和curl与Unistream服务交互时遇到问题 我的环境:Ubuntu 15.04,php 5.64 一些历史:unistream的支持要求我们生成认证: makecert.exe-n“CN=some_name”-ss My-r-m 120-pe-sky exchange-a sha1,然后通过mmc端导出并向它们发送证书。好的,我们这样做,得到了他们这边的证书。 我将他们的证书转换为pem格式,并尝试使用的是php SoapClient: $soap = new

我在通过SOAP客户端和curl与Unistream服务交互时遇到问题

我的环境:Ubuntu 15.04,php 5.64

一些历史:unistream的支持要求我们生成认证: makecert.exe-n“CN=some_name”-ss My-r-m 120-pe-sky exchange-a sha1,然后通过mmc端导出并向它们发送证书。好的,我们这样做,得到了他们这边的证书。 我将他们的证书转换为pem格式,并尝试使用的是php SoapClient:

    $soap = new SoapClient("http://test2.unistream.com:82/wcflib-tc/service.svc?wsdl", [
    'encoding' => 'UTF-8',
    'trace' => true,
    'local_cert' => $cert_path,
    'soap_version' => SOAP_1_2,
    'connection_timeout' => 180,
    'cache_wsdl' => WSDL_CACHE_NONE
]);
$data = $soap->GetCountriesChanges(['requestMessage'=>[
        'AuthenticationHeader'=>[
            'AppKey'=>'*',
            'Password'=>'*',
            'Username'=>'*',
        ],
        'UpdateCount'=>1000
    ]]);
我什么都没有。我用python soap库和soapui尝试了同样的方法,但也没有得到任何结果,超时。 好的,我用wireshark查看了一下,看到soap客户机接收到所有xsd模式等,然后在向url发出post请求后连接中断,只是超时。我只看到了带xml的纯http,没有带ssl的数据包。 好的,我尝试在此url上发送post请求:

ini_set('default_socket_timeout', 30);
$request_string =
    '<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"
              xmlns:ns1="http://schemas.datacontract.org/2004/07/WcfServiceLib"
              xmlns:ns2="http://schemas.datacontract.org/2004/07/WcfServiceLib.Utils"
              xmlns:ns3="http://schemas.datacontract.org/2004/07/WcfServiceLib.Dictionaries.Country"
              xmlns:ns4="http://test.unistream.com/wcflib/">
    <env:Body>
        <ns4:GetCountriesChanges>
            <ns4:requestMessage>
                <ns2:AuthenticationHeader>
                    <ns1:AppKey>*</ns1:AppKey>
                    <ns1:Password>*</ns1:Password>
                    <ns1:Username>*</ns1:Username>
                </ns2:AuthenticationHeader>
                <ns3:UpdateCount>1000</ns3:UpdateCount>
            </ns4:requestMessage>
        </ns4:GetCountriesChanges>
    </env:Body>
</env:Envelope>
';

$url = 'http://test2.unistream.com:82/wcflib-tc/service.svc';

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/soap+xml;', 'Charset=utf-8']);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CAPATH, "/path");
//my cert
curl_setopt($ch, CURLOPT_SSLCERT, "/path/local_cert.pem");
//my private key
curl_setopt($ch, CURLOPT_SSLKEY, "/path/local_key.pem");
curl_setopt($ch, CURLOPT_SSLKEYPASSWD, 'passwd');
//api's cert
curl_setopt($ch, CURLOPT_CAINFO, '/path/api_cert.cer'); 
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request_string);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_CERTINFO, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
print_r($result);
echo "\n";
$error = curl_error($ch);
print_r($error);
echo "\n";
ini\u集('default\u socket\u timeout',30);
$request\u字符串=
'
*
*
*
1000
';
$url='1http://test2.unistream.com:82/wcflib-tc/service.svc';
$ch=curl_init();
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_HTTPHEADER,['Content-Type:application/soap+xml;','Charset=utf-8']);
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_CAPATH,“/path”);
//我的证书
curl_setopt($ch,CURLOPT_SSLCERT,“/path/local_cert.pem”);
//我的私钥
curl_setopt($ch,CURLOPT_SSLKEY,“/path/local_key.pem”);
curl_setopt($ch,CURLOPT_SSLKEYPASSWD,'passwd');
//api证书
curl_setopt($ch,CURLOPT_CAINFO,'/path/api_cert.cer');
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,30);
curl_setopt($ch,CURLOPT_POSTFIELDS,$request_string);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,2);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,true);
curl_setopt($ch,CURLOPT_CERTINFO,true);
curl_setopt($ch,CURLOPT_VERBOSE,1);
curl_setopt($ch,CURLOPT_URL,$URL);
$result=curl\u exec($ch);
打印(结果);
回音“\n”;
$error=curl\u error($ch);
打印错误($error);
回音“\n”;
我得到xml时出错:“验证消息安全性时出错。” 如果我尝试向url发送请求:我得到了纯html,错误为400,curl错误为:“错误:140770FC:SSL例程:SSL23\u GET\u SERVER\u HELLO:unknown protocol”

支持帮不了我。他们说“我们有10000个工作客户,我们只咨询高级api问题和业务逻辑”


谁能告诉我正确的方向吗?

我没有unistream的文档

我知道证书是传输层的。这意味着它们比其他任何事情都先发生。但您连接的是HTTP URL,而不是HTTPS URL,这意味着您没有使用加密

证书和加密不是您的问题

但是,您粘贴的URL只是没有侦听该端口上的连接

$curl-v *正在尝试94.127.155.67。。。 *60001毫秒后连接超时 *关闭连接0:(28)连接在60001毫秒后超时

您根本没有使用正确的地址/端口号

下一个
  • 获取正确的url端点
  • 除非端点使用HTTPS,否则不要使用客户端证书