On October 20, 2003 06:42 am, Ana Isabel Ramirez Saiz wrote:
> I am trying to find, with no success, the source code of some ssl
> methods, specifically, ssl_connect and ssl_accept .The SSL_connect and
> SSL_accept functions calls them:
>
>   return (s->method->ssl_accept(s))
>   return (s->method->ssl_connect(s))
>
>
> and I have found their declaration on ssl.h file:
>
>   typedef struct ssl_method_st
>      int (*ssl_connect)(SSL *s)
>      int (*ssl_accept)(SSL *s)
> but not their source code, I would really thank if someone can help me
> to find it, many thanks in advance

Welcome to the dark world of SSLea... erm ... "OpenSSL". SSL_METHOD 
(struct ssl_method_st) is a virtual table allowing an SSL object to have 
a different set of implementation callbacks depending on requirements 
(eg. client or server? SSLv2, SSLv3, TLSv1, or a compatibility mode for 
all of them?). So the implementation of those handlers depends, at 
run-time, on what "s->method" is pointing to. In fact, things get more 
complicated than that - an SSL object can start out with a SSL_METHOD 
vtable that allows it to perform handshaking and dynamically negotiate 
what protocol version should be used, and then it can switch the 
SSL_METHOD for another that corresponds to that version.

Anyway, that's all just as a warning - the code in ./ssl/ is hard and 
unpleasant so I don't want to give the impression that it is (i) easy to 
follow, or (ii) logical. It (i) certainly isn't, and (ii) often isn't, 
respectively. :-)

For your typical startup state for a client, the SSL object will be using 
the SSL_METHOD returned from SSLv23_client_method(), see ssl/s23_clnt.c, 
and specifically the "ssl_connect" pointer is mapped to the 
ssl23_connect() function. Likewise in an SSL/TLS server, you should see 
ssl/s23_srvr.c and the s23_accept() function. My advice, if you want to 
understand the code, would be to verify that you can run and use the 
"openssl [s_client | s_server]" tools, then build openssl with debugging 
flags and just watch s_server or s_client from a debugger. You could set 
breakpoints on SSL_accept, SSL_connect, SSL_read, [etc] and just keep an 
eye on the SSL structure and the SSL_METHOD table its "method" pointer 
points to. Good luck.

Cheers,
Geoff

-- 
Geoff Thorpe
[EMAIL PROTECTED]
http://www.openssl.org/

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to