Re: BUG #4869: No proper initialization of OpenSSL-Engine in libpq - Mailing list pgsql-bugs

From Lars Kanis
Subject Re: BUG #4869: No proper initialization of OpenSSL-Engine in libpq
Date
Msg-id 200906221538.52316.kanis@comcard.de
Whole thread Raw
In response to Re: BUG #4869: No proper initialization of OpenSSL-Engine in libpq  (Magnus Hagander <magnus@hagander.net>)
List pgsql-bugs
Hi Magnus,

thanks for reply.
> > The following patch solves the problem:
>
> This looks good in generael to me. I remember looking at the engine code
> wondering why we didn't do that, but since I don't have a good
> environment to test that part in, I forgot about it :(
>
> Shouldn't there be an ENGINE_free() in the error path of ENGINE_init()?
In the patch it is already there, isn't it?

> Should we not also call ENGINE_finish() and ENGINE_free() in the success
> path of this code? Your patch adds it to the case where we didn't get
> the private key, but what if we did? I assume they should also go
> outside the error path, per the attached patch - or will that break
> their usage?
That's right. I thought about it, but I don't know where the right place is.

> Can you test that and verify that it doesn't break for you?
It breaks with Segmentation fault in my smartcard-based setup. The pkey-han=
dle=20
is all we have from the engine, when client_cert_cb() is finished. Obviousl=
y=20
the ref-counting of openssl does not take the pkey-handle into account, so =
we=20
need to keep the engine_ptr for later freeing.

close_SSL() should be the right place for ENGINE_finish() and ENGINE_free()=
 ?


--=20
Mit freundlichen Gr=C3=BC=C3=9Fen,

Lars Kanis
Bereichsleiter IT

Tel  +49 3745 769 -422=20
Fax +49 3745 769 -334=20
eMail: kanis@comcard.de=20

Sie k=C3=B6nnen sich unter http://www.comcard.de unseren Newsletter abonnie=
ren!

ComCard GmbH
Hammerbr=C3=BCcker Stra=C3=9Fe 3
08223 Falkenstein

Gesch=C3=A4ftsf=C3=BChrer: Dipl.-Ing. Ralph Siegel
Amtgericht Chemnitz HRB 3255
Ust.ID DE811118514

pgsql-bugs by date:

Previous
From: Lars Kanis
Date:
Subject: Re: BUG #4869: No proper initialization of OpenSSL-Engine in libpq
Next
From: Tom Lane
Date:
Subject: Re: BUG #4869: No proper initialization of OpenSSL-Engine in libpq