Thanks, I've read the man page for SSL_get_peer_certificate() and it says it returns NULL if " No certificate was presented by the peer or no connection was established." After tracing through the code I see that SSL_get_peer_certificate() returns null because no connection has been established, ie it enters the following piece of code "if ((s == NULL) || (s->session == NULL))". I know for a fact that s is not NULL which means that s->session is NULL. Do you know of a reason why s->session would be NULL?
Thanks, John