1

We have a site on an old codebase using PHP 5.5 (for now) and one of our integrations we interface with using SoapClient has told us they will be disabling usage of TLS < 1.2 shortly.

Currently our connections are as simple as:

$client = new SoapClient($soap_url);

What do we have to do to make sure only TLS 1.2 requests are sent? I found this answer, but I'm not entirely sure if this still applies to our situation; additionally, not sure we should be forcing Soap 1.1 either?

What are the requirements on our end to make sure we send TLS 1.2 requests?

Brett
  • 19,449
  • 54
  • 157
  • 290

1 Answers1

2

When negotiating the connection with the server, your TLS library, let's assume openSSL, is going to tell the server what your maximum supported version is. The server will then choose a version that it, and the client both support. So, assuming your client system supports TLS1.2 there is probably no action required on your part.

TLS 1.2 support was added to OpenSSL in 1.0.1. If you are on el6 or newer and update your packages you should be fine. Check your version like so:

# openssl version
> OpenSSL 1.0.2k-fips  26 Jan 2017

You can check what protocols/ciphers a server supports with this nmap command:

 nmap --script ssl-enum-ciphers -p 443 stackoverflow.com

Now, if you want to test a failure when using TLS1.1, or force a cipher or something, you will need to use PHP's stream_context_create.

With the code below you can force use of TLS1.2 by setting the crypto_method to STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT. Or, perhaps more useful towards what you are asking, you could test the failure when forcing use of STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT.

<?php
$options = ['trace' => 1,
            'soap_version' => SOAP_1_2,
            'exceptions' => true,
            'location' => 'https://stackoverflow.com/foo',
            'uri' => "https://stackoverflow.com/bar",
            'stream_context' => stream_context_create([
                'ssl'=> [
                    'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT,
                    'ciphers' => 'SHA256'                        
                 ]
             ])];

$client = new SoapClient(null, $options);

try {
    $response = $client->getFoo();    
} catch (\Exception $e){    
    var_dump($client->__getLastRequest());
    var_dump($client->__getLastResponse());
    throw $e;
}


//OR, an even easier test with out a Soap Client...
$opts = [
         'ssl'=> [
             'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT,
             'ciphers' => 'SHA256',
             'verify_peer' => false,
             'verify_peer_name' => false
         ]
     ];

$context = stream_context_create($opts);
$fp = fopen('https://stackoverflow.com', 'r', false, $context);

If things work with 1.2 and you can generate an error forcing say 1.1 then you can be pretty confident things are setup fine. Errors would be along the lines of:

Warning: fopen(): SSL operation failed with code 1. OpenSSL Error messages: error:140830B5:SSL routines:ssl3_client_hello:no ciphers available

fopen(): Failed to enable crypto

When talking about SOAP version 1.1 vs 1.2 those are just different W3C standards for the Simple Object Access Protocol. More on some of the differences can be found here.

I will just say in closing I've not tested this in PHP 5.5, that is such an old version that these days I don't have an easy way to spin it up. Think this would all still be applicable however.

ficuscr
  • 6,975
  • 2
  • 32
  • 52
  • Thanks very much. I checked the OpenSSL version and got `OpenSSL 1.0.2k-fips 26 Jan 2017`, so sounds ok there. I then tried the _nmap command_ but got an error: `nmap: command not found`. From what you're saying though, if it appears the server supports TLS 1.2 then we shouldn't really need to force it by using `stream_context_create` correct? – Brett Jun 10 '19 at 23:02
  • Correct. An up-to-date client, like a current web browser, should just work. nmap can be installed by your package manager. – ficuscr Jun 10 '19 at 23:54
  • So it's not just up to our server, it's also dependent in the client browser being used, which we can't do anything about? – Brett Jun 11 '19 at 18:44
  • I was just making the comparison. A web browser connecting to a server and making a secure connection, being like your server making a secure connection over cURL to another server. As long as your server isn't the equivalent of IE6 you are likely to be OK. You are correct though, if for example a web server requires TLS 1.2 some [older mobile device web browsers](https://caniuse.com/#feat=tls1-2) could end up not being able to connect over HTTPS. – ficuscr Jun 11 '19 at 22:35
  • To be clear, using a server side http client like cURL, the end user's web browser is not a factor. Their browser is not making the connection, your web server is. Didn't mean to confuse matters/ – ficuscr Jun 11 '19 at 22:41
  • Alright - thanks a lot. Thanks for clearing that up. :) – Brett Jun 12 '19 at 13:36