Change TLS version in PHP upload

Asked

Viewed 392 times

1

My submission is returning this error ...

Warning: file_get_contents(https://webto.salesforce.com/servlet/servlet.WebToLead...): failed to open stream: HTTP request failed! HTTP/1.1 400 TLS 1.1 or Higher required in /home/Storage/9/8e/3d/teste1124/public_html/tpl/site.php on line 124

$context = stream_context_create(array(
    'http' => array(    
        'method'  => 'POST',
        'content' => $content,
    )
));

$result = file_get_contents('https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8', null, $context);

And it looks like the file_get_contents request is using TLS 1.0, which stopped being supported by Salesforce...

Note 01 ... The line 124 of the error, in Cód is the line $result = file_get_contents , above.

I rode like this so I could test ................................................................................

$context = stream_context_create([array(
     'http' => array(                                                       
         'method'  => 'POST',
         'content' => $content,
     ),
     'ssl' => [
          'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT |
                             STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT,
     ],
)]);

$result = file_get_contents('https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8', false, $context);

ERROR === Warning: stream_context_create(): options should have the form ["wrappername"]["optionname"] = $value in /home/Storage/9/8e/3d/teste1124/public_html/tpl/index.php on line 126

Obs 02 ... A line 126 === )]); from Cód. above.

How can I correct and correctly adjust my submission ? I’m mounting wrong shipment or what will be ?

  • Hello Paul, what version of PHP you are using and what is your hosting operating system?

  • @Guilherme Nascimento The server version is PHP Version 5.4.45 & Linux

  • I understand, is that if it was 5.6 some things might be different (SSL in question), but being 5.4 or 5.5 can be solved more easily. I’ll draw up a response

  • Yes, I’m just installing PHP5.4 here to create a functional example for you, my internet is slow and I only have PHP7.1 which is different from 5.4. I saved your question in the favorites so I don’t forget, until soon.

  • @Paulomaia Is there a specific reason that prevents you from using Curl? I believe it would be much easier, since just use CURLOPT_SSLVERSION.

  • That’s not gonna work after all 3 is not TLS 1.1. Switch to CURL_SSLVERSION_TLSv1_2, so that curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);

  • Then specify the 3 is the same as the Sslv3 version. Sslv3 predates TLS 1.1. The site requires you to use TLS 1.1 or higher, so use CURL_SSLVERSION_TLSv1_2 or CURL_SSLVERSION_TLSv1_1. If you really want to use numbers instead of constants, use 5 or 6. But don’t use it 3....

  • No Answer , Someone ?

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.