Skip to content

Commit

Permalink
Include operation timeout to prevent getting stuck if TLS connection
Browse files Browse the repository at this point in the history
cannot be verified because of missing CA certificate
  • Loading branch information
jvillafanez committed Feb 17, 2020
1 parent 7615279 commit ff16e16
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ private function doConnect($host, $port) {
}
// Set network timeout threshold to avoid long delays when ldap server cannot be resolved
$this->getLDAP()->setOption($this->ldapConnectionRes, LDAP_OPT_NETWORK_TIMEOUT, \intval($this->configuration->ldapNetworkTimeout));
$this->getLDAP()->setOption($this->ldapConnectionRes, LDAP_OPT_TIMEOUT, \intval($this->configuration->ldapNetworkTimeout));
if (!$this->getLDAP()->isResource($this->ldapConnectionRes)) {
$this->ldapConnectionRes = null; // to indicate it really is not set, connect() might have set it to false
throw new ServerNotAvailableException("Connect to $host:$port failed");
Expand Down
1 change: 1 addition & 0 deletions lib/Wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,7 @@ private function getConnection() {
$this->getLDAP()->setOption($cr, LDAP_OPT_PROTOCOL_VERSION, 3);
$this->getLDAP()->setOption($cr, LDAP_OPT_REFERRALS, 0);
$this->getLDAP()->setOption($cr, LDAP_OPT_NETWORK_TIMEOUT, self::LDAP_NW_TIMEOUT);
$this->getLDAP()->setOption($cr, LDAP_OPT_TIMEOUT, self::LDAP_NW_TIMEOUT);
if ($this->configuration->ldapTLS) {
$this->getLDAP()->startTls($cr);
}
Expand Down

0 comments on commit ff16e16

Please sign in to comment.