add support for setting ssl version to use
authorgggeek <giunta.gaetano@gmail.com>
Sat, 1 Jul 2017 14:22:07 +0000 (15:22 +0100)
committergggeek <giunta.gaetano@gmail.com>
Sat, 1 Jul 2017 14:22:07 +0000 (15:22 +0100)
.gitignore
.travis.yml
lib/xmlrpc.inc
test/parse_args.php
test/testsuite.php

index 8d880ea..3ec7bc3 100644 (file)
@@ -1,3 +1,3 @@
+/vendor
 /.idea
 composer.phar
-
index 8f5c0c2..28a16f9 100644 (file)
@@ -30,7 +30,7 @@ before_script:
   - ./test/ci/travis/setup_privoxy.sh
 
 script:
-  php -d "include_path=.:./lib:./test" test/testsuite.php LOCALSERVER=localhost URI=/demo/server/server.php HTTPSSERVER=localhost HTTPSURI=/demo/server/server.php PROXY=localhost:8080 HTTPSVERIFYHOST=0 HTTPSIGNOREPEER=1
+  php -d "include_path=.:./lib:./test" test/testsuite.php LOCALSERVER=localhost URI=/demo/server/server.php HTTPSSERVER=localhost HTTPSURI=/demo/server/server.php PROXY=localhost:8080 HTTPSVERIFYHOST=0 HTTPSIGNOREPEER=1 SSLVERSION=3
 
 after_failure:
   # Save as much info as we can to help developers
index 5afcc40..dbd36a9 100644 (file)
                var $keypass='';\r
                var $verifypeer=true;\r
                var $verifyhost=1;\r
+               var $sslversion=0; // corresponds to CURL_SSLVERSION_DEFAULT\r
                var $no_multicall=false;\r
                var $proxy='';\r
                var $proxyport=0;\r
                        $this->verifyhost = $i;\r
                }\r
 \r
+               /**\r
+               * Set attributes for SSL communication: SSL version to use. Best left at 0 (default value ): let cURL decide\r
+               *\r
+               * @param int $i\r
+               */\r
+               public function setSSLVersion($i)\r
+               {\r
+                       $this->sslversion = $i;\r
+               }\r
+\r
                /**\r
                * Set proxy info\r
                * @param string $proxyhost\r
                                        $this->proxy_authtype,\r
                                        $this->keepalive,\r
                                        $this->key,\r
-                                       $this->keypass\r
+                                       $this->keypass,\r
+                                       $this->sslversion\r
                                );\r
                        }\r
                        elseif($method == 'http11')\r
                function &sendPayloadHTTPS($msg, $server, $port, $timeout=0, $username='',\r
                        $password='', $authtype=1, $cert='',$certpass='', $cacert='', $cacertdir='',\r
                        $proxyhost='', $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1,\r
-                       $keepalive=false, $key='', $keypass='')\r
+                       $keepalive=false, $key='', $keypass='', $sslVersion = 0)\r
                {\r
                        $r =& $this->sendPayloadCURL($msg, $server, $port, $timeout, $username,\r
                                $password, $authtype, $cert, $certpass, $cacert, $cacertdir, $proxyhost, $proxyport,\r
-                               $proxyusername, $proxypassword, $proxyauthtype, 'https', $keepalive, $key, $keypass);\r
+                               $proxyusername, $proxypassword, $proxyauthtype, 'https', $keepalive, $key, $keypass, $sslVersion);\r
                        return $r;\r
                }\r
 \r
                function &sendPayloadCURL($msg, $server, $port, $timeout=0, $username='',\r
                        $password='', $authtype=1, $cert='', $certpass='', $cacert='', $cacertdir='',\r
                        $proxyhost='', $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1, $method='https',\r
-                       $keepalive=false, $key='', $keypass='')\r
+                       $keepalive=false, $key='', $keypass='', $sslVersion = 0)\r
                {\r
                        if(!function_exists('curl_init'))\r
                        {\r
                                }\r
                                // whether to verify cert's common name (CN); 0 for no, 1 to verify that it exists, and 2 to verify that it matches the hostname used\r
                                curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, $this->verifyhost);\r
+                               // allow usage of different SSL versions\r
+                               curl_setopt($curl, CURLOPT_SSLVERSION, $sslVersion);\r
                        }\r
 \r
                        // proxy info\r
index b0c625a..151d943 100644 (file)
        {
                $HTTPSVERIFYHOST = 2;
        }
+       if(!isset($SSLVERSION))
+       {
+               $SSLVERSION = 0;
+       }
        if(!isset($PROXY))
        {
                $PROXYSERVER = null;
index 19a4f0e..779d514 100644 (file)
@@ -793,6 +793,7 @@ class LocalHostMultiTests extends LocalhostTests
         $this->client->path = $HTTPSURI;
         $this->client->setSSLVerifyPeer(!$HTTPSIGNOREPEER);
         $this->client->setSSLVerifyHost($HTTPSVERIFYHOST);
+        $this->client->setSSLVersion($SSLVERSION);
         $this->_runtests();
     }
 
@@ -817,6 +818,7 @@ class LocalHostMultiTests extends LocalhostTests
         $this->client->path = $HTTPSURI;
         $this->client->setSSLVerifyPeer(!$HTTPSIGNOREPEER);
         $this->client->setSSLVerifyHost($HTTPSVERIFYHOST);
+        $this->client->setSSLVersion($SSLVERSION);
         $this->_runtests();
     }