Use keepalive for LDAP connections (#2344)

This commit is contained in:
Maxime Besson 2020-10-09 12:22:28 +02:00
parent ca97628c04
commit fcb8e6b3c5
3 changed files with 8 additions and 5 deletions

View File

@ -91,8 +91,9 @@ sub ldap {
# Connect
my $ldap = Net::LDAP->new(
\@servers,
onerror => undef,
verify => ( $self->{ldapVerify} || "require" ),
keepalive => 1,
onerror => undef,
verify => ( $self->{ldapVerify} || "require" ),
( $self->{ldapCAFile} ? ( cafile => $self->{ldapCAFile} ) : () ),
( $self->{ldapCAPath} ? ( capath => $self->{ldapCAPath} ) : () ),
( $self->{ldapPort} ? ( port => $self->{ldapPort} ) : () ),

View File

@ -486,7 +486,8 @@ sub _ldap {
# Connect
my $ldap = Net::LDAP->new(
\@servers,
onerror => undef,
onerror => undef,
keepalive => 1,
( $self->ldapPort ? ( port => $self->ldapPort ) : () ),
( $self->ldapVerify ? ( verify => $self->ldapVerify ) : () ),
( $self->ldapCAFile ? ( cafile => $self->ldapCAFile ) : () ),

View File

@ -47,7 +47,8 @@ sub new {
}
$self = Net::LDAP->new(
\@servers,
onerror => undef,
onerror => undef,
keepalive => 1,
( $conf->{ldapPort} ? ( port => $conf->{ldapPort} ) : () ),
( $conf->{ldapTimeout} ? ( timeout => $conf->{ldapTimeout} ) : () ),
( $conf->{ldapVersion} ? ( version => $conf->{ldapVersion} ) : () ),
@ -66,7 +67,7 @@ sub new {
# socket when certificate validation fails. Net::LDAP does not catch
# it, and the process ends up crashing.
# As a precaution, make sure the underlying socket is doing fine:
if ( $self->socket->isa('IO::Socket::SSL')
if ( $self->socket->isa('IO::Socket::SSL')
and $self->socket->errstr < 0 )
{
$portal->logger->error(