greg_coates has asked for the wisdom of the Perl Monks concerning the following question:

I'm having trouble getting my perl to connect to my openldap server.

My code is running on a RedHat Enterpise 6 machine that has openssl 1.0 installed.

Here's my connect code:

$ldap = Net::LDAPS->new( $server, port=>636, verify=>'require', capath=>'/path/here/ssl/cacerts/' ) or die("$@");

And here's the error I'm getting:

IO::Socket::SSL: SSL connect attempt failed with unknown errorerror:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed at LDAP.pm line 28, <DATA> line 522.

(LDAP.pm is an LDAP utility module that I wrote for internal use.)

One final bit of information: if I use the ldapsearch command line tool, I can connect to the server just fine.

I'm beating my head against my wall, and I'd appreciate any ideas.

Thanks!

Replies are listed 'Best First'.
Re: Error connecting to LDAP via Net::LDAPS
by Khen1950fx (Canon) on Mar 05, 2011 at 05:51 UTC
    Use Net::LDAP::Server::Test. Specifically, in the test directory, use 01-ldap.t.

    Here's how I used your code:

    #!/usr/bin/perl use strict; use warnings; use Net::LDAPS; my $ldap = Net::LDAPS->new( server => 'ldaps://127.0.0.1', verify => 'require', capath => '/etc/openssl/cacerts/' ) or die $@;
    At first, I tried 'localhost', but it kept coming back at me with a 'badname' exception. Also, I used 'ldaps://' for the server. It worked.