php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68855 Soap Could not connect to host
Submitted: 2015-01-19 11:02 UTC Modified: 2021-09-22 10:03 UTC
Votes:45
Avg. Score:4.4 ± 1.0
Reproduced:39 of 41 (95.1%)
Same Version:16 (41.0%)
Same OS:6 (15.4%)
From: lampacz at gmail dot com Assigned:
Status: Open Package: SOAP related
PHP Version: 5.6.4 OS: Debian wheezy
Private report: No CVE-ID: None
 [2015-01-19 11:02 UTC] lampacz at gmail dot com
Description:
------------
Connecting to SAP https endpoint(https://sap_ip_adress:1802/long_url). After calling soap function (soapclient->function()) getting "Could not connect to host".

PHP version 5.3.3-7+squeeze8 works ok
PHP version 5.4, 5.6.3 doesn't work

Test script:
---------------
$oSC = new SoapClient('sap.wsdl', array(
  'local_cert' => 'sap.crt',
  'location' => 'https://sap_address:8102/sap_url/1.0',
  'user_agent' => 'PHP WS',
  'cache_wsdl' => WSDL_CACHE_NONE,
  'trace' => true,
  'exceptions' => true,
  'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
  'soap_version' => SOAP_1_1
));

$oSC->getInfo();

Expected result:
----------------
Result from getInfo() function

Actual result:
--------------
Could not connect to host

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-09 07:30 UTC] seyferseed at mail dot ru
php 5.6.9 - the same bug
OS - Ubuntu 14.10
 [2015-06-09 07:36 UTC] seyferseed at mail dot ru
Can be fixed with this workaround. Need to add stream context param to SoapClient.

$client = new SoapClient("https://IP:443/sdk/vimService.wsdl",
    array(
        "trace" => 1,
        "location" => "https://IP:443/sdk/",
        'exceptions' => 1,
        "stream_context" => stream_context_create(
            array(
                'ssl' => array(
                    'verify_peer'       => false,
                    'verify_peer_name'  => false,
                )
            )
        )
    ) 
);
 [2015-06-09 08:05 UTC] lampacz at gmail dot com
Of course tried this solution but doesn't work.

$oSC = new SoapClient('sap.wsdl', array(
  'local_cert' => 'sap.crt',
  'location' => 'https://sap_address:8102/sap_url/1.0',
  'user_agent' => 'PHP WS',
  'cache_wsdl' => WSDL_CACHE_NONE,
  'trace' => true,
  'exceptions' => true,
  'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
  'soap_version' => SOAP_1_1,
  'stream_context' => stream_context_create(
    array(
      'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
      )
    )
  )
));
 [2015-06-09 08:12 UTC] seyferseed at mail dot ru
Try to update php to latest 5.6.9 version and perform debian dist-upgrade to latest libs versions.

What does mean parameter 'local_cert' => 'sap.crt'? Try without it.
 [2015-06-09 08:17 UTC] lampacz at gmail dot com
http://php.net/manual/en/soapclient.soapclient.php

For HTTPS client certificate authentication use local_cert and passphrase options

Not possible to use without client https certificate. Certificate is without passphrase
 [2015-06-10 06:39 UTC] seyferseed at mail dot ru
This is my production config for https remote air ticket service, and it is working without any cert, just with pass phrase.

$soapParams = [
            'login'                  => $this->request['user'],
            'password'               => $this->request['password'],
            'trace'                  => true,
            'connection_timeout'     => 10,
            'default_socket_timeout' => 10,
            "exceptions"             => true,
            'soap_version'           => SOAP_1_1,
            'cache_wsdl'             => WSDL_CACHE_NONE,
            'location'               => 'https://link/',
            "stream_context"         => stream_context_create(
                [
                    'ssl' => [
                        'verify_peer'      => false,
                        'verify_peer_name' => false,
                    ]
                ]
            )
        ];
 [2015-06-10 07:40 UTC] lampacz at gmail dot com
This is not my case. I'm using https client certificate (required by server). Your case is ignoring validating https server certificate
 [2021-09-21 12:34 UTC] cmb@php.net
Is this still an issue with any of the actively supported PHP
versions[1]?

[1] <https://www.php.net/supported-versions.php>
 [2021-09-21 12:34 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-09-22 05:29 UTC] lampacz at gmail dot com
-Status: Feedback +Status: Assigned
 [2021-09-22 05:29 UTC] lampacz at gmail dot com
unable to confirm, not using this anymore, it's over 6 years :)
 [2021-09-22 10:03 UTC] cmb@php.net
-Status: Assigned +Status: Open -Assigned To: cmb +Assigned To:
 [2021-09-22 10:03 UTC] cmb@php.net
Thanks for the swift reply!  You are giving us not much
info about the actual problem, though; I mean, how should
we be able to reproduce this, let alone debug?

Given that there are 42 upvotes, there might actually be something
wrong.  Maybe somebody else will provide further details.

> For HTTPS client certificate authentication use local_cert and
> passphrase options
> Not possible to use without client https certificate.
> Certificate is without passphrase

I would have tried an empty passphrase then, rather than not
specifying the option at all.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 22:01:28 2024 UTC