tags:

views:

36

answers:

1

Hi,

I'm trying to use Net::LDAP in Perl to do LDAPS authentication against my Server 2008 Active Directory and I'm having a hard time getting server verification to work. It works if in start_tls I useverify=> 'none', but this is not so great.

When I use verify => 'require' (which is preferable), I get this error:

SSL connect attempt failed with unknown error error:0D0C50A1:asn1 encoding routines:ASN1_item_verify:unknown message digest algorithm at ./ldap.pl line 23, line 522.

When I test from the command line using Openssl s_client it works great, so I don't think it's an OpenSSL problem. I'm kind of a noob with Perl, so I'm not sure what else to debug.

Here's the relevant code snippet:

#!/usr/bin/perl
use Net::LDAP;

$ldap = Net::LDAP->new('ho.mydomain.com',
                        ) or die "LDAP error";
$mesg = $ldap->start_tls(
    sslversion => 'tlsv1',
    verify => 'require',
    capath => '/etc/ssl/certs/',
    );
die $mesg->error if $mesg->is_error;

The output from OpenSSL s_client:


New, TLSv1/SSLv3, Cipher is AES128-SHA
Server public key is 2048 bit
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1
    Cipher    : AES128-SHA
    Session-ID: [removed]
    Session-ID-ctx:
    Master-Key: [removed]    
    Key-Arg   : None
    Start Time: 1278707544
    Timeout   : 300 (sec)
    Verify return code: 0 (ok)

Any help would be greatly appreciated.

Thanks

A: 

Are you sure your s_client works properly when verifying the whole certificate chain (pass the -verify option)?

"unknown message digest algorithm" means that some crypto element in your chain does not support the digest hash for some certificate in the path to a trusted root.

It could be that an intermediate or root certificate is using the problematic hash algorithm (probably sha256 if you have an old openssl, or something really old if you have a new one).

Make sure you have a recent openssl library. See http://bugs.gentoo.org/294615 for one example of this happening.

Borealid
Interesting, thanks for the input! I think verification is working on the whole chain, s_client doesn't give any errors. Here's the top part of the output:CONNECTED(00000003)depth=1 /DC=com/DC=mydomain/DC=ho/CN=DC01verify return:1depth=0 /CN=dc03.ho.mydomain.comverify return:1---Certificate chain 0 s:/CN=dc03.ho.mydomain.com i:/DC=com/DC=mydomain/DC=ho/CN=DC01---My openssl version is 0.9.8h. Thanks again,
Tracert
Well, that's a dead end then.Trying again: Do you have all the prerequisites for Perl-LDAP installed? Specifically, if the server is offering DIGEST-MD5 SASL auth, you need to have Digest::MD5 installed.
Borealid
Also, make sure to use LDAP v3. There's really no reason you'd not want to do this. `Net::LDAP->new( 'ho.mydomain.com', version => 3 );`
Borealid
I think I've got all the prerequisites. My distro is SLES11-SP1, so I just used zypper to install perl-ldap and perl-ldap-ssl. It resolved a bunch of dependencies, too, including IO::Socket::SSL. I didn't have Digest::MD5, so I installed it just now with CPAN and specified the LDAP version also, but no love.
Tracert
Hey is it possible there's something weird about my CA cert? It's an internal one generated by my Server 2008 AD, which is running Active Directory Certificate Services.
Tracert
You've got me.One thing to try would be to use SSL instead of TLS (connect to the `ldaps` port). If that doesn't work, I'm out of ideas.
Borealid