Dr Stephen Henson wrote:
>
> Scheltema, R.A. wrote:
> >
> > Hi all,
> >
> > I'm currently working on an implementation of a program using openssl. In
> > this program it would be extremely usefull if I could pass data to the
> > callback-functions in the way, for example, the thread call-back method is
> > done (or x-event-methods, ...). The password method would look like:
> >
> > struct myData {
> > // ...
> > };
> >
> > static int __supply_passwd(char *buf, int len, int WhatIsThis, void *data) {
> > struct myData *md = (myData *) data;
> > // ...
> > }
> >
> > int main() {
> > myData *d = new myData;
> > SSL_CTX_set_default_passwd_cb(m_ctx, &__supply_passwd, (void *) d);
> > // ...
> > return 0;
> > }
> >
> > With the current situation it is, according to me, impossible to do this. Or
> > am I wrong? If not is it an option for future releases ??
> >
>
> I think the best you can currently do is either have one callback for
> each piece of data or some yucky global variable version with thread
> specific data and appropriate locks.
>
> Adding an extra parameter to the password callbacks is a much cleaner
> way of handling things. Unfortunately lots of functions use them (e.g.
> PEM stuff) and it will break quite a lot of code (but all they will need
> is an extra parameter set to NULL) and its rather a large change.
>
> It is IMHO well worth doing so it may well appear in a future release.
You can already add "extra" data to the context, IIRC, so perhaps the
neater solution is to pass the context to the callback?
Cheers,
Ben.
--
http://www.apache-ssl.org/ben.html
"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
- Indira Gandhi
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]