mirror of
https://github.com/Icinga/icingaweb2-module-graphite.git
synced 2026-05-28 04:34:57 -04:00
Add switch for insecure TLS
This commit is contained in:
parent
9241c592d0
commit
84fba6f5a1
3 changed files with 46 additions and 1 deletions
|
|
@ -45,6 +45,14 @@ class BackendForm extends ConfigForm
|
|||
'label' => $this->translate('Graphite Web password'),
|
||||
'description' => $this->translate('The above user\'s password')
|
||||
]
|
||||
],
|
||||
[
|
||||
'checkbox',
|
||||
'graphite_insecure',
|
||||
[
|
||||
'label' => $this->translate('Connect insecurely'),
|
||||
'description' => $this->translate('Check this to not verify the remote\'s TLS certificate')
|
||||
]
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ trait GraphingTrait
|
|||
(new GraphiteWebClient(Url::fromPath($graphite->url)))
|
||||
->setUser($graphite->user)
|
||||
->setPassword($graphite->password)
|
||||
->setInsecure($graphite->insecure)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,13 @@ class GraphiteWebClient
|
|||
*/
|
||||
protected $password;
|
||||
|
||||
/**
|
||||
* Don't verify the remote's TLS certificate
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $insecure = false;
|
||||
|
||||
/**
|
||||
* HTTP client
|
||||
*
|
||||
|
|
@ -74,7 +81,12 @@ class GraphiteWebClient
|
|||
->getAbsoluteUrl();
|
||||
|
||||
// TODO(ak): keep connections alive (TCP handshakes are a bit expensive and TLS handshakes are very expensive)
|
||||
return (string) $this->httpClient->send(new Request($method, $url, $headers, $body))->getBody();
|
||||
return (string) $this->httpClient->send(
|
||||
new Request($method, $url, $headers, $body),
|
||||
['curl' => [
|
||||
CURLOPT_SSL_VERIFYPEER => ! $this->insecure
|
||||
]]
|
||||
)->getBody();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -148,4 +160,28 @@ class GraphiteWebClient
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether not to verify the remote's TLS certificate
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getInsecure()
|
||||
{
|
||||
return $this->insecure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether not to verify the remote's TLS certificate
|
||||
*
|
||||
* @param bool $insecure
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setInsecure($insecure = true)
|
||||
{
|
||||
$this->insecure = $insecure;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue