Skip to content

Commit

Permalink
Fix that LDAP encryption settings have no effect
Browse files Browse the repository at this point in the history
I renamed the directive for the encryption setting from 'connection' to 'encryption' before releasing Beta3 but
I forgot to change the Connection class accordingly.

fixes #8953
  • Loading branch information
lippserd committed Apr 2, 2015
1 parent 06d9e41 commit 9ce9e02
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions library/Icinga/Protocol/Ldap/Connection.php
Expand Up @@ -45,14 +45,20 @@ class Connection
*/
const LDAPS = 'ldaps';

/**
* Encryption for the connection if any
*
* @var string|null
*/
protected $encryption;

protected $ds;
protected $hostname;
protected $port = 389;
protected $bind_dn;
protected $bind_pw;
protected $root_dn;
protected $count;
protected $connectionType;
protected $reqCert = true;

/**
Expand Down Expand Up @@ -86,7 +92,10 @@ public function __construct(ConfigObject $config)
$this->bind_pw = $config->bind_pw;
$this->root_dn = $config->root_dn;
$this->port = $config->get('port', $this->port);
$this->connectionType = $config->get('connection');
$this->encryption = $config->get('encryption');
if ($this->encryption !== null) {
$this->encryption = strtolower($this->encryption);
}
$this->reqCert = (bool) $config->get('reqcert', $this->reqCert);
}

Expand Down Expand Up @@ -481,12 +490,12 @@ protected function getConfigDir($sub = null)
*/
protected function prepareNewConnection()
{
if ($this->connectionType === static::STARTTLS || $this->connectionType === static::LDAPS) {
if ($this->encryption === static::STARTTLS || $this->encryption === static::LDAPS) {
$this->prepareTlsEnvironment();
}

$hostname = $this->hostname;
if ($this->connectionType === static::LDAPS) {
if ($this->encryption === static::LDAPS) {
$hostname = 'ldaps://' . $hostname;
}

Expand All @@ -499,8 +508,7 @@ protected function prepareNewConnection()
Logger::warning('LADP discovery failed, assuming default LDAP settings.');
$this->capabilities = new Capability(); // create empty default capabilities
}

if ($this->connectionType === static::STARTTLS) {
if ($this->encryption === static::STARTTLS) {
$force_tls = false;
if ($this->capabilities->hasStartTls()) {
if (@ldap_start_tls($ds)) {
Expand Down

0 comments on commit 9ce9e02

Please sign in to comment.