Skip to content

Commit

Permalink
JSON: allow insecure/selfsigned certificate #309
Browse files Browse the repository at this point in the history
  • Loading branch information
Rello committed May 24, 2024
1 parent 7e01323 commit bdbae43
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Changelog

## 4.14.0 - 2024-05-2x
### Added
- charts: select account- (values in columns) or kpi-model (values in rows) #393
- JSON: allow insecure/selfsigned certificate #309

### Fixed
- Save filter fails for table-only report #392

## 4.13.1 - 2024-04-14
### Fixed
- missing variable in public shares

## 4.13.0 - 2024-04-14
Expand Down
4 changes: 4 additions & 0 deletions lib/Datasource/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public function getTemplate(): array
$template[] = ['id' => 'content-type', 'name' => 'Header Content-Type', 'placeholder' => 'application/json'];
$template[] = ['id' => 'customHeaders', 'name' => 'Custom headers', 'placeholder' => 'key: value,key: value'];
$template[] = ['id' => 'auth', 'name' => $this->l10n->t('Authentication'), 'placeholder' => 'User:Password'];
$template[] = ['id' => 'insecure', 'name' => $this->l10n->t('Allow insecure connections'), 'placeholder' => '2-' . $this->l10n->t('No') . '/0-' . $this->l10n->t('Yes'), 'type' => 'tf'];
$template[] = ['id' => 'body', 'name' => 'Request body', 'placeholder' => ''];
$template[] = ['id' => 'timestamp', 'name' => $this->l10n->t('Timestamp of data load'), 'placeholder' => 'true-' . $this->l10n->t('Yes') . '/false-' . $this->l10n->t('No'), 'type' => 'tf'];
return $template;
Expand All @@ -80,6 +81,8 @@ public function readData($option): array
$headers = array_map('trim', $headers);
$headers[] = 'OCS-APIRequest: true';
$headers[] = 'Content-Type: ' . $contentType;
# VERITYHOST=0 to disable verification, 2 to enable. 1 is no longer a valid option.
$verifyHost = intval($option['insecure']);

$ch = curl_init();
if ($ch !== false) {
Expand All @@ -90,6 +93,7 @@ public function readData($option): array
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_USERPWD, $auth);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $verifyHost);
if ($option['body'] && $option['body'] !== '') {
curl_setopt($ch, CURLOPT_POSTFIELDS, $option['body']);
}
Expand Down

0 comments on commit bdbae43

Please sign in to comment.