]> git.proxmox.com Git - pmg-api.git/commitdiff
LDAPCache: combine ldaps/starttls branches for connect
authorDominik Csapak <d.csapak@proxmox.com>
Fri, 3 Apr 2020 12:29:57 +0000 (14:29 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 7 Apr 2020 08:46:37 +0000 (10:46 +0200)
they are similar except the setting of the verify options, so
combine them as

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
src/PMG/LDAPCache.pm

index 3045c27ba9166ac69b3635432506b81fcac32fbc..df614547e4d2b08360de0a692c0364ab39f80ac5 100755 (executable)
@@ -257,15 +257,12 @@ sub ldap_connect {
     my $opts = {};
     my $scheme = $self->{mode};
 
-    if ($scheme eq 'ldaps') {
-       $opts->{verify} = 'require' if $self->{verify};
-       if ($self->{cafile}) {
-           $opts->{cafile} = $self->{cafile};
-       } else {
-           $opts->{capath} = '/etc/ssl/certs/';
+    if ($scheme eq 'ldaps' || $scheme eq 'ldap+starttls') {
+       if ($self->{verify}) {
+           $opts->{verify} = 'require';
+       } elsif ($scheme eq 'ldap+starttls') {
+           $opts->{verify} = 'none';
        }
-    } elsif ($self->{mode} eq 'ldap+starttls') {
-       $opts->{verify} = $self->{verify} ? 'require' : 'none';
 
        if ($self->{cafile}) {
            $opts->{cafile} = $self->{cafile};