Issue 7398 - Retrieve LDAP server cert
Summary: Retrieve LDAP server cert
Status: VERIFIED FIXED
Alias: None
Product: OpenLDAP
Classification: Unclassified
Component: slapd (show other issues)
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: 2.5.0
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-21 17:20 UTC by Michael Ströder
Modified: 2020-10-14 21:04 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Michael Ströder 2012-09-21 17:20:59 UTC
Full_Name: Michael Str�der
Version: 
OS: 
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (2001:8d8:1fe:1:d6be:d9ff:fe06:a14f)


Feature request:
When using LDAPS or StartTLS it would be sometimes handy to retrieve the LDAP
server certificate over the LDAP client API.

Opinions?
Comment 1 Howard Chu 2012-09-21 17:43:42 UTC
michael@stroeder.com wrote:
> Full_Name: Michael Ströder
> Version: 
> OS: 
> URL: ftp://ftp.openldap.org/incoming/
> Submission from: (NULL) (2001:8d8:1fe:1:d6be:d9ff:fe06:a14f)
> 
> 
> Feature request:
> When using LDAPS or StartTLS it would be sometimes handy to retrieve the LDAP
> server certificate over the LDAP client API.
> 
> Opinions?

And then what? I think it'd be straightforward for us to return a copy of it
in DER binary format. What do clients need to do with it?

-- 
  -- Howard Chu
  CTO, Symas Corp.           http://www.symas.com
  Director, Highland Sun     http://highlandsun.com/hyc/
  Chief Architect, OpenLDAP  http://www.openldap.org/project/

Comment 2 Michael Ströder 2012-09-21 18:28:02 UTC
On Fri, 21 Sep 2012 10:43:42 -0700 Howard Chu <hyc@symas.com> wrote
> michael@stroeder.com wrote:
> > Feature request:
> > When using LDAPS or StartTLS it would be sometimes handy to retrieve the
> > LDAP server certificate over the LDAP client API.
> > 
> > Opinions?
> 
> And then what? I think it'd be straightforward for us to return a copy of it
> in DER binary format. What do clients need to do with it?

In my case (web2ldap): Simply display it to the user.

If it's not too much work this would be a handy feature.

Ciao, Michael.


Comment 3 Kurt Zeilenga 2012-09-21 22:53:17 UTC
Why not just get it from TLS? 

-- Kurt

Comment 4 Michael Ströder 2012-09-22 11:44:15 UTC
Kurt Zeilenga wrote:
> Why not just get it from TLS? 

What exactly do you mean?

Ciao, Michael.

Comment 5 Hallvard Furuseth 2012-09-22 13:50:35 UTC
 michael@stroeder.com wrote:
>Kurt Zeilenga wrote:
>> Why not just get it from TLS?

 That does require an #ifdef <which TLS implementation> mess in
 the client.  libldap already has that.

> What exactly do you mean?

 In OpenSSL, SSL_get_peer_certificate().

 I note that it might also or instead make sense to ask for the
 cert chain - OpenSSL SSL_get_peer_cert_chain().  Which quickly
 dives into how many other TLS session attributes it would make
 sense to kindly provide an LDAP API interface to...

 Hallvard

Comment 6 Hallvard Furuseth 2012-09-22 13:59:48 UTC
 I wrote:
> In OpenSSL, SSL_get_peer_certificate().

 ..after getting the SSL* arg with
 ldap_get_option LDAP_OPT_X_TLS_SSL_CTX.
 Which the manpage recommends not doing.  At least
 don't meddle with the SSL* more than you have to.

 Hallvard

Comment 7 ando@openldap.org 2012-09-22 14:10:37 UTC
>  I wrote:
>> In OpenSSL, SSL_get_peer_certificate().
>
>  ..after getting the SSL* arg with
>  ldap_get_option LDAP_OPT_X_TLS_SSL_CTX.
>  Which the manpage recommends not doing.  At least
>  don't meddle with the SSL* more than you have to.

I presume Michael's case is one of the few in which the client would pay
enough attention to details when using such an option.

Whether a case like this deserves an OpenLDAP API is questionable, since
it is not an LDAP-specific issue, but rather a general SSL wrapping issue.
 OTOH, as long as clever client design often needs it, I would not object
to adding such feature.

p.

-- 
Pierangelo Masarati
Associate Professor
Dipartimento di Ingegneria Aerospaziale
Politecnico di Milano

Comment 8 Michael Ströder 2012-09-22 14:32:29 UTC
Hallvard Breien Furuseth wrote:
> I wrote:
>> In OpenSSL, SSL_get_peer_certificate().
> 
> ..after getting the SSL* arg with
> ldap_get_option LDAP_OPT_X_TLS_SSL_CTX.
> Which the manpage recommends not doing.  At least
> don't meddle with the SSL* more than you have to.

Hmm, but then the client has to deal with whether libldap is linked to
OpenSSL, libnss or GnuTLS...

Unfortunately in the current project where I'm using web2ldap the python-ldap
libs are linked against the OpenLDAP libs shipped with Debian => GnuTLS.

Ciao, Michael.

Comment 9 Kurt Zeilenga 2012-09-22 21:25:41 UTC
On Sep 22, 2012, at 8:24 AM, michael@stroeder.com wrote:

> Hallvard Breien Furuseth wrote:
>> I wrote:
>>> In OpenSSL, SSL_get_peer_certificate().
>> 
>> ..after getting the SSL* arg with
>> ldap_get_option LDAP_OPT_X_TLS_SSL_CTX.
>> Which the manpage recommends not doing.  At least
>> don't meddle with the SSL* more than you have to.

That statement, IIRC, was made mostly because unless you control your build of libldap (or control which libldap you use), you don't know what TLS implementation lies underneath.

> Hmm, but then the client has to deal with whether libldap is linked to
> OpenSSL, libnss or GnuTLS...

Yes. but often that's only one. 

Anyways, I see little reason to add cert extraction code in libldap.  Most folks who need this need this for more than one protocols, and it's easier/better for them to use a common facilities for doing this across all these protocols.

But, hey, if someone wants to write such code for all the supported TLS layers, have at it.  But like most things for non-OpenSSL, your mileage will vary.

> 
> Ciao, Michael.
> 
> 


Comment 10 Howard Chu 2012-09-27 15:07:16 UTC
moved from Incoming to Software Enhancements
Comment 11 Howard Chu 2013-09-10 11:32:51 UTC
Michael Ströder wrote:
> On Fri, 21 Sep 2012 10:43:42 -0700 Howard Chu <hyc@symas.com> wrote
>> michael@stroeder.com wrote:
>>> Feature request:
>>> When using LDAPS or StartTLS it would be sometimes handy to retrieve the
>>> LDAP server certificate over the LDAP client API.
>>>
>>> Opinions?
>>
>> And then what? I think it'd be straightforward for us to return a copy of it
>> in DER binary format. What do clients need to do with it?
>
> In my case (web2ldap): Simply display it to the user.

Probably would have been easier to just return the signature.

> If it's not too much work this would be a handy feature.

Added in master, please test - I have not tested any of this.

-- 
   -- Howard Chu
   CTO, Symas Corp.           http://www.symas.com
   Director, Highland Sun     http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP  http://www.openldap.org/project/

Comment 12 Howard Chu 2013-09-19 17:48:45 UTC
changed notes
changed state Open to Test
Comment 13 OpenLDAP project 2014-08-01 21:04:57 UTC
added in master