Commit 84ac457e authored by loiclau's avatar loiclau

Add CURLOPT_SSL_ to bypass certificate (#6027)

* Add CURLOPT_SSL_ to bypass certificat

* feat(kb) add ignore ssl certificate option
parent 0fc02569
......@@ -50,6 +50,7 @@ class WikiApi
private $loggedIn;
private $tokens;
private $cookies;
private $noSslCertificate;
/**
* WikiApi constructor.
......@@ -62,6 +63,7 @@ class WikiApi
$this->url = $config['kb_wiki_url'] . '/api.php';
$this->username = $config['kb_wiki_account'];
$this->password = $config['kb_wiki_password'];
$this->noSslCertificate = $config['kb_wiki_certificate'];
$this->curl = $this->getCurl();
$this->version = $this->getWikiVersion();
$this->cookies = array();
......@@ -74,6 +76,10 @@ class WikiApi
curl_setopt($curl, CURLOPT_URL, $this->url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
if($this->noSslCertificate == 1){
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
}
return $curl;
}
......
......@@ -925,7 +925,9 @@ function updateBackupConfigData($db, $form, $centreon)
function updateKnowledgeBaseData($db, $form, $centreon)
{
$ret = $form->getSubmitValues();
if (!isset($ret['kb_wiki_certificate'])){
$ret['kb_wiki_certificate'] = 0;
}
foreach ($ret as $key => $value) {
if (preg_match('/^kb_/', $key)) {
updateOption($db, $key, $value);
......
......@@ -47,6 +47,10 @@
<td class="FormRowField"><img class="helpTooltip" name="tip_knowledge_wiki_account_password">&nbsp;{$form.kb_wiki_password.label}</td>
<td class="FormRowValue">{$form.kb_wiki_password.html}</td>
</tr>
<tr class="list_two">
<td class="FormRowField"><img class="helpTooltip" name="tip_knowledge_wiki_certificate">&nbsp;{$form.kb_wiki_certificate.label}</td>
<td class="FormRowValue">{$form.kb_wiki_certificate.html}</td>
</tr>
</table>
{if !$valid}
<div id="validForm"><p>{$form.submitC.html}&nbsp;&nbsp;&nbsp;{$form.reset.html}</p></div>
......
......@@ -72,6 +72,7 @@ $form->addElement('text', 'kb_wiki_account', _("Knowledge wiki account (with del
$form->addRule('kb_wiki_account', _("Mandatory field"), 'required');
$form->addElement('password', 'kb_wiki_password', _("Knowledge wiki account password"));
$form->addRule('kb_wiki_password', _("Mandatory field"), 'required');
$form->addElement('checkbox', 'kb_wiki_certificate', 'ssl certificate', _("Ignore ssl certificate"));
$form->addElement('hidden', 'gopt_id');
$redirect = $form->addElement('hidden', 'o');
......
......@@ -33,6 +33,10 @@ $help['tip_knowledge_wiki_account'] = dgettext(
'help',
"Wiki account with delete right."
);
$help['tip_knowledge_wiki_certificate'] = dgettext(
'help',
"Ignore ssl certificate."
);
$help['tip_knowledge_wiki_account_password'] = dgettext(
'help',
"Wiki account password."
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment