Use s->session->peer instead of calling SSL_get_peer_certificate(s)