2014-01-16 08:47:25 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class SyncTool {
|
|
|
|
// take a server as parameter and return a HttpSocket object using the ssl options defined in the server settings
|
|
|
|
public function setupHttpSocket($server) {
|
|
|
|
$params = array();
|
|
|
|
App::uses('HttpSocket', 'Network/Http');
|
2014-01-21 11:28:18 +01:00
|
|
|
if ($server['Server']['cert_file']) $params['ssl_cafile'] = APP . "files" . DS . "certs" . DS . $server['Server']['id'] . '.pem';
|
2014-01-16 08:47:25 +01:00
|
|
|
if ($server['Server']['self_signed']) $params['ssl_allow_self_signed'] = $server['Server']['self_signed'];
|
|
|
|
$HttpSocket = new HttpSocket($params);
|
2015-03-18 17:58:14 +01:00
|
|
|
|
|
|
|
$proxy = Configure::read('Proxy');
|
2015-03-19 09:55:11 +01:00
|
|
|
$HttpSocket->configProxy($proxy['host'], $proxy['port'], $proxy['method'], $proxy['user'], $proxy['password']);
|
|
|
|
|
2014-01-16 08:47:25 +01:00
|
|
|
return $HttpSocket;
|
|
|
|
}
|
|
|
|
}
|