开发者

PHP SOAP SSL problems

开发者 https://www.devze.com 2023-03-31 16:55 出处:网络
I\'m trying to connect to a secure SOAP server using NuSOAP.(I gave the built-in SOAP library a chance, but that was behaving strangely, so I switched to NuSOAP.)

I'm trying to connect to a secure SOAP server using NuSOAP. (I gave the built-in SOAP library a chance, but that was behaving strangely, so I switched to NuSOAP.)

Here's my code:

require('application/libraries/nusoap/nusoap.php');
$soap = new nusoap_client('https://ws.firstdataglobalgateway.com/fdggwsapi/services/order.wsdl', 'wsdl');
$soap->setCredentials('WS'.STORE_NUMBER.'._.1',
    PASSWORD,
    'certificate',
    array(
        'sslcertfile' => 'first_data/cert.pem',
        'sslkeyfile' => 'first_data/key.pem',
        'passphrase' => KEY_PASSPHRASE
    )
);
if($err = $soap->getError()) {
    die('Error: '.$err);
}
$result = $soap->call('fdggwsapi:FDGGWSApiOrderRequest', array('v1:Transaction' => '1'));
if($soap->fault) {
    echo 'Fault! <pre>';
    var_dump($result);
    echo '</pre>';
} else {
    if($err = $soap->getError()) {  
        die('Error: '.$err);
    } else {
        echo '<pre>';
        var_dump($result);
        die('</pre>');
    }
}

I get the following error:

Error: wsdl error: Getting https://ws.firstdataglobalgateway.com/fdggwsapi/services/order.wsdl - HTTP ERROR: cURL ERROR: 56: SSL read: error:1409441B:SSL routines:SSL3_READ_BYTES:tlsv1 alert decrypt error, errno 0
url: https://ws.firstdataglobalgateway.com:443/fdggwsapi/services/order.wsdl
content_type: 
http_code: 0
header_size: 0
request_size: 163
filetime: -1
ssl_verify_result: 0
redirect_count: 0
total_time: 0.531131
namelookup_time: 0.00121
connect_time: 0.070608
pretransfer_time: 0.305044
size_upload: 0
size_download: 0
speed_download: 0
speed_upload: 0
download_content_length: -1
upload_content_length: 0
starttransfer_time: 0
redirect_time: 0

What could be the possible problems? 开发者_JS百科 How could I debug this? I'm rather out of my league here.


Based on the error:

SSL read: error:1409441B:SSL routines:SSL3_READ_BYTES:tlsv1 alert 
decrypt error, errno 0

It looks to me like the PHP library is having trouble reading your cert.pem and key.pem files. These files can come in different formats. Apache requires that these be in PKCS12 format and I would guess PHP is the same. You can use a tool called "Keystore Explorer 4.0.1" to verify and convert if necessary.

You can verify the validity of the format of the keys also, using openssl and this command:

C:\Temp> openssl pkcs12 -info -in ksb_cert.p12


With this settings my client working finally

$client = new nusoap_client($wsdlurl,'wdsl');
$client->setUseCURL(true);
$client->useHTTPPersistentConnection();
$client->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0);
$client->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0);
$client->setCurlOption(CURLOPT_RETURNTRANSFER, 1);
$client->setCurlOption(CURLOPT_SSLVERSION,3);

0

精彩评论

暂无评论...
验证码 换一张
取 消