Skip to content
Snippets Groups Projects
Commit 4616f466 authored by Andreas Gohr's avatar Andreas Gohr Committed by GitHub
Browse files

Merge pull request #2131 from kelunik/http-client-tls

Remove insecure SSLv3 fallback, use TLS 1.2 if possible
parents 4fa61045 f7813a68
No related branches found
No related tags found
No related merge requests found
...@@ -604,18 +604,16 @@ class HTTPClient { ...@@ -604,18 +604,16 @@ class HTTPClient {
// set correct peer name for verification (enabled since PHP 5.6) // set correct peer name for verification (enabled since PHP 5.6)
stream_context_set_option($socket, 'ssl', 'peer_name', $requestinfo['host']); stream_context_set_option($socket, 'ssl', 'peer_name', $requestinfo['host']);
// because SSLv3 is mostly broken, we try TLS connections here first. // SSLv3 is broken, use only TLS connections.
// according to https://github.com/splitbrain/dokuwiki/commit/c05ef534 we had problems with certain // @link https://bugs.php.net/69195
// setups with this solution before, but we have no usable test for that and TLS should be the more if (PHP_VERSION_ID >= 50600 && PHP_VERSION_ID <= 50606) {
// common crypto by now $cryptoMethod = STREAM_CRYPTO_METHOD_TLS_CLIENT;
if (@stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { } else {
$requesturl = $requestinfo['path']. // actually means neither SSLv2 nor SSLv3
(!empty($requestinfo['query'])?'?'.$requestinfo['query']:''); $cryptoMethod = STREAM_CRYPTO_METHOD_SSLv23_CLIENT;
return true;
} }
// if the above failed, this will most probably not work either, but we can try if (@stream_socket_enable_crypto($socket, true, $cryptoMethod)) {
if (@stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_SSLv3_CLIENT)) {
$requesturl = $requestinfo['path']. $requesturl = $requestinfo['path'].
(!empty($requestinfo['query'])?'?'.$requestinfo['query']:''); (!empty($requestinfo['query'])?'?'.$requestinfo['query']:'');
return true; return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment