[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: ldap_start_tls_s "Not Supported"



On Sun, 7 Apr 2002, Fredrik Jonson wrote:

> Hello all, 

Well, I've found the solution myself so for the completeness of
the mail archives here's my answer: 

> // begin tlstest.c
> #include <stdio.h>
> #include <ldap.h>
> 
> int main()
> {
>     LDAP *ldapStruct;
>     int result;
      int ldap_vers = LDAP_VERSION3; 
> 
>     ldapStruct = ldap_init("server.fqdn.from.ssl-cert", LDAP_PORT);
> 

 /*
  * One must set protocol version to LDAPv3 before TLS can be 
  * enabled. So after some digging in the source code of
  * ldapseach i found the magic function ldap_set_option... 
  */
      ldap_set_option(ldapStruct, 
                      LDAP_OPT_PROTOCOL_VERSION, 
                      &ldap_vers); // ldap_vers = LDAP_VERSION3

 // Now libldap2 executes start_tls as any other happy camper. =)

>     result = ldap_start_tls_s(ldapStruct, NULL, NULL);
>     printf("Start TLS: ");
>     printf(ldap_err2string(result));
>     printf("\n");
>     return 0;
> }
> // end of tlstest.c

  Start TLS: Success 

HTH, HAND / fredrik  
-- 
Fredrik Jonson
pt97fjo@student.bth.se