mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 08:14:03 +02:00
DbResourceForm: Don't show SSL form elements by default
Addded additionally a check for PHP 5.4 so that these elements are not shown for earlier versions. refs #11115
This commit is contained in:
parent
5e7817cad2
commit
b759ab6f5a
@ -42,6 +42,8 @@ class DbResourceForm extends Form
|
|||||||
if (Platform::hasOciSupport()) {
|
if (Platform::hasOciSupport()) {
|
||||||
$dbChoices['oci'] = 'Oracle (OCI8)';
|
$dbChoices['oci'] = 'Oracle (OCI8)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$encryptionChoices = array();
|
||||||
$offerPostgres = false;
|
$offerPostgres = false;
|
||||||
$offerMysql = false;
|
$offerMysql = false;
|
||||||
if (isset($formData['db'])) {
|
if (isset($formData['db'])) {
|
||||||
@ -49,6 +51,9 @@ class DbResourceForm extends Form
|
|||||||
$offerPostgres = true;
|
$offerPostgres = true;
|
||||||
} elseif ($formData['db'] === 'mysql') {
|
} elseif ($formData['db'] === 'mysql') {
|
||||||
$offerMysql = true;
|
$offerMysql = true;
|
||||||
|
if (version_compare(Platform::getPhpVersion(), '5.4.0', '>=')) {
|
||||||
|
$encryptionChoices['ssl'] = 'SSL';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$dbChoice = key($dbChoices);
|
$dbChoice = key($dbChoices);
|
||||||
@ -56,8 +61,12 @@ class DbResourceForm extends Form
|
|||||||
$offerPostgres = true;
|
$offerPostgres = true;
|
||||||
} elseif ($dbChoice === 'mysql') {
|
} elseif ($dbChoice === 'mysql') {
|
||||||
$offerMysql = true;
|
$offerMysql = true;
|
||||||
|
if (version_compare(Platform::getPhpVersion(), '5.4.0', '>=')) {
|
||||||
|
$encryptionChoices['ssl'] = 'SSL';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$socketInfo = '';
|
$socketInfo = '';
|
||||||
if ($offerPostgres) {
|
if ($offerPostgres) {
|
||||||
$socketInfo = $this->translate(
|
$socketInfo = $this->translate(
|
||||||
@ -68,6 +77,7 @@ class DbResourceForm extends Form
|
|||||||
'For using unix domain sockets, specify localhost'
|
'For using unix domain sockets, specify localhost'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
'text',
|
'text',
|
||||||
'name',
|
'name',
|
||||||
@ -138,53 +148,67 @@ class DbResourceForm extends Form
|
|||||||
'description' => $this->translate('The password to use for authentication')
|
'description' => $this->translate('The password to use for authentication')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if ($offerMysql) {
|
if (! empty($encryptionChoices)) {
|
||||||
|
$this->addElement(
|
||||||
|
'select',
|
||||||
|
'encryption',
|
||||||
|
array(
|
||||||
|
'autosubmit' => true,
|
||||||
|
'label' => $this->translate('Encryption'),
|
||||||
|
'description' => $this->translate(
|
||||||
|
'Whether to encrypt the connection or to authenticate using certificates'
|
||||||
|
),
|
||||||
|
'multiOptions' => array_merge(
|
||||||
|
array('none' => $this->translate('None', 'db connection encryption')),
|
||||||
|
$encryptionChoices
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if (isset($formData['encryption']) && $formData['encryption'] === 'ssl') {
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
'text',
|
'text',
|
||||||
'ssl_key',
|
'ssl_key',
|
||||||
array(
|
array(
|
||||||
'required' => false,
|
|
||||||
'label' => $this->translate('SSL Key'),
|
'label' => $this->translate('SSL Key'),
|
||||||
'description' => $this->translate('The SSL client key file path')
|
'description' => $this->translate('The client key file path')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
'text',
|
'text',
|
||||||
'ssl_cert',
|
'ssl_cert',
|
||||||
array(
|
array(
|
||||||
'required' => false,
|
|
||||||
'label' => $this->translate('SSL Certificate'),
|
'label' => $this->translate('SSL Certificate'),
|
||||||
'description' => $this->translate('The SSL certificate file path')
|
'description' => $this->translate('The certificate file path')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
'text',
|
'text',
|
||||||
'ssl_ca',
|
'ssl_ca',
|
||||||
array(
|
array(
|
||||||
'required' => false,
|
|
||||||
'label' => $this->translate('SSL CA'),
|
'label' => $this->translate('SSL CA'),
|
||||||
'description' => $this->translate('The SSL Certificate Authority certificate file path')
|
'description' => $this->translate('The CA certificate file path')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
'text',
|
'text',
|
||||||
'ssl_capath',
|
'ssl_capath',
|
||||||
array(
|
array(
|
||||||
'required' => false,
|
|
||||||
'label' => $this->translate('SSL CA Path'),
|
'label' => $this->translate('SSL CA Path'),
|
||||||
'description' => $this->translate('The SSL trusted SSL CA certificates in PEM format directory path')
|
'description' => $this->translate(
|
||||||
|
'The trusted CA certificates in PEM format directory path'
|
||||||
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
'text',
|
'text',
|
||||||
'ssl_cipher',
|
'ssl_cipher',
|
||||||
array(
|
array(
|
||||||
'required' => false,
|
|
||||||
'label' => $this->translate('SSL Cipher'),
|
'label' => $this->translate('SSL Cipher'),
|
||||||
'description' => $this->translate('The SSL list of permissible ciphers')
|
'description' => $this->translate('The list of permissible ciphers')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
'text',
|
'text',
|
||||||
'charset',
|
'charset',
|
||||||
|
@ -143,13 +143,7 @@ class DbConnection implements Selectable, Extensible, Updatable, Reducible, Insp
|
|||||||
break;
|
break;
|
||||||
case 'mysql':
|
case 'mysql':
|
||||||
$adapter = 'Pdo_Mysql';
|
$adapter = 'Pdo_Mysql';
|
||||||
// If any SSL options are set, add them to driver_options
|
if ($this->config->encryption === 'ssl') {
|
||||||
if ($this->config->ssl_key
|
|
||||||
|| $this->config->ssl_cert
|
|
||||||
|| $this->config->ssl_ca
|
|
||||||
|| $this->config->ssl_capath
|
|
||||||
|| $this->config->ssl_cipher
|
|
||||||
) {
|
|
||||||
# The presence of these keys as empty strings or null cause non-ssl connections to fail
|
# The presence of these keys as empty strings or null cause non-ssl connections to fail
|
||||||
if ($this->config->ssl_key) {
|
if ($this->config->ssl_key) {
|
||||||
$adapterParamaters['driver_options'][PDO::MYSQL_ATTR_SSL_KEY] = $this->config->ssl_key;
|
$adapterParamaters['driver_options'][PDO::MYSQL_ATTR_SSL_KEY] = $this->config->ssl_key;
|
||||||
|
@ -113,29 +113,43 @@ class BackendStep extends Step
|
|||||||
. '<td><strong>' . t('Password') . '</strong></td>'
|
. '<td><strong>' . t('Password') . '</strong></td>'
|
||||||
. '<td>' . str_repeat('*', strlen($this->data['resourceConfig']['password'])) . '</td>'
|
. '<td>' . str_repeat('*', strlen($this->data['resourceConfig']['password'])) . '</td>'
|
||||||
. '</tr>';
|
. '</tr>';
|
||||||
if ($this->data['resourceConfig']['db'] === 'mysql') {
|
|
||||||
|
if (isset($this->data['resourceConfig']['ssl_key']) && $this->data['resourceConfig']['ssl_key']) {
|
||||||
$resourceHtml .= ''
|
$resourceHtml .= ''
|
||||||
.'<tr>'
|
.'<tr>'
|
||||||
. '<td><strong>' . t('SSL Key') . '</strong></td>'
|
. '<td><strong>' . t('SSL Key') . '</strong></td>'
|
||||||
. '<td>' . $this->data['resourceConfig']['ssl_key'] . '</td>'
|
. '<td>' . $this->data['resourceConfig']['ssl_key'] . '</td>'
|
||||||
. '</tr>'
|
. '</tr>';
|
||||||
|
}
|
||||||
|
if (isset($this->data['resourceConfig']['ssl_cert']) && $this->data['resourceConfig']['ssl_cert']) {
|
||||||
|
$resourceHtml .= ''
|
||||||
. '<tr>'
|
. '<tr>'
|
||||||
. '<td><strong>' . t('SSL Cert') . '</strong></td>'
|
. '<td><strong>' . t('SSL Cert') . '</strong></td>'
|
||||||
. '<td>' . $this->data['resourceConfig']['ssl_cert'] . '</td>'
|
. '<td>' . $this->data['resourceConfig']['ssl_cert'] . '</td>'
|
||||||
. '</tr>'
|
. '</tr>';
|
||||||
|
}
|
||||||
|
if (isset($this->data['resourceConfig']['ssl_ca']) && $this->data['resourceConfig']['ssl_ca']) {
|
||||||
|
$resourceHtml .= ''
|
||||||
. '<tr>'
|
. '<tr>'
|
||||||
. '<td><strong>' . t('CA') . '</strong></td>'
|
. '<td><strong>' . t('CA') . '</strong></td>'
|
||||||
. '<td>' . $this->data['resourceConfig']['ssl_ca'] . '</td>'
|
. '<td>' . $this->data['resourceConfig']['ssl_ca'] . '</td>'
|
||||||
. '</tr>'
|
. '</tr>';
|
||||||
|
}
|
||||||
|
if (isset($this->data['resourceConfig']['ssl_capath']) && $this->data['resourceConfig']['ssl_capath']) {
|
||||||
|
$resourceHtml .= ''
|
||||||
. '<tr>'
|
. '<tr>'
|
||||||
. '<td><strong>' . t('CA Path') . '</strong></td>'
|
. '<td><strong>' . t('CA Path') . '</strong></td>'
|
||||||
. '<td>' . $this->data['resourceConfig']['ssl_capath'] . '</td>'
|
. '<td>' . $this->data['resourceConfig']['ssl_capath'] . '</td>'
|
||||||
. '</tr>'
|
. '</tr>';
|
||||||
|
}
|
||||||
|
if (isset($this->data['resourceConfig']['ssl_cipher']) && $this->data['resourceConfig']['ssl_cipher']) {
|
||||||
|
$resourceHtml .= ''
|
||||||
. '<tr>'
|
. '<tr>'
|
||||||
. '<td><strong>' . t('Cipher') . '</strong></td>'
|
. '<td><strong>' . t('Cipher') . '</strong></td>'
|
||||||
. '<td>' . $this->data['resourceConfig']['ssl_cipher'] . '</td>'
|
. '<td>' . $this->data['resourceConfig']['ssl_cipher'] . '</td>'
|
||||||
. '</tr>';
|
. '</tr>';
|
||||||
};
|
}
|
||||||
|
|
||||||
$resourceHtml .= ''
|
$resourceHtml .= ''
|
||||||
. '</tbody>'
|
. '</tbody>'
|
||||||
. '</table>';
|
. '</table>';
|
||||||
|
@ -262,12 +262,7 @@ class DbTool
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ($this->config['db'] === 'mysql') {
|
if ($this->config['db'] === 'mysql') {
|
||||||
if ($this->config['ssl_key']
|
if (isset($this->config['encryption']) && $this->config['encryption'] === 'ssl') {
|
||||||
|| $this->config['ssl_cert']
|
|
||||||
|| $this->config['ssl_ca']
|
|
||||||
|| $this->config['ssl_capath']
|
|
||||||
|| $this->config['ssl_cipher']
|
|
||||||
) {
|
|
||||||
$this->config['driver_options'] = array();
|
$this->config['driver_options'] = array();
|
||||||
# The presence of these keys as empty strings or null cause non-ssl connections to fail
|
# The presence of these keys as empty strings or null cause non-ssl connections to fail
|
||||||
if ($this->config['ssl_key']) {
|
if ($this->config['ssl_key']) {
|
||||||
@ -315,12 +310,10 @@ class DbTool
|
|||||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($this->config['db'] == 'mysql'
|
if (
|
||||||
&& ($this->config['ssl_key']
|
$this->config['db'] === 'mysql'
|
||||||
|| $this->config['ssl_cert']
|
&& isset($this->config['encryption'])
|
||||||
|| $this->config['ssl_ca']
|
&& $this->config['encryption'] === 'ssl'
|
||||||
|| $this->config['ssl_capath']
|
|
||||||
|| $this->config['ssl_cipher'])
|
|
||||||
) {
|
) {
|
||||||
# The presence of these keys as empty strings or null cause non-ssl connections to fail
|
# The presence of these keys as empty strings or null cause non-ssl connections to fail
|
||||||
if ($this->config['ssl_key']) {
|
if ($this->config['ssl_key']) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user