Search code examples
phpsslcurletrade-api

Unknown SSL protocol error in connection to etws.etrade.com:443


I am trying to connect to the eTrade API which uses OAuth. I am trying to request a token.

The domain I am trying to connect with has an SSL certificate.

The connection uses TLS 1.2. The connection is encrypted and authenticated using AES_128_GCM and uses ECDHE_RSA as the key exchange mechanism.

Here is the exact error I am getting

Caught exception Error Code : 1001 Error Message : Error no : 35 Error : Unknown SSL protocol error in connection to etws.etrade.com:443 #0 /home/detroitclicks/public_html/etrade/Common/etHttpUtils.class.php(174): etHttpUtils->DoHttpRequest() #1 /home/detroitclicks/public_html/etrade/OAuth/etOAuth.class.php(58): etHttpUtils->GetResponse() #2 /home/detroitclicks/public_html/etrade/Samples/test_etOAuth.php(54): etOAuth->GetRequestToken() #3 {main} Exiting...

I'm not sure if this matters, but I have this set up in one of my php files:

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
    curl_setopt($ch, CURLOPT_SSLVERSION, 3);

Solution

  • The connection uses TLS 1.2.   
    ....
    curl_setopt($ch, CURLOPT_SSLVERSION, 3);
    

    There is a mismatch between the requirement for TLS 1.2 and the explicit setting of version 3 (SSL 3.0) with CURLOPT_SSLVERSION. Just remove this setting and it should try the best it can. It might still fail if your local SSL stack does not support TLS 1.2 yet.