From ed352ed8ccf199451abf934b571070a8aeeaa209 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Thu, 4 Apr 2019 15:18:59 +0200 Subject: [PATCH] ImportSourceRestApi: respect SSL + Proxy settings --- .../Director/Import/ImportSourceRestApi.php | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/library/Director/Import/ImportSourceRestApi.php b/library/Director/Import/ImportSourceRestApi.php index 1ca91127..36a8f722 100644 --- a/library/Director/Import/ImportSourceRestApi.php +++ b/library/Director/Import/ImportSourceRestApi.php @@ -45,6 +45,27 @@ class ImportSourceRestApi extends ImportSourceHook $api->setPort($parts['port']); } + if ($api->getScheme() === 'HTTPS') { + if ($this->getSetting('ssl_verify_peer', 'y') === 'n') { + $api->disableSslPeerVerification(); + } + if ($this->getSetting('ssl_verify_host', 'y') === 'n') { + $api->disableSslHostVerification(); + } + } + + if ($proxy = $this->getSetting('proxy')) { + if ($proxyType = $this->getSetting('proxy_type')) { + $api->setProxy($proxy, $proxyType); + } else { + $api->setProxy($proxy); + } + + if ($user = $this->getSetting('proxy_user')) { + $api->setProxyAuth($user, $this->getSetting('proxy_pass')); + } + } + $result = $api->get($url); if ($property = $this->getSetting('extract_property')) { if (\property_exists($result, $property)) { @@ -165,7 +186,6 @@ class ImportSourceRestApi extends ImportSourceHook 'Often the expected result is provided in a property like "objects".' . ' Please specify this if required' ), - 'required' => false, )); } @@ -180,12 +200,10 @@ class ImportSourceRestApi extends ImportSourceHook 'description' => $form->translate( 'Will be used for SOAP authentication against your vCenter' ), - 'required' => true, )); $form->addElement('password', 'password', array( 'label' => $form->translate('Password'), - 'required' => true, )); }