Thank you Howard, I missed that option.


De: Howard Chu <hyc@symas.com>
Enviado: jueves, 2 de abril de 2020 13:06
Para: Lasa Martxel <mlasa@ikerlan.es>; openldap-technical@openldap.org <openldap-technical@openldap.org>
Asunto: Re: Multiple OpenLDAP client instances with the c library
 


Lasa Martxel wrote:
> Hello Howard,
>
> I have tried that, but without success.
>
> I have had a look at the tls implementation, and once the tls context is created and initialized, it is only destroyed when the reference count to the context
> is 0, which happens when the context is destroyed.
>
>>From what I've seen, the context is destroyed when the program exits (atexit callback).
>
> The tls context contains the client certificates among other things, so I can't reinitialize it with the new ones for the second instance.
>
> I may be missing something.

Yes. Read the ldap_set_option(3) manpage more carefully. Use LDAP_OPT_X_TLS_NEWCTX.

>
> Thanks!
>
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------
> *De:* Howard Chu <hyc@symas.com>
> *Enviado:* jueves, 2 de abril de 2020 12:31
> *Para:* Lasa Martxel <mlasa@ikerlan.es>; openldap-technical@openldap.org <openldap-technical@openldap.org>
> *Asunto:* Re: Multiple OpenLDAP client instances with the c library
>
> Lasa Martxel wrote:
>> Hello,
>>
>> I'm using the openldap c client library (2.4.45).
>>
>> I would like to somehow have two client instances (not necessarily simultaneously) within the same application, but I'm having issues with the second instance I
>> create.
>>
>> I have not found a way to clear the global options so the new ones (different ca cerficiate, different client certificate) can be used with the second instance.
>> With the second ldap_initialize, global options are already initialized. Same with the TLS context, it's initialized too.
>
> So just use ldap_set_option on the second LDAP* handle and change the options.
>
> --
>   -- Howard Chu
>   CTO, Symas Corp.
> https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.symas.com&amp;data=02%7C01%7Cmlasa%40ikerlan.es%7Cc8fbfb0c43c54b81ed9208d7d6f5ee41%7C910ac815f8554a08bf2990b46552cf11%7C0%7C0%7C637214224071927896&amp;sdata=UxIZ7qw9%2FC%2FLPSCrq2TQan1zoHTAdYTBs6xWbem3BzY%3D&amp;reserved=0
>   Director, Highland Sun
> https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fhighlandsun.com%2Fhyc%2F&amp;data=02%7C01%7Cmlasa%40ikerlan.es%7Cc8fbfb0c43c54b81ed9208d7d6f5ee41%7C910ac815f8554a08bf2990b46552cf11%7C0%7C0%7C637214224071927896&amp;sdata=K6yCcDvS14rrPhVTVAV%2Bn7ryHsIp%2F2ckhQX8%2FskaMaA%3D&amp;reserved=0
>   Chief Architect, OpenLDAP
> https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.openldap.org%2Fproject%2F&amp;data=02%7C01%7Cmlasa%40ikerlan.es%7Cc8fbfb0c43c54b81ed9208d7d6f5ee41%7C910ac815f8554a08bf2990b46552cf11%7C0%7C0%7C637214224071927896&amp;sdata=dh48aaR2XM4OarR2fB%2Bnp0ailChTM3tS7DS5V0FIOAo%3D&amp;reserved=0


--
  -- Howard Chu
  CTO, Symas Corp.           https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.symas.com&amp;data=02%7C01%7Cmlasa%40ikerlan.es%7Cc8fbfb0c43c54b81ed9208d7d6f5ee41%7C910ac815f8554a08bf2990b46552cf11%7C0%7C0%7C637214224071937883&amp;sdata=mYkF6sY0%2FeWUskBoAKdDiWhqvIVxZ7d9TxfjfPTQAxA%3D&amp;reserved=0
  Director, Highland Sun     https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fhighlandsun.com%2Fhyc%2F&amp;data=02%7C01%7Cmlasa%40ikerlan.es%7Cc8fbfb0c43c54b81ed9208d7d6f5ee41%7C910ac815f8554a08bf2990b46552cf11%7C0%7C0%7C637214224071937883&amp;sdata=EH7luNyyhczpenFQU18PZZNycpzEgHtdx%2BK0SiOdS44%3D&amp;reserved=0
  Chief Architect, OpenLDAP  https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.openldap.org%2Fproject%2F&amp;data=02%7C01%7Cmlasa%40ikerlan.es%7Cc8fbfb0c43c54b81ed9208d7d6f5ee41%7C910ac815f8554a08bf2990b46552cf11%7C0%7C0%7C637214224071937883&amp;sdata=vuxW%2FIZ58S9TCz71AE491%2BNcH%2FriirX4sb9N%2FAI6Czk%3D&amp;reserved=0