This is really far more evil than you might think. Given the research I'm doing, I'm incredibly surprised PayPal is going ahead with this as it's fairly difficult to support in some cases. Unfortunately, there's fairly limited amount of work that I can do to workaround this, though there is something I want to query about the suggested fix (at the end).
The core of the issue is that TLS 1.2 support isn't that pervasive when it comes to the PHP world. If PHP doesn't have support for TLS 1.2, there's nothing XF can legitimately do about that. We'd be looking for TLS 1.2 support in one of two places:
- PHP sockets transports. I can determine this using stream_get_transports() and looking for "tlsv1.2" as far as I can tell. I have an example case where only "tls" is present and this errors when connecting.
- cURL. Essentially, I can't determine whether cURL will support TLS 1.2.
Whether cURL supports TLS really depends on SSL library it was compiled against and the cURL version. For example, when compiled against NSS, TLS > 1.0 isn't supported until 7.34.0. It doesn't appear to be supported with WinSSL until 7.36.0, whereas DarwinSSL got it back in 7.28.0. The constant CURL_SSLVERSION_TLSv1_2 (6) itself isn't supported in cURL until 7.34.0. My understanding is that prior to that, it is equivalent to 0 (CURL_SSLVERSION_DEFAULT) which will attempt to figure out the protocol to use.
In terms of PHP itself, while I believe I can determine whether it's supported as mentioned, this is likely to require OpenSSL newer than 0.9.8. This might not be too arduous, but it's certainly not guaranteed. As an example, MAMP and XAMPP are currently compiled against 0.9.8 (
https://github.com/paypal/PayPal-PHP-SDK/issues/484#issuecomment-176240130). I suspect the PHP using PHP 5.3.3 (which was the bundled RHEL/CentOS version) may well all be compiled against this. Their cURL probably will be too, so they have no workaround short of upgrading to a build that does work.
I think at best we can do the TLS test and provide a big warning if it fails. I believe that if we check for socket support and use that if available and then fallback to cURL (if available) is the extent of the approach that can be taken.
@Xon, are you sure that forcing the SSL version is needed? It should negotiate and figure it out by default. In at least one of our tests so far, it hasn't been needed. PayPal has a quick one liner in their PHP section that you can check:
https://github.com/paypal/TLS-update I don't think the line should necessarily hurt, at least not in the short to medium term, but I just don't think it's necessary.