Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
Add CURLOPT_SSL_ to bypass certificate (#6027)
Browse files Browse the repository at this point in the history
* Add CURLOPT_SSL_ to bypass certificat

* feat(kb) add ignore ssl certificate option
  • Loading branch information
loiclau authored Feb 5, 2018
1 parent 054febf commit e0929fe
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions www/class/centreon-knowledge/wikiApi.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class WikiApi
private $loggedIn;
private $tokens;
private $cookies;
private $noSslCertificate;

/**
* WikiApi constructor.
Expand All @@ -62,6 +63,7 @@ public function __construct()
$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();
Expand All @@ -74,6 +76,10 @@ private function getCurl()
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;
}
Expand Down
4 changes: 3 additions & 1 deletion www/include/Administration/parameters/DB-Func.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ <h4>{t}Knowledge base configuration{/t}</h4>
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
$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');
Expand Down
4 changes: 4 additions & 0 deletions www/include/Administration/parameters/knowledgeBase/help.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
'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."
Expand Down

0 comments on commit e0929fe

Please sign in to comment.