Stop RemoteFile from swallowing OpenSSL error details
authorTim Düsterhus <duesterhus@woltlab.com>
Sat, 13 Jun 2020 11:25:01 +0000 (13:25 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Sat, 13 Jun 2020 11:25:01 +0000 (13:25 +0200)
Fixes #3107

wcfsetup/install/files/lib/system/io/RemoteFile.class.php

index a97a65edeeff89303309f5dfb4c2726b1b68ec1a..170374e089cee0026612cbf094c6578926dcd8fe 100644 (file)
@@ -58,9 +58,14 @@ class RemoteFile extends File {
                if (!preg_match('/^[a-z0-9]+:/', $this->host)) $this->host = 'tcp://'.$this->host;
                
                $context = stream_context_create($options);
-               $this->resource = @stream_socket_client($this->host.':'.$this->port, $this->errorNumber, $this->errorDesc, $timeout, STREAM_CLIENT_CONNECT, $context);
-               if ($this->resource === false) {
-                       throw new SystemException('Can not connect to ' . $host, 0, $this->errorDesc);
+               try {
+                       $this->resource = stream_socket_client($this->host.':'.$this->port, $this->errorNumber, $this->errorDesc, $timeout, STREAM_CLIENT_CONNECT, $context);
+                       if ($this->resource === false) {
+                               throw new \Exception('stream_socket_client returned false: ' . $this->errorDesc, $this->errorNumber);
+                       }
+               }
+               catch (\Exception $e) {
+                       throw new SystemException('Can not connect to ' . $host, 0, $this->errorDesc, $e);
                }
                
                stream_set_timeout($this->resource, $timeout);